How to Develop C++ projects in Manjaro? In this post I will document my process and I’m asking you, do you have some better solution?
For C++ development we need two things:
- C++ compiler
- Some kind of development IDE
Compile and Run C++ project in Command line
In theory, we only need C++ compiler and simple text editor to start with C++ development. For this post I’m using GCC.
The GNU Compiler Collection includes front ends for C, C++, Objective-C, Fortran, Ada, Go, and D, as well as libraries for these languages (libstdc++,…). GCC was originally written as the compiler for the GNU operating system. The GNU system was developed to be 100% free software, free in the sense that it respects the user’s freedom.
We can install GCC on Manjaro with next command.
sudo pacman -Sy gcc
And now we can try to create simple C hello world example and run it in command line. For this, simple example I will use nano text editor and call GCC compiler from command line. So, let’s create GCC directory with hello.c file
mkdir GCC
cd GCC/
nano hello.c
and hello.c file contains:
#include <stdio.h>
int main() {
// printf() displays the string inside quotation
printf("Hello World!");
return 0;
}
And now we can simply compile for hello world example and run it with next commands.
gcc hello.c
ls -la
./a.out
But what will happen if we try C++ hello world example hello.cpp show bellow.
#include <iostream>
int main()
{
std::cout << "Hello, World!"<<std::endl;
return 0;
}
If we use the same command to compile this example we will get a error. We need to change command line to:
g++ hello.cpp
And for short project this can be enough. No overhead, no additional plugins and unnecessary GUI. But how complex can this be for the multiple file and all .h and .cpp file. What if we would like to debug our solution. For this reasons we use IDE and I this post I will install and configure the CodeLite.
Install CodeLite in Manjaro
This is very easy thing if first we enable the Arch User Repository of AUR. So lets enable AUR.
And now we have CodeLite installed. Now we need just to configure the CodeLite
Configure CodeLite
Create Workspace and Project
Create Workspace and then create additional Project for C++. And then setup the project like on next image:
And now we have configure CodeLite and we can try simple Hello World C++ example program. That is shown on image bellow.
And that is basically it. Now we have installed GCC compiler and CodeLite IDE that is configured to work with C++17 standard. And that is all on how to develop C++ projects in Manjaro.
Now we can start developing C++ project in Manjaro. What IDE do you use? Did you manage to follow this tutorial and install CodeLite on your PC? If you want to try this on virtual machine, take a look at my other post https://bln364.com/how-to-start-with-virtual-machines-in-2020/. And as always, see you in the next one.
Thanks man, I was looking for that
Your tutorial was a great help!!!! Thank you!!!!
These instructions worked for newer release of Codelite– 15.0.2 which I downloaded instead of codelite-bin. The entire process worked all the way through!
(My only hiccup was in locating the Project Settings dialog button for the drop down menu for the C++ Compiler Options. In the newer version the button isn’t visible until clicking into the cell on the right. When the button appears it is blank- they removed the three dots which was what I was looking for. LOL!!)