0

I have a subdirs Qt project composed of :

  • an external (not made by me) lib
  • an internal (made by me) lib using the external lib
  • an application using the internal lib

I am on Windows using mingw as compiler

When compiling the libraries I have no issues, everything seems to work fine.

But when I compile the application, I get an ld error : undefined reference to external lib functions (called from internal libs function).

I think this is because when compiling the internal library these method are not called therefore not loaded and this is why it can't find them.

Is there a way to combine the 2 libraries (or at least to force the compiler/linker to resolve the symbols) when compiling the internal library ?

f222
  • 352
  • 2
  • 13

1 Answers1

0

I found a way to fix my issue.

In the pro file of my internal lib :

  • I changed the TARGET value from internal_lib to internal_lib_unlinked.
  • I added a new line QMAKE_POST_LINK += ar crsT $$DESTDIR/libinternal_lib.a $$DESTDIR/libinternal_lib_unlinked.a path/to/libexternal_lib.a

This is hacky but it works.

Found thanks to How to combine several C/C++ libraries into one?

f222
  • 352
  • 2
  • 13