Strange compiling problem

New Message Reply Date view Thread view Subject view Author view

Jay Gischer (gischer++at++puget.engr.sgi.com)
Mon, 20 Apr 1998 10:52:54 -0700 (PDT)


Olivier Georg writes:
> Hi,
>
> I have a very strange compiling problem. In my Performer project,
> libptk++ I have several classes that when compiled are put together
> into a '.a' file (libptk++.a). Then this file is linked to the binary.
> I've recently added a class. I know it _is_ present in libptk++.a
> (I can see some string in it which are exclusive to this class)
> But when linking this file to the binary, all other classes are
> present, but not this new one ?
>
> The command to get the binary is :
>
> /usr/bin/CC -DIRIX6 -I../. -nostdinc -I/usr/include -mips2 -o32 -g
> -MDupdate Makedepend -o application.DBG -L/usr/lib/Performer/DebugStatic
> -L/usr/lib/Performer/DebugStatic/libpfdb -L/lib -lpf_ogl -lpfdu_ogl
> -lpfutil_ogl -lpfui -lvl -Wl,-none -limage -lfm -ignore_unresolved -lGLU
> -lGL -lXext -lXsgivc -lXmu -lX11 -lfpe -lm -lmalloc -lC -lcurses
> -L/usr/people/ogeorg/virgy/libptk++2.0/src/DBG.O32.OPENGL -lptk++
> ../../lib/libgizmo.a ../../lib/libmgl.a /usr/local/lib/libtcl.so
> /usr/local/lib/libtk.so
>
> One can see that libptk++ _is_ included, so how come something in libptk++
> is _not_ int application.DBG ? Has anyone already experienced this ?
>
> Olivier

Olivier,

Linking against a .a has different semantics than linking against a
.so. When you link against a .so, you automatically get everything
in the .so whether or not there is a current reference to it.

When you link against a .a, you only load those object files for which
there is an outstanding reference. What this means is that one of the
objects which appears *before* lptk++ must contain a reference to your
class in order for it to be loaded. Life can be even more complicated
if the routines for your class are defined in more than one object
file, in which case there would probably need to be a reference to the
particular method in question in one of the objects before "-lptk++"
to trigger loading of that method.

The solution is to either
1. Turn your .a into a dso (it isn't that hard, try "man dso") or,
2. Rearrange the order of your libraries, or
3. Use the linker flags "-all" and "-none"

"-all" will force the loading of every object file from any archives
encountered after the "-all" flag. "-none" (poorly named IMHO) turns
off "-all", returning to the normal archive semantics described above.

------------------------------------------------------------------------
Jay L Gischer + "I see great things in baseball. It's our game.
Advanced Graphics + It will repair our losses and be a blessing to
Software + us."
Silicon Graphics + -Walt Whitman
(415) 390-4277 +
gischer++at++sgi.com + "A life has no meaning except in the impact it
                     + has on other lives"
                     + -Jackie Robinson

=======================================================================
List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/
            Submissions: info-performer++at++sgi.com
        Admin. requests: info-performer-request++at++sgi.com


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:57:16 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.