Static library; including (sub) H files problem
-
Apologees if this is a basic question, but I'm having beef with Qt (or C++ in general probably). I made a small static (Linux) library in Qt, where the H file I would include in other projects, roughly looks like this:
[code]
// file MyLibrary.h
#include <subDir/myStruct.h>class MyLibrary {
public:
MyStruct createStruct( int x );
};
[/code]The library compiles fine, but now I'm trying to use it in another project. In the PRO file, I added the library so it would generate a couple of lines like this:
[code]
INCLUDEPATH += $$PWD/../myLibrary
DEPENDPATH += $$PWD/../myLibrary
LIBS += -L$$PWD/../myLibrary/ReleaseX86/ -myLibrary
PRE_TARGETDEPS += $$PWD/../myLibrary/ReleaseX86/myLibrary.a
[/code]Then in my program that uses the library, I include the file:
#include <MyLibrary.h>I can create the "MyLibrary" class and use it without problems. But when I try to use the "myStruct", problems start. It seems that the other H files included within the library - #include <subDir/myStruct.h>- doesn't get included. The Compiler simply won't recognize MyStruct, even though I can actually look into it. When pressing F4 on it in my code, it nicely moves to the right H file, so the struct seems to be known while coding in Qt. But compiling fails:
"'MyStruct' does not name a type"I can fool the compiler by making a forward declaration of MyStruct within the MyLibrary.h file, so it compiles again. But as soon as I try to do something with MyStruct, it obviously complains that the type is incomplete.
I guess the include paths are wrong within my context, though it doesn't say it can't find file X, as it does when I make a typo in the "#include <subDir/TYPOmyStruct.h".