M'kay so I'm new to Qt and I'm trying to include the boost/filesystem lib to my project. However, when I try to build it, I always get this error:
LNK1104: File "libboost_filesystem-vc140-mt-1_61.lib" cannot be
opened.
Now, I know that this library needs to be build beforehand, so, as described on the Boost-Website I made:
bootstrap
.\b2
and it built just fine. I also used the Qt dialog to add the libary to my project, my .pro-file looks like this:
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = ProjectName
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp \
someclass.cpp \
someclass2.cpp
HEADERS += mainwindow.h \
someclass.h \
someclass2.h
FORMS += mainwindow.ui
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/libarys -llibboost_filesystem-vc140-mt-1_61
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/libarys -llibboost_filesystem-vc140-mt-1_61
else:unix: LIBS += -L$$PWD/libarys -llibboost_filesystem-vc140-mt-1_61
INCLUDEPATH += $$PWD/boost
DEPENDPATH += $$PWD/boost
Apparently, I did something wrong, but I can't figure out, WHAT exactly it is. The internet knows the problem, but it seems there's no "easy" solution to it.
Turned out, my project didn't like the lib-version.
I rebuilt my lib files:
>b2 --build-dir="destination/directory" toolset=msvc --build-type=complete link=static threading=multi --with-filesystem stage
Then, I used the library in
release/link-static/runtime-link-static/threading-multi/
Which is:
libboost_filesystem-vc140-mt-s-1_61
And re-ran qmake for the .pro-file. Then built and executed the application and the error is gone.
Related
I have problems creating a project using QT with CGAL and Boost on Windows 10.
In this project there are a few .pro Files and all projects without CGAL have compiled. Boost also works without problems. If I compile the CGAL Project i get linking errors:
Link Errors
Here is my .pro file
win32:INCLUDEPATH += C:/CGAL32/include/
win32:INCLUDEPATH += C:/CGAL32/build/include/
win32:INCLUDEPATH += C:/boost_lib_inc/include/
win32:INCLUDEPATH += C:/boost/boost_1_68_0/
win32:CONFIG(release, debug|release): LIBS += -LC:/CGAL32/auxiliary/gmp/lib -lgmp-10 -lmpfr-4 -LC:/CGAL32/build/lib/Release -lCGAL-vc140-mt-4.12.1 -lCGAL_Core-vc140-mt-4.12.1
else:win32:CONFIG(debug, debug|release): LIBS += -LC:/CGAL32/auxiliary/gmp/lib -lgmp-10 -lmpfr-4 -LC:/CGAL32/build/lib/Debug -lCGAL-vc140-mt-gd-4.12.1 -lCGAL_Core-vc140-mt-gd-4.12.1
else:unix:!macx: LIBS += -L$$PWD/../../../../../../usr/lib/x86_64-linux-gnu/ -lCGAL
On Linux all works fine.
I have created a project in qt creator with multiple subdirs and am deploying/running it on a beaglebone. Compiles fine, deploys fine, etc.
My issue is that when I try to debug, the only files I can set breakpoints in or step into are those in the same subdir where main.cpp is. Just to test, I duplicated the project with a flat folder structure and can set breakpoints and step into everything.
When the debugger starts up, the debug log tries to set the breakpoints and fails seemingly because it can't find the .cpp files:
"No source file named projectdir/dir1/myclass.cpp.\n"
8045^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="",pending="\"projectdir/dir1/myclass.cpp\":7",times="0",original-location="\"fullpathofprojectdir/dir1/myclass.cpp\":7"}
Whereas it says this for breakpoints in main:
8046^done,bkpt={number="2",type="breakpoint",disp="keep",enabled="y",addr="0x0001831c",func="main(int, char**)",file="projectdir/dir2/main.cpp",fullname="fullpathofprojectdir/dir2/main.cpp",line="27",thread-groups=["i1"],times="0",original-location="fullpathofprojectdir/dir2/main.cpp:27"}
Additionally, myclass.cpp doesn't show up in the source files panes either. How can I resolve this?
Here is the setup of my *.pro files:
Top level project file:
TEMPLATE = subdirs
SUBDIRS += \
dir1 \
dir2
unix {
target.path = /home/debian
INSTALLS += target
}
Project file of library (dir1, myclass.cpp, etc):
QT -= gui
TARGET = Common
TEMPLATE = lib
DEFINES += COMMON_LIBRARY
SOURCES += \
myclass.cpp
HEADERS += \
common_global.h \
myclass.h
unix {
target.path = /home/debian/lib
INSTALLS += target
}
CONFIG += debug
Project file containing main:
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = Test
TEMPLATE = app
SOURCES += \
main.cpp
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../Common/release/
-lCommon
else:win32:CONFIG(debug, debug|release): LIBS += -
L$$OUT_PWD/../Common/debug/ -lCommon
else:unix: LIBS += -L$$OUT_PWD/../Common/ -lCommon
INCLUDEPATH += $$PWD/../Common
DEPENDPATH += $$PWD/../Common
target.path = /home/debian
INSTALLS += target
Let me know if there's any other relevant data I forgot to provide. Qt Creator version is 4.5.0 and I'm running it on a 64 bit VM of ubuntu 16.04 if that's relevant.
I installed libfreenect. I opened QT and began to coding. When I use libfreenect.h no error occurres. But when I use libfreenect.hpp, this error occurred:"error: libusb.h: No such file or directory"
contents of .pro file is:
QT += core
QT -= gui
CONFIG += c++11
TARGET = 12moharram
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../usr/local/lib/release/ -lfreenect
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../usr/local/lib/debug/ -lfreenect
else:unix: LIBS += -L$$PWD/../../../usr/local/lib/ -lfreenect
INCLUDEPATH += $$PWD/../../../usr/local/include
DEPENDPATH += $$PWD/../../../usr/local/include
Where is the problem?
Probably libfreenect.h and libfreenect.hpp are themselves including other files, for a reason that I cannot understand libfreenect.hpp is including libusb.h and libfreenect.h is not. Probably libusb.h is not in your INCLUDEPATH.
I would first try to find libusb.h, if it is not present install it (you will probably have to install libusb-dev (debian style). Once you are sure libsub.h is present make sure is in the INCLUDEPATH, in case change the INCLUDEPATH in your .pro file.
This should fix this specific problem but after you fix this there can be more, good luck.
I'm using QT(5)-Creator with 2 projects, that compile both with MinGW my C++ programs under Windows 7. One project generates a static library, and the other is just there to verify that the library is alright.
The error:
When building the library no errors are generated and it creates successfully the static lib MyClassName.a.
In turn, when trying to import the library, I get error messages durring building/compilation:
undefined reference to 'MyClassName::MyClassName()'
undefined reference to 'MyClassName::MyClassFunction()'
The files:
here's the main.cpp of my importer project
#include <QCoreApplication>
#include "MyClassName.h"
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
MyClassName *mainThread = new MyClassName();
mainThread->MyClassFunction();
return a.exec();
}
and it's .pro file
QT += core
QT += widgets
QT -= gui
TARGET = TESTerase
CONFIG += console
CONFIG -= app_bundle
CONFIG +=extserialport
CONFIG +=staticlib
TEMPLATE = app
HEADERS += \
MyClassName.h
SOURCES += main.cpp
unix:!macx: LIBS += -L$$PWD/../MyClassName-Release/ -lMyClassName
INCLUDEPATH += $$PWD
INCLUDEPATH += $$PWD/../MyClassName-Release/release
DEPENDPATH += $$PWD/../MyClassName-Release/release
unix:!macx: PRE_TARGETDEPS += $$PWD/../MyClassName-Release/release/MyClassName.a
btw I've used QT-Creator's include external library function
My guesses:
Since I'm able to [Strg+Click] the functions in the main, I assume the error is thrown by the Linker.
It may also be a manner of importing/creating/using libraries too, since I just started with that topic.
Anyways searching the Internet about it usually just results in the hint, to use the same compiler for both projects - which shouldn't matter in my case (since I'm building both projects with the same Creator and the same settings).
Has anybody an idea?
Thanks for your support
Kind Regards
[Update for Bogdans request]
the new .pro file
#-------------------------------------------------
#
# Project created by QtCreator 2015-04-29T19:46:22
#
#-------------------------------------------------
QT += core
QT += widgets
QT -= gui
TARGET = TESTerase
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG +=extserialport
HEADERS += \
MyClassName.h
SOURCES += main.cpp
unix:!macx: LIBS += -L$$PWD/../MyClassName-Release/ -lMyClassName
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../MyClassName-Release/release/ -lMyClassName
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../MyClassName-Release/debug/ -lMyClassName
else:unix:!macx: LIBS += -L$$PWD/../MyClassName-Release/ -lMyClassName
INCLUDEPATH += $$PWD/../MyClassName-Release/release
DEPENDPATH += $$PWD/../MyClassName-Release/release
win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../MyClassName-Release/release/MyClassName.a
else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../MyClassName-Release/debug/MyClassName.a
else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../MyClassName-Release/release/MyClassName.lib
else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../MyClassName-Release/debug/MyClassName.lib
else:unix:!macx: PRE_TARGETDEPS += $$PWD/../MyClassName-Release/MyClassName.a
Your .pro file defines library dependencies only for unix platform unix:!macx:. I suppose there should be also win32 for Windows.
Had the same problem just now. Build was working fine on macOS/OSX but not on Windows with the same codebase.
It was caused by the fact I was not exporting my symbols, which is necessary on Windows.
Use Q_DECL_EXPORT on functions when building the lib.
And use Q_DECL_IMPORT when using the functions from the lib.
Example how to do this here: https://wiki.qt.io/How_to_create_a_library_with_Qt_and_use_it_in_an_application#Creating_a_shared_library
Solved the problem in my case, hope it helps!
I am trying to include the assimp library (http://assimp.sourceforge.net/main_doc.html) for importing assets into my QT project.
I managed to include it in VS2012 but not in QT.
The import wizard gives me this code:
unix|win32: LIBS += -L$$PWD/assimp--3.0.1270-sdk/lib/assimp_debug-dll_win32/ -lassimp
INCLUDEPATH += $$PWD/assimp--3.0.1270-sdk/include
DEPENDPATH += $$PWD/assimp--3.0.1270-sdk/include
win32: PRE_TARGETDEPS += $$PWD/assimp--3.0.1270-sdk/lib/assimp_debug-dll_win32/assimp.lib
else:unix: PRE_TARGETDEPS += $$PWD/assimp--3.0.1270-sdk/lib/assimp_debug-dll_win32/libassimp.a
When i build the code it throws this error
undefined reference to `Assimp::Importer::Importer()'
If i understand it right:
QT / VS2012
INCLUDEPATH =Include directories
LIBS = Library directories
PRE_TARGETDEPS=Additional dependancies
Do i have to manualy add the location off the .dll file into .pro or what am i missing?