views:

16731

answers:

7

How can I add external library into a project built by Qt Creator RC1 (version 0.9.2)? For example, the win32 function EnumProcesses() requires Psapi.lib to be added in the project to build.

Thanks in advance.

+8  A: 

Are you using qmake projects? If so, you can add an external library using the LIBS variable. E.g:

win32:LIBS += path/to/Psapi.lib
dirkgently
A: 

Hi!! sorry but it doesn´t work, i´m doing this:

LIBS += C:\Program Files\OpenCV\lib

or this:

LIBS += C:\Program Files\OpenCV\cv.lib

but is the same, the error is that the library is not found.

the problem is at the time when a write #include says: No such file or directory

so, Is there someone that can help me???

A: 

Hi, The error you mean is due to missing additional include path. Try adding it with: INCLUDEPATH += C:\path\to\include\files\ Hope it works. Regards.

+9  A: 

The proper way to do this is like this:

LIBS += -L/path/to -lpsapi

This way it will work on all platforms supported by Qt. The idea is that you have to separate the directory from the library name (without the extension and without any 'lib' prefix). Of course, if you are including a Windows specific lib, this really doesn't matter.

This is the correct answer for this post.
ShaChris23
+1 because it consider cross platform solution, the most complete answer.
+1  A: 

LIBS += C:\Program Files\OpenCV\lib

won't work because you're using white-spaces in Program Files. In this case you have to add quotes, so the result will look like this: LIBS += "C:\Program Files\OpenCV\lib". I recommend placing libraries in non white-space locations ;-)

martin
A: 

hi, i am writing a c++ library and i want to use it for a qt project under linux, windows, mac os X and maemo platform.

can anyone submit a sample project for a library and a project? thanks in advance, lukas

bibo
A: 

What if I'd like to add a .dll library to my project? It doesn't recognize the format.

shuawinn