views:

758

answers:

3

This seems like it should be really simple. I compiled a library in Qt (this newmat library), and produced the file libnewmat.a. Now I need to integrate this library into another project but I just can't get it to work.

I've tried a few different things with the LIBS variable in my .pro file including:

Win32:LIBS += libnewmat.a #library is in same directory as the project

Win32:LIBS += "C:/...path.../libnewmat.a"

Win32:LIBS += L"C:/...path..." -lnewmat

I've even tried using forward and back slashes in the path but it made no difference. I also include this check to make sure the library is actually found:

!exists(libnewmat.a) {
    error("libnewmat.a does not exist")
}

So I know that isn't the problem. What I don't understand is that when i ctrl+f the compiler output (which displays the commands that qmake is using at the command line), I don't find any reference to the library. For some reason my LIBS variable isn't making any difference on the command line which is where I would expect it to be. Here is a sample of the compiler output where I would expect the library to be referenced if anyone would like to double check:

g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"..\..\..\..\Qt\2009.02\qt\include\QtCore" -I"..\..\..\..\Qt\2009.02\qt\include\QtGui" -I"..\..\..\..\Qt\2009.02\qt\include\QtOpenGL" -I"..\..\..\..\Qt\2009.02\qt\include" -I"..\Visual Studio Projects\NewMatProj\newmat10" -I"..\..\..\..\Qt\2009.02\qt\include\ActiveQt" -I"debug" -I"." -I"..\..\..\..\Qt\2009.02\qt\mkspecs\win32-g++" -o debug\moc_Window.o debug\moc_Window.cpp
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -mthreads -Wl -Wl,-subsystem,windows -o debug\GLPractice.exe debug/main.o debug/GLWidget.o debug/Window.o debug/CGSWidget.o debug/moc_GLWidget.o debug/moc_Window.o -L"c:\Qt\2009.02\qt\lib" -lopengl32 -lglu32 -lgdi32 -luser32 -lmingw32 -lqtmaind -lQtOpenGLd4 -lQtGuid4 -lQtCored4

I suspect there is something really simple that I'm missing here.

I'm using QtCreator on Windows Vista.

+4  A: 

I think the scope conditions are case sensitive:

win32:LIBS += libnewmat.a  # lowercase w
richardwb
A: 

Hi,

I've the very same problem. Isn't it possible to link to a static library from a static library? Anyhow if you make a shared library by removing CONFIG+=static from .pro file you avoid this problem.

Cheers, H

A: 

u dont need a lot of libs in pro file. try this, it worked for me.

Win32:INCLUDEPATH += .

Win32:LIBS += "C:/...path.../libnewmat.a"

or

Win32:DEPENDPATH += .

Win32:LIBS += "C:/...path.../libnewmat.a"

Also libnewmat.a might be linux library.. normally windows libs have .lib extension.. not sure though..

-Arps

arpit