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