Registered Member
|
Hello,
I'm not an expert developer, and I use C++ for mathematics (combinatorics) research to test out possibilities. I've created a (shared) library containing many useful functions that I use in many of my little projects, but right now I'm copy-pasting the whole directory into all my projects. Of course, I often edit something or add something to the library, so this is obviously not a good way. What I want is for each project to be in its own directory, but "linked" somehow to the shared-library-project, so that when I compile any of my projects, the shared-library-project compiles too, copies the libwhatever.a into somewhere everything can access it, and links it. In Cmake I tried doing this just by saying "add_subdirectory(../mylib)" but it doesn't work, it says the root directory has to be, well, at the root. But I don't want to have the library inside any specific project directory, because then all the others won't work. Any ideas? Thank you. |
Registered Member
|
Why don't you create a static library and install it in your library path (for instance /usr/lib)? Then it is sufficient to link your projects against that library (being in the default path should be found without problems).
|
Global Moderator
|
Hello,
you can also just use target_link_libraries() in cmake with a path to a shared library file. That'll link against that file. That would even work without installing the library system-wide. Greetings, Sven
I'm working on the KDevelop IDE.
|
Registered Member
|
Well, the system wide doesn't work because I would need to constantly install (since it's being changed all the time). The other one... well, I guess that would work on my system, but what about if I re-distribute stuff? They'll need the same paths. Unless I can do this with a relative path... I'll try.
Thanks, Xorlium |
Global Moderator
|
Well, in that case you would of course install it into a system-wide path. If you want to get more advanced, you can also ship with a Find<Foo>.cmake file which will figure out the path.
Greetings
I'm working on the KDevelop IDE.
|
Registered users: bancha, Bing [Bot], Evergrowing, Google [Bot], lockheed, mesutakcan, Sogou [Bot]