我的程序无法启动,抱怨需要libgcc_s_sjlj-1.dll。但是,Qt目录中不存在此文件。我做了一些搜索,发现应该添加-static-libgcc和-static-libstdc++。这是我的.pro文件:
QT += core gui xml
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = mouseEventProcess
TEMPLATE = app
SOURCES += main.cpp
mainwindow.cpp
fileOp.cpp
xmlpraser.cpp
pixmapOp.cpp
mathOp.cpp
HEADERS += mainwindow.h
fileOp.h
xmlpraser.h
pixmapOp.h
mathOp.h
FORMS += mainwindow.ui
#COMPILE LIBGCC_S_SJLJ-1.DLL AND LIBSTDC++-6.DLL INTO THE EXE FILE
win32{
QMAKE_LFLAGS += -static-libgcc
QMAKE_LFLAGS += -static-libstdc++
#BOOST LIBRARIES. CHANGE TO YOUR OWN.
INCLUDEPATH += D:/boost_1_51_0
#OPENCV LIBRARIES. CHANGE TO YOUR OWN.
INCLUDEPATH += D:/opencv2.4.4/include
INCLUDEPATH += D:/opencv2.4.4/release/install/include
LIBS += -LD:/opencv2.4.4/release/install/lib
-lopencv_core244
-lopencv_highgui244
-lopencv_imgproc244
#-lopencv_features2d244
#-lopencv_calib3d244
}
unix{
#BOOST LIBRARIES. CHANGE TO YOUR OWN.
INCLUDEPATH += /home/panda/boost_1_51_0
#OPENCV LIBRARIES.IF YOU COMPILED AND INSALLED
#OPENCV FROM CMAKE & MINGW, JUST LEAVE IT BE,
#UNLESS YOU KNOW EXACTLY WHAT YOU ARE DOING.
INCLUDEPATH += /usr/local/include/opencv
INCLUDEPATH += /usr/local/include/opencv2
LIBS += -lopencv_core -lopencv_imgproc -lopencv_highgui
LIBS += -lopencv_ml -lopencv_video -lopencv_features2d
LIBS += -lopencv_calib3d -lopencv_objdetect -lopencv_contrib
LIBS += -lopencv_legacy -lopencv_flann
}
如果这样做有效,则不需要libgcc_s_sjlj-1.dll和libstdc++-6.dll。然而,在我将该程序放入.exe文件夹之前,它仍然需要libstdc++-6.dll。
所以我的问题是:在哪里可以获得libgcc_s_sjlj-1.dll,或者我的.pro文件中有问题吗?
啊,我真傻。你的"我的程序缺少libgcc_s_sjlj-1.dll,而不是libgcc_s_dw2-1.dll"应该敲响了警钟。
您使用错误的MinGW进行编译。MinGW有几种不同的异常处理程序:sjlj、dwarf、seh。小矮人只有32bin。当您安装了libgcc_s_dw2-1.dll时,这意味着您安装了仅32位的MinGW。
您必须使用用于编译Qt的相同MinGW来编译程序。sjlj-MinGW适用于32位和64位,所以我认为qt项目提供二进制包是有道理的,这些包是用sjlj-MinGW编译的。
有一些可用的MinGW包,您可以选择使用哪种异常处理机制。最好的选择可能是使用MinGW,它捆绑在Qt 5.1.1安装程序包中。