QtCreator and static library trouble



  • I have two qmake projects, Util and UnitTests. Util builds a static library; UnitTests builds an executable that needs to link in Util.

    I'm new to QtCreator and I'm having trouble figuring out the right way to represent this relationship. Util builds cleanly, but every time I try to build UnitTests, it gives me undefined symbol errors. I know that means the library isn't being linked.

    I tried defining a project dependency of UnitTests on Util. However, that doesn't seem to have solved the problem (perhaps this only affects build order?). In Visual Studio, I know that would have been sufficient, but maybe not in QtCreator. After I added the dependency, the "Build" option changed to "Build without dependencies". I couldn't find a way to build with dependencies, which is what I want.

    I tried selecting "Add Library --> Add Internal Library" to the UnitTests project, but the dropdown list was empty (Util was not in it), and I wasn't sure how to proceed from there.

    I can of course just write the link requirement into the UnitTests.pro file, but that doesn't feel "clean" to me. There has to be a better way to do it.



  • I am having exactly the same problem. Does the static library project have to be marked in some way to get it to show up in the "Internal" library dropdown?



  • I found my answer "here":http://stackoverflow.com/questions/16761508/qt-creator-projects-that-use-other-projects-as-libraries.

    I needed to create a parent project that contains references to the child projects. At that point the child projects could find each other for library references. Mine looks like this:

    @TEMPLATE = subdirs
    CONFIG += ordered
    SUBDIRS = codemodel simpleedit@



  • is the

    SUBDIRS =

    is that the directory of your project and then the lib?



  • I used the approach suggested "here":http://stackoverflow.com/questions/1417776/how-to-use-qmakes-subdirs-template

    Worked for me.



  • SUBDIRS contains the names of the two child projects. It's just the name of the directory each of those projects is contained in.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.