Compilers
gcc
- GNU C Compiler
Some basic flags related to gcc
For compiling
-ccompile without linking files-o <filename>for output file name-I <directory>add directories to be searched for the header files-L <directory>add directory to be searched for the libraries-l<library>links a library
For debugging
-gfor debugging level-ggdbfor gdb
For optimization
-O0No optimization (default).-O1Basic optimization.-O2Moderate optimization.-O3Maximum optimization.-OsOptimization for size.
For warnings and error
-Wall- all warning as error-WextraEnables extra warning messages.-WerrorTreats all warnings as errors.
Setting standard
-std=<standard>Specifies the standard to which the code should conform-std=c99,-std=c11
Others
-vDisplays the commands being executed by the compiler.-pthreadEnables multi-threading with the POSIX threads library.-staticProduces a statically linked executable.
msvc
- Microsoft visual studio compiler
LLVM
- used in making compilers
How to link libraries
Finding Libraries ldconfig
List all installed libraries on the system.
ldconfig -p | grep libcurl
After that you can grep some particular one ldconfig -p | grep libcurl
pkg-config
Suppose you want to know how to link a library libcurl
You can use pkg-config --cflags --libs libcurl.
This will give you what to add to you gcc command.
-I/usr/include/x86_64-linux-gnu -lcurl