1

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?

Aiden Yeomin Nam
  • 315
  • 5
  • 16
Angelo13C
  • 43
  • 3
  • Look up *pkgconfig* system, it is for getting compiler and linker options for using libraries which need other libraries etc. – hyde Aug 30 '19 at 19:12

1 Answers1

0

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.

einpoklum
  • 118,144
  • 57
  • 340
  • 684
  • Thanks, I changed my mind, for now I am specifing the dynamics library in Premake and I'm doing fine – Angelo13C Sep 02 '19 at 07:46
  • I prefer to recommend to [add_subdirectory(nana ..)](https://github.com/qPCR4vir/nana-demo/blob/master/CMakeLists.txt#L24) and then [target_link_libraries(my_project PUBLIC nana)](https://github.com/qPCR4vir/nana-demo/blob/master/CMakeLists.txt#L32). What do you think? – qPCR4vir Oct 09 '19 at 09:46
  • @qPCR4vir: That's not the proper way to do it. Nana is a separate, independent project - not a subdirectory of your own. – einpoklum Oct 09 '19 at 09:50
  • but compiling separately led to lot of hard to fix errors if flags/options are not compatible. What will be a proper way to do a nana compilation withing your project build? Lots of errors come from people first installing compiled nana an then consuming that without recompilation when flags changed. – qPCR4vir Oct 09 '19 at 10:22
  • @qPCR4vir: I don't have a really good answer to give you. However, a repository needs to export all of its relevant settings via a .cmake file, so that dependent repositories can then apply their own logic - e.g. whether flags are compatible. In the general case, you may have a large hierarchy of dependent libraries - you can't just make them all subfolders of your application's source tree. – einpoklum Oct 09 '19 at 10:39
  • I never put nana or other dependencies in a subdirectory of my application's tree. I find unfortunate we have `add_subdirectory` instead of `add_directory`. I will continue to investigate. – qPCR4vir Oct 09 '19 at 11:22