Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Static library; including (sub) H files problem
QtWS25 Last Chance

Static library; including (sub) H files problem

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 745 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rick16bit
    wrote on last edited by
    #1

    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".

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved