💻

Setting Up C/C++ Environment on Linux

Apr 19, 2025

Setting Up a Programming Environment for C/C++ on Linux

Introduction

  • New series announcement on programming with C and C++ on a Linux platform.
  • Focus on setting up programming environment using Ubuntu and Visual Studio Code.

Installing Visual Studio Code

Graphical Installation on Ubuntu

  • Use Ubuntu Software Center for installation.
  • Search for 'Visual Studio Code' in the application search bar.
  • Visual Studio Code is available on multiple platforms (Linux, MacOS, Windows).
  • Click 'Install' and authenticate with the administrative password.

Features of Visual Studio Code

  • Lightweight source editor supporting various languages.
  • Offers extensions for additional language support.

Exploring Visual Studio Code Interface

Welcome Page

  • Offers help content, videos, tips, and tricks.
  • Information on customizing the IDE and available commands.

Menu Options

  • File: Manage files and workspaces.
  • Edit: Undo, redo, cut, copy, paste.
  • View: Customize appearance and editor.
  • Go: Shortcuts for navigation.
  • Debug: Start/stop debugging, manage breakpoints.
  • Terminal: Build and run applications.
  • Help: Access documentation and updates.

Left Panel

  • Explorer: Manage projects, open/edit files.
  • Search: Search across files with filters.
  • Source Control: Integrate with repositories like GitHub.
  • Debugging: Configure debugging settings.
  • Extensions: Install add-ons to enhance functionality.

Installing Extensions

C/C++ Extension

  • Enables debugging, code browsing, and auto-completion for C/C++.

Code Runner

  • Supports multiple languages, facilitates building and running applications within the IDE.

Creating a C++ Program

Project Setup

  • Open a folder to act as a project directory.
  • Create a new file named main.cpp.

Writing a Simple C++ Program

  • Include the iostream library.
  • Define int main() function.
  • Use std::cout to print "Hello World!" to the console.
  • Return 0 to indicate successful execution.

Running the Program

  • Save the file and use the play button to compile and execute.
  • Output displayed in the terminal.

Installing Visual Studio Code via Terminal

Steps for Non-Graphical Installation

  • Download the appropriate .deb package for Ubuntu.
  • Use terminal commands:
    • sudo dpkg -i <package-location> to install.
    • sudo apt install -f to fix dependencies.
  • Check installation by launching Visual Studio Code from the applications menu.

Conclusion

  • Visual Studio Code is a versatile IDE suitable for various Linux distributions.
  • Importance of following series for further tutorials.
  • Encouragement to subscribe and provide feedback.