PDA

View Full Version : MinGW can't find my libraries



cape
18th September 2011, 13:34
Hi,

I'm trying to compile qxmpp libraries with qtcreator 2.3.0. I believe the problem occurs at the linking stage, here is the relative output:


g++ -Wl,-s -Wl,-subsystem,console -o release\tests.exe release/tests.o release/moc_tests.o release/qrc_tests.o -L"c:\qt-everywhere-opensource-src-4.7.4\lib" -LE:/qxmpp-0.3.0/lib -lqxmpp -lQtTest -lQtXml -lQtGui -lQtNetwork -lQtCore gdi32.lib comdlg32.lib oleaut32.lib imm32.lib winmm.lib winspool.lib msimg32.lib c:\qt-everywhere-opensource-src-4.7.4\lib\QtCore.lib kernel32.lib user32.lib shell32.lib uuid.lib ole32.lib advapi32.lib ws2_32.lib /LIBPATH:C:\OpenSSL-Win32\lib
mingw32-make[2]: Leaving directory `E:/qxmpp-build-desktop-Qt_4_7_4__qt-everywhere-opensource-src-4_7_4__Release/tests'
mingw32-make[1]: Leaving directory `E:/qxmpp-build-desktop-Qt_4_7_4__qt-everywhere-opensource-src-4_7_4__Release/tests'
g++: gdi32.lib: No such file or directory
g++: comdlg32.lib: No such file or directory
g++: oleaut32.lib: No such file or directory
g++: imm32.lib: No such file or directory
g++: winmm.lib: No such file or directory
g++: winspool.lib: No such file or directory
g++: msimg32.lib: No such file or directory
g++: kernel32.lib: No such file or directory
g++: user32.lib: No such file or directory
g++: shell32.lib: No such file or directory
g++: uuid.lib: No such file or directory
g++: ole32.lib: No such file or directory
g++: advapi32.lib: No such file or directory
g++: ws2_32.lib: No such file or directory
g++: /LIBPATH:C:\OpenSSL-Win32\lib: No such file or directory
mingw32-make[2]: *** [release\tests.exe] Error 1
mingw32-make[1]: *** [release] Error 2
mingw32-make: *** [sub-tests-make_default-ordered] Error 2
The process "C:\Qt\qtcreator-2.3.0\mingw\bin\mingw32-make.exe" exited with code 2.
Error while building project qxmpp (target: Desktop)
When executing build step 'Make'

I copied the Microsoft SDK lib files to the qt's lib directory but it still can't find them. It also can't find the openssl libraries even though the path seen after LIBPATH is correct.

Any suggestions?

Thanks...

llev
18th September 2011, 13:54
How do you add gdi32 in .pro file?

cape
18th September 2011, 17:55
How do you add gdi32 in .pro file?

Thanks for answering, I tried these:

LIBS += "C:/Program Files/Microsoft SDKs/Windows/v7.0A/Lib"
LIBS += -L"C:/Program Files/Microsoft SDKs/Windows/v7.0A/Lib" -gdi32
LIBS += "C:\\Program Files\\Microsoft SDKs\\Windows\\v7.0A\\Lib"

None of them worked. Do I have to explicitly add them in the pro file? Shouldn't QtCreator find them itself?

llev
18th September 2011, 18:02
Try to replace it with the lines like this:


LIBS += -lgdi32 -lcomdlg32
etc.

Then rebuild the project and check how linker errors changed.

cape
18th September 2011, 20:29
Didn't work. Tried


LIBS += -lgdi32 ...

and


LIBS += +Lc:\\lib #ms sdk lib files are here
LIBS += -lgdi32 ....

It still can't find them.

llev
18th September 2011, 20:48
Please pay attention on how qt was built.
qt built using MinGW tools uses its own versions of standard libraries. They usually locate at lib sub-folder of MinGW root folder.
Also MinGW tools treat "-lgdi32" record as request to link libgdi32.a file, by other words they follow linux-style naming convention.
And, of course, qt built with MinGW should be used with MinGW build tools.

As I understand you're using MinGW build tools.
Correct?
I guess qt you're using was built with MinGW too?
If so, try to add the path to MinGW\lib folder via the line similar to the following:


QMAKE_LIBDIR += C:/MinGW/lib

And get back to LIBS += -lgdi32 ..

cape
18th September 2011, 21:03
Actually I didn't have a lib folder under C:\mingw, but anyway I tried compiling the project with msvc2010 (again with qtcreator) and it compiled fine! Is there any particular reason as to why I should use mingw? Because msvc seems to be giving me less problems. I'll consider what you said when I try with mingw next.

llev
18th September 2011, 21:10
I prefer to use MSVC libs and see a few reasons to use MinGW on Windows' builds.
I told you about MinGW just because the logs in your original post show that fact you used MinGW tools to compile app.


g++ -Wl,-s -Wl,-subsystem,console -o release\tests.exe release/tests.o release/moc_tests.o release/qrc_tests.o -L"c:\qt-everywhere-opensource-src-4.7.4\lib" -LE:/qxmpp-0.3.0/lib -lqxmpp -lQtTest -lQtXml -lQtGui -lQtNetwork -lQtCore gdi32.lib comdlg32.lib oleaut32.lib imm32.lib winmm.lib winspool.lib msimg32.lib c:\qt-everywhere-opensource-src-4.7.4\lib\QtCore.lib kernel32.lib user32.lib shell32.lib uuid.lib ole32.lib advapi32.lib ws2_32.lib /LIBPATH:C:\OpenSSL-Win32\lib
mingw32-make[2]: Leaving directory `E:/qxmpp-build-desktop-Qt_4_7_4__qt-everywhere-opensource-src-4_7_4__Release/tests'
mingw32-make[1]: Leaving directory `E:/qxmpp-build-desktop-Qt_4_7_4__qt-everywhere-opensource-src-4_7_4__Release/tests'
g++: gdi32.lib: No such file or directory

cape
18th September 2011, 21:17
Yes I was, switched to msvc later as I said. Thanks for helping.