-1

My program won't start, complaining that libgcc_s_sjlj-1.dll is needed. However, this file doesn't exist in Qt directory. I did some search and found that -static-libgcc and -static-libstdc++ should be added. So here is my .pro file:

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
}

If this works, neither libgcc_s_sjlj-1.dll and libstdc++-6.dll is needed. However, the program still needs libstdc++-6.dll before I put it into .exe folder.

So my question is: Where can I get libgcc_s_sjlj-1.dll or is there any problem in my .pro file?

user957121
  • 2,946
  • 4
  • 24
  • 36
  • It is really so hard to enter 'libgcc_s_dw2-1.dll' into the SO searchbar to find one of the dozen posts, which would tell you this is part of the MinGW? Here with 54 upvotes: http://stackoverflow.com/questions/4702732/the-program-cant-start-because-libgcc-s-dw2-1-dll-is-missing – Greenflow Sep 02 '13 at 17:57
  • @Greenflow I've tried that, but it doesn't work. PS: my program lacks libgcc_s_sjlj-1.dll, not libgcc_s_dw2-1.dll. – user957121 Sep 03 '13 at 06:18
  • It seems that the OpenCV libraries is causing the problem. When I remove LIBS += -lopencv_xxx244 statements and all OpenCV codes, the program can run normally in Windows. – user957121 Sep 03 '13 at 06:25
  • Same problem, same solution: libgcc_s_sjlj-1.dll is part of MinGW and should be found in the bin folder of your MinGW installation. – Greenflow Sep 03 '13 at 08:55
  • @Greenflow Oops, libgcc_s_sjlj-1.dll does not exist in bin folder of MinGW. Is that since I'm using a Qt version of 5.1? – user957121 Sep 04 '13 at 01:38

1 Answers1

1

Bah, I am stupid. Your 'my program lacks libgcc_s_sjlj-1.dll, not libgcc_s_dw2-1.dll' should have rung a bell.

You compile with the wrong MinGW. There are several different exception handler for MinGW available: sjlj, dwarf, seh. Dwarf is 32bin only. When you have the libgcc_s_dw2-1.dll it means, you have a 32bit only MinGW installed.

You must compile your programs with the same MinGW, which was used to compile your Qt. The sjlj MinGW works for 32bit and 64bit so I suppose it makes sense that the qt-project provides binary packages, which were compiled with sjlj-MinGW.

There are some MinGW packages available, which allow you to choose, which exception handling mechanism you will use. Best choice is probably to use the MinGW, which is bundled in the Qt 5.1.1 installer packages.

Greenflow
  • 3,935
  • 2
  • 17
  • 28
  • Thanks for the information. I downgraded to Qt 5.0.2 today. There is a libgcc_s_sjlj-1.dll file under MingW's bin(mingw47_32) folder and the problem is gone. I'll reinstall Qt 5.1.1 against 5.1.0(mingw48_32), which I'm using right now to see if it could solve the problem. – user957121 Sep 04 '13 at 13:45
  • I installed Qt 5.1.1 today, however, still got the same problem. On the download page there is only one link available for MinGW 32 bit windows. I install all of the packages, still libgcc_s_sjlj-1.dll is not found under C:\Qt\Qt5.1.1\5.1.1\mingw48_32\bin folder. So is it possible that MinGW has removed this dll file? – user957121 Sep 05 '13 at 12:27
  • 1
    No, it is not possible. It was never there in the first place. I think, the downloaded mingw48_32 uses the dwarf exception handling. Your downloaded Qt, too. I suppose your ovencv lib was compiled with a sjlj compiler and needs this dependency. You can try and find the libgcc_s_sjlj-1.dll on the web. Dangerous. Might be malware inside. Or you can recompile your opencv libs with your qt mingw. Or you get yourself a sjlj MinGW, but then you have to compile your Qt sources with it. – Greenflow Sep 05 '13 at 12:36
  • "I suppose your ovencv lib was compiled with a sjlj compiler and needs this dependency." OMG, that's it! The opencv lib was compiled with MinGW of Qt 5.0.2, which provides libgcc_s_sjlj-1.dll as I mentioned above. Now I know what to do now. Thanks again! – user957121 Sep 06 '13 at 02:48