Ask Your Question
1

Trouble linkig opencv_world from latest source

asked 2013-01-07 11:08:46 -0600

simcha gravatar image

I have downloaded the latest OpenCV source from a github, and tried to compile it with VS2010 (with CUDA and QT support). Everything went well, except linking the opencv_world module. I'm getting lots of unresolved external symbols for symbols starting with 'gpu::', like this one:

gpumat.obj : error LNK2019: unresolved external symbol "void __cdecl cv::gpu::device::set_to_gpu<short>(struct cv::gpu::PtrStepSz<unsigned char>,short const *,int,struct CUstream_st *)" (??$set_to_gpu@F@device@gpu@cv@@YAXU?$PtrStepSz@E@12@PBFHPAUCUstream_st@@@Z) referenced in function "void __cdecl `anonymous namespace'::kernelSetCaller<short>(class cv::gpu::GpuMat &,class cv::Scalar_<double>,struct CUstream_st *)" (??$kernelSetCaller@F@?A0x4d15d89c@@YAXAAVGpuMat@gpu@cv@@V?$Scalar_@N@3@PAUCUstream_st@@@Z)

I'm guessing the problem is in the opencv_gpu module, but the build for that module succeeded. And I'm stuck there, don't know what to do next.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2013-08-30 12:06:38 -0600

Steve107 gravatar image

updated 2013-08-31 07:16:43 -0600

I have fixed this error on my system (Visual Studio 2012, Windows 7 (building 32-bit application, OpenCV 2.4, Qt5)).

1) in VS right click on the opencv_world module, go to properties->linker->input in additional_dependencies put the explicit path for the opencv_ts290.lib library that your project builds. (This got rid of a load of unresolved symbols defined in the C++ standard template library (header files)). (For your specific problem above you can search the lib\Release directory where VS is putting the library files it is building and search for 'set_to_gpu' to see which .lib file it is defined in, and then add that .lib to the additional_dependencies list).

2) Then the next problem was that the file modules\highgui\src\window_QT.h uses the QT_OBJECT macro and needs the Qt moc compiler run on it during the build, but the specification of this (when using Qt5) defined in modules\highgui\CMakeLists.txt is not working. Below are my modifications to highgui\CMakeLists.txt:

if(HAVE_QT5)

# COMMENT_OUT set(CMAKE_AUTOMOC ON)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

QT5_ADD_RESOURCES(_RCC_OUTFILES src/window_QT.qrc)

QT5_WRAP_CPP(_MOC_OUTFILES src/window_QT.h) ##### ADDED_LINE ######

# COMMENT_OUT list(APPEND highgui_srcs src/window_QT.cpp src/window_QT.h ${_RCC_OUTFILES})

list(APPEND highgui_srcs src/window_QT.cpp ${_MOC_OUTFILES} ${_RCC_OUTFILES}) ## ADDED_LINE ##

(This got rid of the rest of the Unresolved external symbol errors).

3) then there was a load of 'precompiled image/object is not linked, image may not run' This is solved by unchecking ENABLE_PRECOMPILED_HEADERS in CMake. (compilation is a lot slower)

You must make changes 2) and 3) and then run CMake (configure and generate) and then make change 1) and the reload the whole project in VS and build it again.

4) I also had a problem when trying to build the documentation:

With my setup the information here for how to install Sphinx did not work as sphinx-build could not find the pkg_resources module http://docs.opencv.org/doc/tutorials/introduction/windows_install/windows_install.html#hereinstallsphinx

I had to first run download and run distribute.py: python distribute_setup.py and then in that same directory run: python easy_install.py sphinx

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2013-01-07 11:08:46 -0600

Seen: 1,831 times

Last updated: Aug 31 '13