6

I have a Qt project using SQLite, so I have the following directory structure:

C:\Workspace\MyProject\MyProject.pro
C:\Workspace\MyProject\sqlite3\sqlite3.lib

Adding sqlite3.lib with absolute paths works fine:

LIBS += -L"c:/Workspace/MyProject/sqlite3" -lsqlite3

But I can't make it work with relative paths. I try with:

LIBS += -L"sqlite3" -lsqlite3

But that fails with:

:-1: error: LNK1104: cannot open file 'sqlite3\sqlite3.lib'

I tried but LIBS += -L"../sqlite3" or even LIBS += -L"../../sqlite3", but that didn't work either.

I'm using MSVC 2008 for the compiler toolchain.

3
  • Since it's possible to build from different directory, relative path pointing to project directory should be $$PWD/... (PWD is absolute path to directory with currently processed .pro file). But that doesn't explain why the custom relative library path is not searched.
    – hluk
    Feb 2, 2014 at 7:29
  • Well, that looks like a legitimate answer, can you post it as such?
    – sashoalm
    Feb 3, 2014 at 9:06
  • Done, though I really wonder how relative paths are handled by compiler/linker.
    – hluk
    Feb 3, 2014 at 9:49

1 Answer 1

14

Since it's possible to build from different directory than project directory, relative path pointing to project directory should be prefixed with $$PWD/ (PWD qmake variable contains absolute path to directory with currently processed *.pro file).

Your line would look like:

LIBS += -L"$$PWD/sqlite3" -lsqlite3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.