Linking libraries
I have some project with file:
src/Test.cpp
.
Now I make subproject for it with another file 开发者_JAVA百科src/TestWrapper.cpp
which includes src/Test.hpp
(related to Test.cpp).
Sure, to build successful shared library with wrapper I have to link Test.cpp too.
Everything works. I have project with Test.cpp linked and subproject (shared library) which linkes Test.cpp too.
The problem: that shared library would be linked to the main project. Will I have any errors due to this?
You should not put Test.cpp in your shared library. You can link your shared library without Test.cpp
, it will just have some undefined symbols, which is perfectly normal for a shared library.
What you did will probably work but is dangerous and will make your software unmaintainable.
精彩评论