Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QMake: Referencing a library using relative paths

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.

like image 912
sashoalm Avatar asked Jan 31 '14 14:01

sashoalm


1 Answers

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
like image 168
hluk Avatar answered Sep 25 '22 22:09

hluk