Question

ISSUE SOLVED (scroll down)

Im on windows 7 and compilling with MinGW.

I made a new Qt application in QtCreator 3.01 (Qt 5.2.1). I compile it, the empty application window pops up everything is awesome. But as soon as i use any other library (like boost or gtest) im starting getting these errors when compiling

cannot find -lqtmain
cannot find -lQt5Widgets
cannot find -lQt5Gui
cannot find -lQt5Core

ld returned 1 exit status

This is my .pro file

#-------------------------------------------------
#
# Project created by QtCreator 2014-04-19T14:17:24
#
#-------------------------------------------------

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = Thermovision
TEMPLATE = app

include(Model/Model.pri)
include(Controller/Controller.pri)
include(View/View.pri)
include(Interface/Interface.pri)


SOURCES += \
    main.cpp

HEADERS  += \
    logdebug.h

FORMS    +=

OTHER_FILES += \
    Model/Model.pri \
    View/View.pri \
    Controller/Controller.pri \
    Interface/Interface.pri \
    Globals/zGlobals.pri

INCLUDEPATH += $$PWD/
DEPENDPATH += $$PWD/

INCLUDEPATH += $$PWD/../../../../../../../MinGW/msys/1.0/local/include
DEPENDPATH += $$PWD/../../../../../../../MinGW/msys/1.0/local/include

win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../../Downloads/boost_1_54_0/boost_1_54_0/stage/lib/ -lboost_thread-mgw48-mt-1_54
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../../Downloads/boost_1_54_0/boost_1_54_0/stage/lib/ -lboost_thread-mgw48-mt-1_54d

this is the main.cpp

#include <iostream>
#include <QApplication>
#include "View/form.h"
#include <boost/thread.hpp>
using namespace std;


int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    Form w;
    w.show();

    boost::thread b;

    return a.exec();
}

when i comment usage of boost thread, the include and the part in .pro file responsible for finding boost thread library everything compiles again. Same when im trying to use gtest.

The odd thing is that I havent found any information regarding this issue anywhere on the internet :<

Can someone help me?

================================================================================= [SOLVED] ok so it seems qt wanted me to explicitly add the libraries into project. I used the built-in tool which generated the following output

win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../../../../../../../Qt/Qt5.2.1/5.2.1/mingw48_32/lib/libQt5Core.a
else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../../../../../../../Qt/Qt5.2.1/5.2.1/mingw48_32/lib/libQt5Cored.a
else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../../../../../../../Qt/Qt5.2.1/5.2.1/mingw48_32/lib/Qt5Core.lib
else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../../../../../../../Qt/Qt5.2.1/5.2.1/mingw48_32/lib/Qt5Cored.lib

but im sure one can thin it down (im gonna stay with this)

Was it helpful?

Solution

Based on our comments and outcome, it seems that a quick solution is to add the libraries explicitly that you wish to use. It will generate something like this in the background, so basically using static libraries as opposed to dynamic:

win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../../../../../../../Qt/Qt5.2.1/5.2.1/mingw48_32/lib/libQt5Core.a
else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../../../../../../../Qt/Qt5.2.1/5.2.1/mingw48_32/lib/libQt5Cored.a
else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../../../../../../../Qt/Qt5.2.1/5.2.1/mingw48_32/lib/Qt5Core.lib
else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../../../../../../../Qt/Qt5.2.1/5.2.1/mingw48_32/lib/Qt5Cored.lib

Alternatively, which I would personally suggest more is to add the following line for now in your project file to get this working with dynamic libraries rather than static to make your application binary go up to the hill:

LIBS += -L$$PWD/../../../../../../../Qt/Qt5.2.1/5.2.1/mingw48_32/lib/
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top