문제

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.

도움이 되었습니까?

해결책

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
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top