问题
I'm having a problem linking a library from opencv(2.3.1) and can't find a way to resolve it.. I'm using qtCreator with mingw and the pre-built vc10 dynamic lib files. So, here is what I have done till now:
.pro file:
TEMPLATE = app
INCLUDEPATH += "E:/opencv/build/include/"
INCLUDEPATH += "E:/opencv/build/include/opencv/"
INCLUDEPATH += "E:/opencv/build/include/opencv2/"
INCLUDEPATH += $$PWD/../opencv/build/x86/vc10
DEPENDPATH += $$PWD/../opencv/build/x86/vc10
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../opencv/build/x86/vc10/lib/ -lopencv_core231
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../opencv/build/x86/vc10/lib/ -lopencv_core231d
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../opencv/build/x86/vc10/lib/ -lopencv_highgui231
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../opencv/build/x86/vc10/lib/ -lopencv_highgui231d
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../opencv/build/x86/vc10/lib/ -lopencv_imgproc231
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../opencv/build/x86/vc10/lib/ -lopencv_imgproc231d
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../opencv/build/x86/vc10/lib/ -lopencv_calib3d231
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../opencv/build/x86/vc10/lib/ -lopencv_calib3d231d
...
I have tested an application that used highgui libs from opencv and it compiled and worked nicely, but when I try to use cvPyrDown(from imgproc_c.h) it compiles but can't load the library correctly it "exits unexpectedly" with code -1073741515.
I don't understand why that is.. as you can see from the .pro file I linked the imgproc libs just like the highgui, but it still won't work!
Any suggestions ?
Edit
Ok, the problem is that visual studio creates libraries with different naming conventions than g++ and that's why it won't work.. If this is true, I still can't explain why it works with the highgui libs.. Any ideas ?
回答1:
Which version of Opencv is this? I suggest trying latest 2.3, and using CMake instead of .pro files, which is the build system for the overall project.
Then you just file->open-project on the CMakeLists.txt, and you can just look at how examples are set up with CMake.
If this is latest, then 1) highgui uses QT so it makes sense that it might play nicer with qt creator and 2) building with .pro on windows might be untested; a unavoidable need for CMake would not be surprising.
Edit: Look at the CMakeLists.txt files for the libraries ....
# CMakeLists.txt for /modules/highgui
#YV
if (HAVE_QT)
if (HAVE_QT_OPENGL)
set(QT_USE_QTOPENGL TRUE)
endif()
INCLUDE(${QT_USE_FILE})
SET(_RCCS_FILES src/window_QT.qrc)
QT4_ADD_RESOURCES(_RCC_OUTFILES ${_RCCS_FILES})
SET(_MOC_HEADERS src/window_QT.h )
QT4_WRAP_CPP(_MOC_OUTFILES ${_MOC_HEADERS})
set(HIGHGUI_LIBRARIES ${HIGHGUI_LIBRARIES} ${QT_LIBRARIES} ${QT_QTTEST_LIBRARY})
set(highgui_srcs ${highgui_srcs} src/window_QT.cpp ${_MOC_OUTFILES} ${_RCC_OUTFILES} )
endif()
if(WIN32)
if(NOT HAVE_QT)
set(highgui_srcs ${highgui_srcs} src/window_w32.cpp)
endif()
set(highgui_srcs ${highgui_srcs} src/cap_vfw.cpp src/cap_cmu.cpp src/cap_dshow.cpp)
if(HAVE_MIL)
set(highgui_srcs ${highgui_srcs} src/cap_mil.cpp)
endif()
endif()
if(UNIX)
if(NOT HAVE_QT)
if(HAVE_GTK)
set(highgui_srcs ${highgui_srcs} src/window_gtk.cpp)
endif()
endif()
....
endif()
But "imgproc"'s CMakeLists.txt doesn't do any specific checks ... just passes the buck to main opencv lib:
define_opencv_module(imgproc opencv_core)
回答2:
Shouldn't you be using the MSVC version of Qt then?
来源:https://stackoverflow.com/questions/8556228/linking-qtcreator-opencv