I'm writing a small C++ program (with a GUI) with Qt Creator and compiling with MinGW. Everything works fine when I compile the project in debug mode but as soon as I move to release mode I get compiler errors:
undefined reference to 'std::out_of_range::~out_of_range()' thread.cpp
When I click on the error I also get:
File not found: thread.cpp
I have looked through my Boost installation and found thread.cpp and it should be on the include path for my project.
Any ideas?
EDIT: Here is my .pro file:
#-------------------------------------------------
#
# Project created by QtCreator 2012-08-10T12:09:39
#
#-------------------------------------------------
QT += core gui
TARGET = GeneDropWin
TEMPLATE = app
SOURCES += main.cpp \
genedrop.cpp \
mainbody.cpp \
biofunctions.cpp \
fileio.cpp \
settings.cpp
HEADERS += genedrop.h \
geneclasses.h \
paramclass.h \
mainbody.h \
biofunctions.h \
fileio.h \
geneclasses.h \
settings.h
FORMS += genedrop.ui \
settings.ui
#Stuff I've added
INCLUDEPATH += "C:\\Program Files\\boost_1_50_0"
LIBS += -L"C:\\Program Files\\boost_1_50_0\\stage\\lib" -lboost_thread-mgw46-mt-1_50 -lboost_system-mgw46-mt-1_50 -lboost_date_time-mgw46-mt-1_50 -lboost_chrono-mgw46-mt-1_50
CONFIG += static \
release
RESOURCES += \
NIABLogo.qrc
Ok, the problem is fixed but perhaps not completely understood. I fixed it by switching compiler to MSVC and changing the syntax for the linker options (e.g. -lboost_thread-mgw46-mt-1_50 -> -llibboost_thread-vc100-mt-1_50), compiles without an issue now. I will put forward my reasoning as to what I think may have been the problem but would appreciate a better answer if wrong:
Although I thought I had built the Boost libraries with MinGW when looking through the installation I found a number of folders mentioning msvc instead (e.g. ...boost\bin.v2\libs\date_time\build_msvc-10.0) which suggested to me that I had built it with MSVC.
The linker error claimed not to be able to find files associated with thread.cpp.
Looking at the thread folder of the build directory all the .obj and .lib files had msvc-10.0 folders in their path.
Thus I think that the MinGW compiler was looking for boost objects within a non-existent MinGW folder and so was failing. The fact that it worked under debug mode I guess relates to a less-constrained search for files.
Related
My application builds and runs fine in Release mode. However, in Debug mode, my application crashes. When trying to use debugger to pinpoint the crash cause, such error is received:
Qt Creator unexpected CDB exit
The CDB process terminated
What could possibly be the problem cause?
UPDATE
I built and deployed the application in Debug mode and then tried to run the executable by command like:
C:\Users\m3\Documents\deployment_folder>.\application.exe
and I received this message:
The code execution cannot be proceed because tbb_debug.dll was not found. Reinstalling the program may fix this problem.
For some reason, tbb.dll can be found in Release mode but tbb_debug.dll cannot be found in debug mode. Although all TBB DLLs are in the same directory. Not sure why ...
UPDATE
I'm adding TBB to my project with QMake like this:
INCLUDEPATH += deps/tbb-2020.3-win/tbb/include
# Looks like absolute path works for LIBS, but NOT relative path
win32: CONFIG (release, debug|release): {
LIBS += -LC:\Users\m3\repos\myapp\deps\tbb-2020.3-win\tbb\lib\intel64\vc14 \
-ltbb \
-ltbb_preview \
-ltbbbind \
-ltbbmalloc \
-ltbbmalloc_proxy \
-ltbbproxy
} else: win32: CONFIG (debug, debug|release): {
LIBS += -LC:\Users\m3\repos\myapp\deps\tbb-2020.3-win\tbb\lib\intel64\vc14 \
-ltbb_debug \
-ltbb_preview_debug \
-ltbbbind_debug \
-ltbbmalloc_debug \
-ltbbmalloc_proxy_debug \
-ltbbproxy_debug
} else: unix: { # Linux and mac
# TODO: add correct path to LIBS +=
}
The problem is resolved by manually copying TBB DLLs next to the application executable.
Copy from ... /tbb-2020.3-win/tbb/bin/intel64/vc14/*.dll to executable location.
On why release mode worked
I think some 3rd party application has already added tbb.dll to may PATH environment variable. But tbb_debug.dll is not added to PATH by any application. Just a guess ...
Qt Creator is not parsing the include files in my project properly and gives a lot of errors in the IDE, including errors like main.cpp:14:5: error: unknown type name 'QApplication'. However, my project compiles perfectly fine. I am getting tired of all these supposed errors and am wondering if there is any way to fix this issue.
My .pro file looks like this:
QT += core gui widgets
# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
klocktimer.cpp \
main.cpp \
klockmainwindow.cpp \
chronometer.cpp
TRANSLATIONS += \
klock_en_US.ts \
klock_es_MX.ts
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
HEADERS += \
klocktimer.h \
klockmainwindow.h \
chronometer.h
I had a hunch from a few days ago (I forget exactly how I got this hunch) that stddef.h was causing the problem. So I added #include <stddef.h> to my main.cpp, and Qt Creator gave the error:
/home/loren/code/klock/main.cpp:12: error: 'stddef.h' file not found
/usr/include/c++/9/ostream:42: to match this '{'
where the '{' is the beginning { in namespace std.
Somebody on the Qt forums told me to go to the Help Menu > About Plugins > Disable the ClangCodeModel plugin. This required a restart of Qt Creator, but it fixed my problem.
I have been struggling recently to get opencv to work with qt. At this moment my issue is this: It cant find the libraries. No matter what I do it says the same thing:
:-1: error: LNK1104: cannot open file 'opencv_improc245d.lib'
I included the bin in my path variable, and added each file to libs:
INCLUDEPATH += C:\\OpenCV-2.4.5\\opencv\\build\\include
LIBS += -LC:\\OpenCV-2.4.5\\mybuild\\lib\\Debug \
-lopencv_calib3d245d \
-lopencv_contrib245d \
-lopencv_core245d \
-lopencv_features2d245d \
-lopencv_flann245d \
-lopencv_gpu245d \
-lopencv_highgui245d \
-lopencv_improc245d \
-lopencv_legacy245d \
-lopencv_ ml245d \
-lopencv_ objdetect245d \
-lopencv_ ts245d \
-lopencv_ video245d
also, my opencv library is compiled from source for msvc2010 with qt enabled, and my qt is using msvc2010 as it's compiler.
Am I adding the libraries wrong or is something wrong with my includepath?
Look in the leftmost pane of Qt Creator. There is a Projects tab. (ctrl+5) should reach you there. Go to Build Environment. Click on Details to get list of System Environment Variables. Goto INCLUDE variable in the list. Select and click Edit. Add path_to_opencv/opencv/build/include.
[ path_to_opencv is the path where your opencv directory resides.]
Clean the project, run qmake and build the project again.
I built OpenCV with CMake under Visual studio 10, copied the binaries to a /bin folder in the opencv directory. I have a simple OpenCV program with no syntax errors, but I am getting several errors such as "undefined reference to cv::imread". Why is this?
My .pro file has the following appended at the end of it:
INCLUDEPATH += C:/opencv/build/include/
LIBS += -LC:/opencv/build/x64/vc10/lib \
-lopencv_core231 \
-lopencv_highgui231 \
-lopencv_imgproc231 \
-lopencv_features2d231 \
-lopencv_calib3d231
Thanks
undefined reference instead of unresolved external symbol means you are probably using MinGW for your application, and you can't use gcc with a VC++ compiled C++ library.
I have coded a program in QTcreator on linux and when i tried to port it to windows.
Program compiles without any errors.
But when i run the program it exits automatically
Starting C:\Projects\LIG\debug\LIGenerator.exe...
C:\Projects\LIG\debug\LIGenerator.exe exited with code -1073741515
I tried to debug it using QT creator debugger. But flow of the program does not pass even through main.cpp
how to debug the program and fine where is the errors.
Update
In the .pro file the INCLUDEPATH and LIB are the following
win32:INCLUDEPATH += "C:\Program Files\Expat 2.0.1\Source\lib"
win32:INCLUDEPATH += "E:\confuse-2.7\confuse-2.7\src"
win32:INCLUDEPATH += "C:\Projects\LithologyInputGenerator5\XML"
win32:LIBS += -L"C:/Program Files/Expat 2.0.1/Bin" \
-L"C:/Program Files/GnuWin32/lib/" \
-L"E:/confuse-2.7/confuse-2.7/windows/msvs.net/libConfuse/Release"
LIBS += -lexpat \
-lcrypto \
-lssl\
-lconfuse
unix:LIBS += libgsoap++.a \
-lgsoap
win32:LIBS += -lwsock32
Update
I have used dependency walker as mentioned which help me to find the missing dependencies. I have now fixed all the dependencies except MPR.DLL ( Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.). IT was not missing so i left it out.
Also i have used a configuration file. I have now copied the conf file to debug dir for WIN32 compiler.I don't remember whether i have used more than one conf file
Still the program automatically exit with code -1073741515
. I tried to debug program using GUI debugger . But program is not even breaking at main also.
Could any one help me to get out of the this?
-1073741515 is the same as 0xC0000135 which I think often is because a a dependency is missing. I'd suggest checking that all DLLs your app depends on are in the correct locations.
You can use Dependency Walker for this.
I had the same problem, fixed by changing project settings Projects -> Tool chain -> MinGW (x86 32bit)