First of all, I use c++11 on linux with g++4.7 for all parts of my problem.
The setup of my problem: I created a shared library (lets call it "libA") that I use in different programs. Within this library is a part that was not exposed in the interface since it's not relevant for the programs. Now, however, I'd like to use this previously hidden part in another library ("libB") directly.
My plan was therefore to create a new library from the hidden part of libA. This would then be "libSub". libsub is then included into both libA and libB. Both compile without errors. But when I now try to compile a program that depends on libA, I get lots of errors saying that there are undefined references to functions from libSub.
In order to make the structure a bit clearer:
// Sub.hpp
class Sub{
private:
// private variables
public:
// interface functions
};
// A.hpp
class Sub; //forward declaring the sub-class
class A{
private:
std::shared_ptr<Sub> s;
// more private variables
public:
// some interface functions
};
// A.cpp
#include <Sub.hpp> // include the declaration of the Sub class
// definitions of the member functions of A
// program.cpp
#include A.hpp
a=A();
The libraries are placed in local folders since I wanted to avoid installing them to the general lib-folders. I guess that installing them all to the global lib-folder would solve the problem.
And the question is: Is there a way to get rid of the errors and still use local folders? And if so, how?