Setting Up VSCode for Ubuntu
Step 1: Install Visual Studio Code (VSCode)
Open a terminal window.
Run the following commands to install VSCode:
sudo apt update sudo apt install codeOnce the installation is complete, you can launch VSCode from the Applications menu or by running
code
in the terminal.
Step 2: Install C/C++ Extension
Open VSCode.
Go to the Extensions view by clicking on the Extensions icon in the Activity Bar on the side of the window or using the keyboard shortcut
Ctrl+Shift+X
.In the Extensions view search box, type "C/C++".
Install the extension provided by Microsoft.
Step 3: Install a C Compiler
Open a terminal window.
Run the following command to install the build-essential package (includes GCC and other necessary tools):
sudo apt install build-essential
Step 4: Create a C File and Compile
Open VSCode.
Click on "File" > "New File" to create a new file.
Save the file with a
.c
extension, for example,hello.c
.Write your C code in the editor.
Open the terminal in VSCode.
Compile the code using the following command:
gcc hello.c -o helloRun the compiled program:
./hello
Step 5: Explore Other IDEs (Optional)
While VSCode is a great choice, you can explore alternative IDEs for C programming on Ubuntu:
Code::Blocks: Install using the following command:
sudo apt install codeblocksEclipse: Install using the following command:
sudo snap install eclipse --classic
Choose an IDE that best suits your preferences.
Conclusion
This guide has walked you through setting up Visual Studio Code for C programming on Ubuntu. Whether you continue with VSCode or explore other IDEs, make sure to choose the one that enhances your coding experience. Happy coding!