Archive-maintaining program; default ‘ar’.
Program for compiling assembly files; default ‘as’.
Program for compiling C programs; default ‘cc’.
Program for compiling C++ programs; default ‘g++’.
Program for running the C preprocessor, with results to standard output; default ‘$(CC) -E’.
Program to use to run lint on source code; default ‘lint’.
Program to convert a Texinfo source file into an Info file; default ‘makeinfo’.
Program to make TeX DVI files from TeX source; default ‘tex’.
Command to remove a file; default ‘rm -f’.
Flags to give the archive-maintaining program; default ‘rv’.
Extra flags to give to the assembler (when explicitly invoked on a ‘.s’ or ‘.S’ file).
Extra flags to give to the C compiler.
Extra flags to give to the C++ compiler.
Extra flags to give to the C preprocessor and programs that use it (the C and Fortran compilers).
Extra flags to give to compilers when they are supposed to invoke the linker, ‘ld’, such as -L. Libraries (-lfoo) should be added to the LDLIBS variable instead.
Library flags or names given to compilers when they are supposed to invoke the linker, ‘ld’. LOADLIBES is a deprecated (but still supported) alternative to LDLIBS. Non-library linker flags, such as -L, should go in the LDFLAGS variable.
Extra flags to give to lint.
GNUDoc on Search-Path.
GCC looks in several different places for headers. if you do not instruct it otherwise, it will look for headers requested with "#include <file>" in the following order:
For C++ programs, it will look in libdir/../include/c++/version, first.
In the above, target is the canonical name of the system GCC was configured to compile code for; often but not always the same as the canonical name of the system it runs on. version is the version of GCC in use.
By default, GCC exports all symbols in DSO. So it is strongly recommended to restrict this by gcc -fvisibility=hidden -fvisibility-inlines-hidden, and export symbols manually with __attribute__ ((visibility ("default"))).
It very substantially improves load times of your DSO (Dynamic Shared Object).
It lets the optimiser produce better code.
It reduces the size of your DSO by 5-20%.
Much lower chance of symbol collision.
Use nm -C -D on the outputted DSO to compare before and after to see the difference it makes.
#pragma GCC visibility is stronger than -fvisibility; it affects extern declarations as well. -fvisibility only affects definitions. This is more true for C than C++; C++ interfaces tend use classes, which are affected by -fvisibility.
Problems with C++ exceptions: Exception catching of a user defined type in a binary other than the one which threw the exception requires a typeinfo lookup.
Just like functions and variables, types that are thrown between multiple shared objects are public interfaces and must have default visibility. The obvious first step is to mark all types throwable across shared object boundaries always as default visibility. You must do this because even if (e.g.) the exception type's implementation code lives in DLL A, when DLL B throws an instance of that type, the catch handler in DLL C will look for the typeinfo in DLL B.
Symbol visibility is "default" by default but if the linker encounters just one definition with it hidden - just one - that typeinfo symbol becomes permanently hidden (remember the C++ standard's ODR - one definition rule). This is true for all symbols, but is more likely to affect you with typeinfos; typeinfo symbols for classes without a vtable are defined on demand within each object file that uses the class for EH and are defined weakly so the definitions get merged at link time into one copy.
This issue also shows up with classes used as the operand of dynamic_cast. Make sure to export all such classes.
Decode (demangle) low-level symbol names into user-level names. Besides removing any initial underscore prepended by the system, this makes C++ function names readable. Different compilers have different mangling styles.
Display information from object files.
/usr/bin/ld: skipping incompatible /usr/lib/libSth.so when searching for -lSth
ArchBBS. It is mainly because you are on a x86_64 machine but LD looks at 32-bit libraries under /usr/lib instead of /usr/lib64.
How link to a specific version of a shared library