Search code examples
c++qtqmake

Qt Creator can't find library file


I have added a lib like this in my .pro file:

unix {
    LIBS += ../lib_dir/myLib.a

    //other includes not related to this
}

And when I try to build I get "undefined reference" errors for every function used from this lib and an error:

File not found: ../lib_dir/myLib.a(myLib.o)

What could I be doing wrong?

EDIT:

Here is what I have written:

LIBS += -L../lib_dir -lmyLib 

Here is the file path:

/home/livanov/Project/lib_dir/myLib.a 

Here is the path of my project that uses the lib:

/home/livanov/Project/client_app

Solution

  • Try using the form described in qmake's variable reference:

    unix {
        LIBS += -L../lib_dir -lmyLib
    }
    

    If the path to your library contains spaces, use quotes:

    unix {
        LIBS += "-L../lib dir" -lmyLib
    }
    

    If that doesn't work, we'll need to see the actual path to your library.