On Jan 25, 1:45 am, Bernd Strieder <[EMAIL PROTECTED]> wrote: > Hello, > > [EMAIL PROTECTED] wrote: > > I'm battling a linker issue. Here is the scenario. I have two static > > libraries libA.a and libB.b and am trying to create an executable > > hello.exe from hello.cpp, libA.a and libB.a. > > g++ -W -Wall -pipe -g -o main.exe main.o -Lblah/src -Lblah/lib1 - > > Lblah/lib2 blah/lib1/libA.a blah/lib2/libB.a > > > I got this.... > > > blah/lib2/libB.a(libB.o): In function `ZN1B1aESs': > > blah/lib2/libB.cpp:9: undefined reference to `A::printB(std::string)' > > blah/lib2/libB.a(libB.o): In function `ZN1B1bEi': > > blah/lib2/libB.cpp:15: undefined reference to `A::printA(int)' > > libB depends on libA, so libA should go after libB in the command line, Yup that worked! Thanks
> or you have to use the --start-group --end-group options. The GNU > linker (and possibly most other linkers) treats all linked files in the > command-line in the order they are given, not returning to an earlier > one automatically. In your case you might get away most easily by > linking libA once before libB and again after it. Just linking libA after libB worked. > It is generally best to avoid circular references, since it is prone to > errors and whatever you do, it adds overhead to the linking process. Thanks! I'll keep that in mind. Sriram _______________________________________________ help-gplusplus mailing list help-gplusplus@gnu.org http://lists.gnu.org/mailman/listinfo/help-gplusplus