Search code examples
gccpremakenana

gcc auto link shared libraries needed by static libraries


I've installed the Nana library and I've read from their website that the library needs some shared libraries to work.. So during linking (gcc) i need to put all links (-lXft, -l...). Is there a solution to auto link shared libraries needed by Nana?

I am using ubuntu 18.04 and I've read that I can do that with Makefile but I haven't understood how.. I want to use Premake to organize my project so that I can say to Premake that it needs to include the Nana library and then Premake "smartly" find all shared libraries..

When I used Premake and I linked the Nana library (statically) the compiler gaves me a lot of errors...
all the errors say:

undefined reference to: X...

So I need to include all the shared libraries that Nana needs, but how?


Solution

  • gcc has no idea about inter-library dependencies. You need a build system (which would use gcc as the compiler) for that.

    Now, the Nana library uses the CMake build system. Thus a good solution to the problem should be to get the authors of Nana to properly export the library's CMake targets, and distribute a .cmake file which you can then import if you also build with CMake.

    Alternatively - perhaps such a CMake file already exists somewhere (I haven't been able to quickly find it though).

    I would ask about this in the Nana forums.