Ask Your Question

Building/Compiling OpenCV 3.2 with Qt on Visual Studio 2015 [closed]

asked 2017-02-14 03:28:25 -0600

DavB gravatar image

updated 2017-02-16 06:44:07 -0600

I'm trying to use Qt functionality (such as named window with CV_GUI_EXPANDED), developing on Visual Studio 2015 on Windows 10.

I'm using the pre-built Windows libraries downloaded from the Sourceforge (opencv-3.2.0-vc14.exe)

It seems to me that Qt is not included in that file, and that I need to rebuild the OpenCV libraries from source with Qt, but I am unable to find any documentation of how to do that on Visual Studio 2015

Many thanks!

Built as dynamic libs?:      YES
C++ Compiler:                C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe  (ver 19.0.24213.1)
C++ flags (Release):         /DWIN32 /D_WINDOWS /W4 /GR /EHa  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi  /wd4251 /wd4324 /wd4275 /wd4589 /MP8  /MD /O2 /Ob2 /DNDEBUG  /Zi
C++ flags (Debug):           /DWIN32 /D_WINDOWS /W4 /GR /EHa  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi  /wd4251 /wd4324 /wd4275 /wd4589 /MP8  /D_DEBUG /MDd /Zi /Ob0 /Od /RTC1 
C Compiler:                  C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe
C flags (Release):           /DWIN32 /D_WINDOWS /W3  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi    /MP8  /MD /O2 /Ob2 /DNDEBUG  /Zi
C flags (Debug):             /DWIN32 /D_WINDOWS /W3  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi    /MP8  /D_DEBUG /MDd /Zi /Ob0 /Od /RTC1 
Linker flags (Release):      /machine:x64  /INCREMENTAL:NO  /debug
Linker flags (Debug):        /machine:x64  /debug /INCREMENTAL 
ccache:                      NO
Precompiled headers:         NO
Extra dependencies:          vfw32 comctl32 gdi32 ole32 setupapi ws2_32 Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Test Qt5::Concurrent
3rdparty dependencies:       zlib libjpeg libwebp libpng libtiff libjasper IlmImf

OpenCV modules: To be built: core flann imgproc ml photo video imgcodecs shape videoio highgui objdetect superres features2d calib3d stitching videostab world ts Disabled: - Disabled by dependency: - Unavailable: cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev java python2 viz

Windows RT support: NO

GUI: QT 5.x: YES (ver 5.6.1) QT OpenGL support: NO OpenGL support: NO VTK support: NO

Media I/O: ZLib: build (ver 1.2.8) JPEG: build (ver 90) WEBP: build (ver 0.3.1) PNG: build (ver 1.6.24) TIFF: build (ver 42 - 4.0.2) JPEG 2000: build (ver 1.900.1) OpenEXR: build (ver 1.7.1) GDAL: NO GDCM: NO

Video I/O: Video for Windows: YES DC1394 1.x: NO DC1394 2.x: NO FFMPEG: YES (prebuilt binaries) avcodec: YES (ver 57.64.101) avformat: YES (ver 57.56.100) avutil: YES (ver 55.34.100) swscale: YES (ver 4.2.100) avresample: YES (ver 3.1.0) GStreamer: NO OpenNI: NO OpenNI PrimeSensor Modules: NO OpenNI2: NO PvAPI: NO GigEVisionSDK: NO DirectShow: YES Media Foundation: NO XIMEA: NO Intel PerC: NO

Parallel framework: Concurrency

Other third-party libraries: Use IPP: 9.0.1 [9.0.1] at: C:/D2/opencv/build/3rdparty/ippicv/ippicv_win Use IPP Async: NO Use Lapack: NO Use Eigen: NO Use Cuda: NO Use OpenCL: YES Use OpenVX: NO Use custom ... (more)

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by LBerger
close date 2017-02-16 08:18:24.153328

2 answers

Sort by ยป oldest newest most voted

answered 2017-02-14 05:09:40 -0600

LBerger gravatar image

updated 2017-02-14 05:13:14 -0600

If you want to use QT you have to clone opencv repo ( or download from zip file) and build opencv using CMake

in folder g:/lib

git clone or use button download from zip file
 run cmakegui
Where is source code = g:/lib/opencv
Where to build binaries =g:/lib/opencv/build
select generator Visual Studio 14 2015 win64 press configure
you can set OPENCV_ENABLE_NONFREE if you want SURF, SIFT... good idea is too set BUILD_EXAMPLES to true
WITH CUDA should be off if you are hurry
QT must be on. If it is not you will have to set a path to QT in CMake GUI
press generate

open.sln project should be in g:/lib/opencv/build open and generate. If you have doxygen it is quite long ...You can install opencv if you like

Now for your own project if you run cmake without installing opencv you have to set manually OPENCV_DIR to g:/lib/opencv/build

