Linux, a static lib referencing another static lib in the executable

I am creating an application consisting of two static libraries and an executable file.

Let me name two static libraries: libusefulclass.a libcore.a

And application: MyApp

libcore creates an instance and uses the class defined in libusefulclass (let's call it usefulClass)

Now, if I link the application as follows:

g++ -m64 -Wl,-rpath,/usr/local/Trolltech/Qt-4.5.4/lib -o myapp src1.o src2.o srcN.o -lusefulclass -lcore

The component complains that no methods were found in libusefulclass:

undefined reference to `UsefulClass::foo()'

and etc.

I found a workaround for this: If HelpClass is also created in the source files of the executable itself, the application is connected without problems.

My question is: is there a cleaner way to force libcore to refer to methods defined in libusefulclass, or can static libraries simply not be linked to eachother?

TIA

P.S.: , : ++ Qt, , Qt, .

+3
1

,

g++ -m64 -Wl,-rpath,/usr/local/Trolltech/Qt-4.5.4/lib -o myapp src1.o src2.o srcN.o  -lcore -lusefulclass

, ,

g++ -m64 -Wl,-rpath,/usr/local/Trolltech/Qt-4.5.4/lib -o myapp src1.o src2.o srcN.o  -lusefulclass -lcore -lusefulclass
+6

Source: https://habr.com/ru/post/1741523/


All Articles