Relative Content

Tag Archive for gcc

Questions about linking libraries in C

I am learning C (still very much a beginner) on Linux using the GCC compiler. I have noticed that some libraries, such as the library used with the math.h header, need to be linked in manually when included. I have been linking in the libraries using various flags of the form -l[library-name], such as -lm for the above-mentioned math library.

How do .so files avoid problems associated with passing header-only templates like MS dll files have?

Based on the discussion around this question. I’d like to know how .so files/the ELF format/the gcc toolchain avoid problems passing classes defined purely in header files (like the std library). According to Jan in that answer, the dynamic linker/loader only picks one version of such a class to load if its defined in two .so files. So if two .so files have two definitions, perhaps with different compiler options/etc, the dynamic linker can pick one to use.

Larger Code is Still Faster

When compiling C code with gcc, there are compiler optimizations, some that limit code size and others create fast code.

Larger Code is Still Faster

When compiling C code with gcc, there are compiler optimizations, some that limit code size and others create fast code.