Pergunta

I am finishing migrating a project from Qt 4.x to 5, but the .pro file is giving me a lot of errors:

c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot find -lHDP
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot find -l../../Qwt/qwt-5.2.0/lib/debug/qwt5
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot find -lqenc
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot find -lzlibwapi
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot find -lqextserialport
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot find -lqxmpp
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot find -ljson_lib
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot find -lSerialPort1

When I comment those lines containing the -lWhatever I get the same errors from other lines below those, at

MOC_DIR += ./GeneratedFiles/release
OBJECTS_DIR += release
UI_DIR += ./GeneratedFiles
RCC_DIR = GeneratedFiles
include(Swibz.pri)

Here is the full code:

TEMPLATE = app
TARGET = Swibz
DESTDIR = ../Release
QT += core gui network webkit webkitwidgets xml opengl serialport
CONFIG += release
DEFINES += _WINDOWS QT_LARGEFILE_SUPPORT QT_XML_LIB QT_OPENGL_LIB QT_NETWORK_LIB QT_DLL QWT_DLL
INCLUDEPATH += ../../../SprintLib \
    ./GeneratedFiles \
    ./GeneratedFiles/release \
    GeneratedFiles/release \
    . \
    ./../../Qwt/qwt-5.2.0/src \
    ../../../QENC/QENC \
    ../../../zlib-1.2.5 \
    ../../../serial/qextserialport-1.2win-alpha \
    ../../../qxmpp-0.3.0/src \
    ../../../JSON \
    ../../../QtSerialPort/qtserialport/include
LIBS += -L"../../../SprintLib/release" \
    -L"../../../QENC/release" \
    -L"../../../zlib-1.2.5/contrib/vstudio/vc9/x86/ZlibDllRelease" \
    -L"../../../serial/qextserialport-1.2win-alpha/Release" \
    -L" qxmpp-0.3.0/lib" \
    -L"../../../JSON/Release" \
    -L"../../../QtSerialPort/qtserialport/src/serialport/release" \
    -lopengl32 \
    -lglu32 \
    -lgdi32 \
    -luser32 \
    -lHDP \ #cannot find
    -l../../Qwt/qwt-5.2.0/lib/debug/qwt5 \ #cannot find
    -lqenc \ #cannot find
    -lzlibwapi \ #cannot find
    -lqextserialport \ #cannot find
    -lsetupapi \
    -lqxmpp \ #cannot find
    -ljson_lib \ #cannot find
    -lSerialPort1 #cannot find
DEPENDPATH += ./ 
MOC_DIR += ./GeneratedFiles/release #cannot find
OBJECTS_DIR += release #cannot find
UI_DIR += ./GeneratedFiles #cannot find
RCC_DIR = ./GeneratedFiles #cannot find
include(Swibz.pri) #cannot find
#win32:RC_FILE = ./Swibz.rc
TRANSLATIONS = ln_en.ts
TRANSLATIONS = ln_lv.ts
TRANSLATIONS = ln_lt.ts
TRANSLATIONS = ln_es.ts

CODECFORTR     = UTF-8

What could it be? I do have the folder GeneratedFiles and release, so I dont know whats wrong. Also, I dont quite understand the meaning of ./../../ and ./, if anyone could explain to me, maybe I can see easier the issue.

EDIT: Here go more errors I get when I coment the -lthingys, it doesnt make sense

g++: error: DEPENDPATH: No such file or directory
g++: error: MOC_DIR: No such file or directory
g++: error: +=: No such file or directory
Foi útil?

Solução

Explanations

The usage of the switches are not coherent with the manual of the GCC suite. (doc)

The linker searches a standard list of directories for the library, which is actually a file named liblibrary.a. The linker then uses this file as if it had been specified precisely by name.

The directories searched include several standard system directories plus any that you specify with -L.

There should be only names/filemanes appearing after -l switches.

Please also note that if you specify a name and not a filename (with extension), the linker will look for a lib<name>.(a|so|dll) file.

Example for qxmpp:

You specified -L" qxmpp-0.3.0/lib" which adds the qxmpp-0.3.0/lib directory (located in the current project directory) to the list of directory to parse when looking for libraries. Then -lqxmpp instructs the linker to look within the directory list for a file named libqxmpp.a.

Solving

Therefore, you must check for each not found library that : there is a -L directive pointing to the right directory where the library stands (usualy ./ will refer to the root of the project, and ../ its parent directory etc), and check that you call for the library with a correct name in a -l directive (either the full filemane, or the abbreviated name).

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top