edit flag offensive delete link more


Dear LBerger:

Thank you very much for your answer!

I followed your instructions and in Visual Studio, and while building ALL_MAKE, there are 31 unresolved externals building opencv_world320d.lib, all of the out of window_QT.obj:

1>------ Build started: Project: opencv_world, Configuration: Debug x64 ------

1> Creating library C:/D2/opencv/build/lib/Debug/opencv_world320d.lib and object C:/D2/opencv/build/lib/Debug/opencv_world320d.exp 1>window_QT.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __cdecl GuiReceiver::metaObject(void)const " (?metaObject@GuiReceiver@@UEBAPEBUQMetaObject@@XZ) 1>window_QT.obj : error LNK2001: unresolved external symbol "public: virtual void * __cdecl GuiReceiver::qt_metacast(char const *)" (?qt_metacast@GuiR

DavB gravatar imageDavB ( 2017-02-15 11:04:52 -0600 )edit

Can you post cmake output ?

LBerger gravatar imageLBerger ( 2017-02-15 11:15:44 -0600 )edit

cmake outputs many files. Which ones should I post?

DavB gravatar imageDavB ( 2017-02-15 13:14:44 -0600 )edit

If you use CMake GUI you can post result print in bottom screen. Try to disable opencv_world. Do you include opencv_contrib?

LBerger gravatar imageLBerger ( 2017-02-15 15:03:07 -0600 )edit

I couldn't upload the file for the Cmake results ... I'll insert below in this comment.

How do I include opencv_contrib? it's nut in the build list.

If I disable opencv_world it completes the ALL_MAKE. All the unresolved link errors come from window_QT.obj!!

DavB gravatar imageDavB ( 2017-02-16 01:31:56 -0600 )edit

FP16: Compiler support is available found IPP (ICV version): 9.0.1 [9.0.1] at: C:/D2/opencv/build/3rdparty/ippicv/ippicv_win Could not find OpenBLAS include. Turning OpenBLAS_FOUND off Could not find OpenBLAS lib. Turning OpenBLAS_FOUND off Could NOT find Matlab (missing: MATLAB_MEX_SCRIPT MATLAB_INCLUDE_DIRS MATLAB_ROOT_DIR MATLAB_LIBRARIES MATLAB_LIBRARY_DIRS MATLAB_MEXEXT MATLAB_ARCH MATLAB_BIN) VTK is not found. Please set -DVTK_DIR in CMake to VTK build directory, or to VTK install subdirectory with VTKConfig.cmake file Processing WORLD modules... module opencv_core... module opencv_flann... module opencv_imgproc... module opencv_ml... module opencv_photo... module opencv_video... module opencv_imgcodecs... module opencv_shape...

DavB gravatar imageDavB ( 2017-02-16 01:33:01 -0600 )edit

It will take many comments to upload all of the output from CMake... :(

DavB gravatar imageDavB ( 2017-02-16 01:34:16 -0600 )edit

you can edit your message and add cmake output. Read this post too

LBerger gravatar imageLBerger ( 2017-02-16 02:28:49 -0600 )edit

I added the CMake output to my original post.

As for the StackOverflow post, I couldn't understand the answer, but I did run the

moc -I"%QTDIR%\include" -I"%QTDIR%\include\QtCore" -I"%QTDIR%\include\QtGui" -omoc_window_QT.cpp window_QT.h

with no results.

I've been scouring the web for solutions to this problem since Monday, and trying all kinds of stuff. Hours and hours without results. FRUSTRATING

DavB gravatar imageDavB ( 2017-02-16 06:48:26 -0600 )edit

Can you update your post ? you build opencv from github ? no opencv_world ? what is exactly error message now?

LBerger gravatar imageLBerger ( 2017-02-16 06:55:57 -0600 )edit

answered 2017-02-15 14:46:13 -0600

Im compiling opencv 3.2 with QT also. You must use only QT 5.6 otherones doesn't work with ocv 3.2 You can build with QT > 5.6 but you're going to get .dll error when you execute.

And also you have to add your qt bin to the path C:\Qt\5.6\msvc2015_64\bin

edit flag offensive delete link more


I don't use QT but I have some doubt about your answer If you open OpencvCVFindLibsGUI.cmake there is no test version about QT5

LBerger gravatar imageLBerger ( 2017-02-15 15:00:34 -0600 )edit

Thanks for your suggestion. I just spent a couple of hours re-downloading Qt and remaking OCV with Qt 5.6.1 and the results are EXACTLY THE SAME as with Qt 5.8.0

DavB gravatar imageDavB ( 2017-02-16 01:17:54 -0600 )edit

Question Tools

1 follower


Asked: 2017-02-14 03:28:25 -0600

Seen: 3,781 times

Last updated: Feb 16 '17