Joseph Garvin <joseph.h.garvin@xxxxxxxxx> writes: > Can anyone explain the differences between using -shared, -symbolic, and -G? > > I've noticed two differences: > > 1. If I compile a shared library with -G, will contain an undefined > reference to main that will prevent linking if -z defs is present. If > I compile with -shared or -symbolic, the reference doesn't exist. > > 2. If I compile a shared library with -G, it doesn't matter if I > statically link libraries. If I use -shared or -symbolic, I get > millions of unresolved text relocation errors unless I add > -mimpure-text. > > What is the -G option actually doing differently? The man page simply > recommends you use -shared or -symbolic instead, but doesn't explain > why or how to choose. Are shared and symbolic synonyms? The man page > says share and symbolic only work on certain platforms, but it's > unclear if it's the same platforms in both cases. The -G option takes an argument, which is the size of data which is considered "small." This is only meaningful on a few targets, such as MIPS. I don't really understand your questions about it. The -symbolic option modifies -shared to indicate that all symbols should be resolved locally. Normally the executable may override a symbol defined in a shared library, so that if function f() in the shared library calls g() in the shared library, if the executable defines g(), then f() will call g() from the executable. The -symbolic option reverses this so that f() will call g() from the shared library. In most cases it's better to use explicit symbol visibility rather than -symbolic. Ian