Conan C++ Package Manager

install conan

sudo apt install python3-pip
pip install conan

looking for library

conan search poco --remote=conancenter

creating a conanfile.txt inside our project’s folder with the following content:



Next step: We are going to install the required dependencies and generate the information for the build system:

$ conan profile new default --detect  # Generates default profile detecting GCC and sets old ABI
$ conan profile update settings.compiler.libcxx=libstdc++11 default  # Sets libcxx to C++11 ABI
$ mkdir build && cd build  #create build folder of cmake binary
$ conan install ..           #install libraries
#or conan install .. --settings os="Linux" --settings compiler="gcc"

Now let’s create our build file. To inject the Conan information, include the generated conanbuildinfo.cmake file like this:

 cmake_minimum_required(VERSION 2.8.12)



 add_executable(md5 md5.cpp)
 target_link_libraries(md5 ${CONAN_LIBS})

C Libraries


double atof(const char *str)
Converts the string pointed to, by the argument str to a floating-point number (type double).
int atoi(const char *str)
Converts the string pointed to, by the argument str to an integer (type int).
long int atol(const char *str)
Converts the string pointed to, by the argument str to a long integer (type long int).
double strtod(const char *str, char **endptr)
Converts the string pointed to, by the argument str to a floating-point number (type double).
long int strtol(const char *str, char **endptr, int base)
Converts the string pointed to, by the argument str to a long integer (type long int).
unsigned long int strtoul(const char *str, char **endptr, int base)
Converts the string pointed to, by the argument str to an unsigned long integer (type unsigned long int).
void *calloc(size_t nitems, size_t size)
Allocates the requested memory and returns a pointer to it.
void free(void *ptr)
Deallocates the memory previously allocated by a call to calloc, malloc, or realloc.
void *malloc(size_t size)Allocates the requested memory and returns a pointer to it.
void *realloc(void *ptr, size_t size)
Attempts to resize the memory block pointed to by ptr that was previously allocated with a call to malloc or calloc.
void abort(void)
Causes an abnormal program termination.
int atexit(void (*func)(void))
Causes the specified function func to be called when the program terminates normally.
void exit(int status)
Causes the program to terminate normally.
char *getenv(const char *name)
Searches for the environment string pointed to by name and returns the associated value to the string.
int system(const char *string)
The command specified by string is passed to the host environment to be executed by the command processor.
void *bsearch(const void *key, const void *base, size_t nitems, size_t size, int (*compar)(const void *, const void *))
Performs a binary search.
void qsort(void *base, size_t nitems, size_t size, int (*compar)(const void *, const void*))
Sorts an array.
int abs(int x)
Returns the absolute value of x.
div_t div(int numer, int denom)
Divides numer (numerator) by denom (denominator).
long int labs(long int x)
Returns the absolute value of x.
ldiv_t ldiv(long int numer, long int denom)
Divides numer (numerator) by denom (denominator).
int rand(void)
Returns a pseudo-random number in the range of 0 to RAND_MAX.
void srand(unsigned int seed)
This function seeds the random number generator used by the function rand.
int mblen(const char *str, size_t n)
Returns the length of a multibyte character pointed to by the argument str.
size_t mbstowcs(schar_t *pwcs, const char *str, size_t n)
Converts the string of multibyte characters pointed to by the argument str to the array pointed to by pwcs.
int mbtowc(whcar_t *pwc, const char *str, size_t n)
Examines the multibyte character pointed to by the argument str.
size_t wcstombs(char *str, const wchar_t *pwcs, size_t n)
Converts the codes stored in the array pwcs to multibyte characters and stores them in the string str.
int wctomb(char *str, wchar_t wchar)
Examines the code which corresponds to a multibyte character given by the argument wchar.
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int main () {
   int n=4;//number of elements
   int *a;
   a = (int*)calloc(n, sizeof(int));

   char *str;
   str = (char *) malloc(15);
   strcpy(str, "tutorialspoint");
   str = (char *) realloc(str, 25);
   strcat(str, ".com");//append string

   free( a );

ubuntu C++ configurations

build-essential : tools and libraries that are required to compile a program. For example, if you need to work on a C/C++ compiler, you need to install essential meta-packages on your system before starting the C compiler installation. When installing the build-essential packages, some other packages such as G++, dpkg-dev, GCC and make, etc. also install on your system.

Cmake + Ninja

GDB: The GNU Project Debugger

then for Qt and vcpkg

Besides build-essential and cmake you need to install git

for vcpkg

sudo apt-get install curl zip unzip tar
sudo apt-get install pkg-config
apt install gperf
sudo apt-get install bison
sudo apt install git
sudo apt install autopoint  
sudo apt install gettext
sudo apt install libtool 

for Qt

sudo apt-get install mesa-common-dev
sudo apt install libglu1-mesa-dev -y
sudo apt-get install libglfw3-dev libgl1-mesa-dev libglu1-mesa-dev
sudo apt install libfontconfig1-dev libfreetype6-dev libx11-dev libx11-xcb-dev libxext-dev libxfixes-dev libxi-dev libxrender-dev libxcb1-dev libxcb-glx0-dev libxcb-keysyms1-dev libxcb-image0-dev libxcb-shm0-dev libxcb-icccm4-dev libxcb-sync-dev libxcb-xfixes0-dev libxcb-shape0-dev libxcb-randr0-dev libxcb-render-util0-dev libxcb-util-dev libxcb-xinerama0-dev libxcb-xkb-dev libxkbcommon-dev libxkbcommon-x11-dev

C++ Useful Libraries

random standard c++ library

std::default_random_engine generator;
std::uniform_int_distribution<int> distribution(1,6);
int dice_roll = distribution(generator);  //between [1,6]
std::default_random_engine generator;
std::uniform_real_distribution<double> distribution(0.0,2.0);
double random = distribution(generator);//between [0.0,2.0)

simd library( single instruction multiple data)

C++ wrappers for SIMD intrinsics and parallelized, optimized mathematical functions (SSE, AVX, NEON, AVX512)

#include <iostream>
#include "xsimd/xsimd.hpp"

namespace xs = xsimd;

int main(int argc, char* argv[])
    xs::batch<double, xs::avx2> a(1.5, 2.5, 3.5, 4.5);
    xs::batch<double, xs::avx2> b(2.5, 3.5, 4.5, 5.5);
    auto mean = (a + b) / 2;
    std::cout << mean << std::endl;
    return 0;
#include <cstddef>
#include <vector>
#include "xsimd/xsimd.hpp"

namespace xs = xsimd;
using vector_type = std::vector<double, xsimd::aligned_allocator<double>>;

void mean(const vector_type& a, const vector_type& b, vector_type& res)
    std::size_t size = a.size();
    constexpr std::size_t simd_size = xsimd::simd_type<double>::size;
    std::size_t vec_size = size - size % simd_size;

    for(std::size_t i = 0; i < vec_size; i += simd_size)
        auto ba = xs::load_aligned(&a[i]);
        auto bb = xs::load_aligned(&b[i]);
        auto bres = (ba + bb) / 2.;
    for(std::size_t i = vec_size; i < size; ++i)
        res[i] = (a[i] + b[i]) / 2.;
#include <cstddef>
#include <vector>
#include "xsimd/xsimd.hpp"
#include "xsimd/stl/algorithms.hpp"

namespace xs = xsimd;
using vector_type = std::vector<double, xsimd::aligned_allocator<double>>;

void mean(const vector_type& a, const vector_type& b, vector_type& res)
    xsimd::transform(a.begin(), a.end(), b.begin(), res.begin(),
                     [](const auto& x, const auto& y) { (x + y) / 2.; });

dlfcn Lybrary


Vcpkg helps you manage C and C++ libraries on Windows, Linux and MacOS. This tool and ecosystem are constantly evolving, and we always appreciate contributions!

//for windows
> git clone
> .\vcpkg\bootstrap-vcpkg.bat
> set PATH=vcpkg_folder;%PATH%	
//for linux you need g++
$ sudo apt-get update
$ sudo apt-get install build-essential tar curl zip unzip
$ sudo apt-get install -y pkg-config
$ git clone
$ ./vcpkg/

Search , Install and remove packages

.\vcpkg\vcpkg search [search term]
.\vcpkg\vcpkg install [packages to install]
.\vcpkg\vcpkg install [package name]:x64-windows
.\vcpkg\vcpkg install [packages to install] --triplet=x64-windows
.\vcpkg\vcpkg remove [packages to install]

In order to use vcpkg with Visual Studio, run the following command (may require administrator elevation):

.\vcpkg\vcpkg integrate install
.\vcpkg\vcpkg integrate remove

In order to use vcpkg with CMake outside of an IDE, you can use the toolchain file:

> cmake -B [build directory] -S . -DCMAKE_TOOLCHAIN_FILE=[path to vcpkg]/scripts/buildsystems/vcpkg.cmake
> cmake --build [build directory]

for more visit this page

understand C compilers and build system and debugers

  • CMake — build system generator
    • You use this define how to compile your code
  • gcc/g++/clang/clang++ — compilers
    • compilers turn your code into binaries
    • gcc and g++ are the GNU C and C++ compilers, respectively
    • clang and clang++ are the LLVM compilers, respectively
    • Use CMake to define how to invoke compilers on the source code files
  • gdb/lldb — debuggers
    • gdb is a debugger provided by GNU
    • lldb is a debugger provided by LLVM
    • Use these to detect issues when running your binaries
    • It generally does not matter which compiler was used to generate the binary, i.e. you can use LLDB to debug a code compiled with a GNU compiler or vice versa

diffrence between make and cmake

Make (or rather a Makefile) is a buildsystem – it drives the compiler and other build tools to build your code.

CMake is a generator of buildsystems. It can produce Makefiles, it can produce Ninja build files, it can produce KDEvelop or Xcode projects, it can produce Visual Studio solutions. From the same starting point, the same CMakeLists.txt file. So if you have a platform-independent project, CMake is a way to make it buildsystem-independent as well.

If you have Windows developers used to Visual Studio and Unix developers who swear by GNU Make, CMake is (one of) the way(s) to go.

cmake -G"MSYS Makefiles"  when compiling for MinGW
cmake -G "Visual Studio 16 2019" -A Win32  when compiling for vs
cmake -G "Visual Studio 16 2019" -A x64 when compiling for vs

for more about cmake

GCC and G++

The GNU C and C++ compiler are called gcc and g++, respectively.

// Compile and link source file hello.c into executable a.exe (Windows) or a (Unixes)
> gcc hello.c
// (Unixes / Mac OS X) In Bash shell
$ gcc -o hello hello.c
$ chmod a+x hello
$ ./hello

// (Windows) In CMD shell
> g++ -o hello.exe hello.cpp
   // Compile and link source hello.cpp into executable hello.exe
> hello
// Execute under CMD shell

// (Unixes / Mac OS X) In Bash shell
$ g++ -o hello hello.cpp
$ chmod a+x hello
$ ./hello
$ g++ -Wall -g -o Hello.exe Hello.cpp
-o: specifies the output executable filename.
-Wall: prints "all" Warning messages.
-g: generates additional symbolic debuggging information for use with gdb debugger.
// Compile-only with -c option
> g++ -c -Wall -g Hello.cpp
// Link object file(s) into an executable
> g++ -g -o Hello.exe Hello.o
-c: Compile into object file "Hello.o". By default, the object file has the same name as the source file with extension of ".o" (there is no need to specify -o option). No linking with other object files or libraries.
Linking is performed when the input file are object files ".o" (instead of source file ".cpp" or ".c"). GCC uses a separate linker program (called ld.exe) to perform the linking.

Suppose that your program has two source files: file1.cppfile2.cpp. You could compile all of them in a single command:

g++ -o myprog.exe file1.cpp file2.cpp 

However, we usually compile each of the source files separately into object file, and link them together in the later stage. In this case, changes in one file does not require re-compilation of the other files.

> g++ -c file1.cpp
> g++ -c file2.cpp
> g++ -o myprog.exe file1.o file2.o
gcc program.o -llib1 -Wl,-Bstatic -llib2 -Wl,-Bdynamic -llib3 // link dynamic and static filels and object to executable file
> cpp hello.c > hello.i //preprocessing 
> gcc -S hello.i //compilation generate assembly code
> as -o hello.o hello.s //assembler generate machine code 
> ld -o hello.exe hello.o ...libraries... linker and generate excutable machine code
g++ --std=c++2a test2.cpp -o test2 //select c++ version

GNU Make

First Makefile By Example

// hello.c
#include <stdio.h>
int main() {
    printf("Hello, world!\n");
    return 0;
all: hello.exe

hello.exe: hello.o
	 gcc -o hello.exe hello.o

hello.o: hello.c
	 gcc -c hello.c
	 rm hello.o hello.exe

Run the “make” utility as follows:

> make
gcc -c hello.c
gcc -o hello.exe hello.o