Ask Your Question

Revision history [back]

Error building opencv extra modules in CMake on Win10

I rarely ask questions, I like the puzzle of solving things myself, but this one has had me stumped for two weeks and I am going in circles!

I'll put the short question first and give the detail of what I have tried below.

I am trying to compile 'webcam_demo.cpp' for character recognition but have encountered a chain of errors, I have fixed all but one.. the root cause.

When generating the opencv + extra modules project in CMake I get the following error; "WARNING: Target "opencv_text" requests linking to directory "C:/Program Files/Tesseract-OCR/lib/". Targets may link only to libraries. CMake is dropping the item." If I ignore the error and continue to build the project I get a similar error in VS2017.

Due to technical limitations of Win Vista and VS2010, I recently upgraded to Windows 10 32bit and Visual Studio 2017.

I installed opencv-3.2.0-vc14, opened webcam_demo.cpp in VS2017 and found a list of include errors, google to the rescue.. ish (due to numerous similar but different issues on google it took a few attempts to resolve each issue in turn getting a step closer until I pieced together the following from fresh)

Installed VS2017.
Installed CMake 3.9.0-rc5 win32 x86 (win installer).
Installed Tesseract 3.02.02 including dev files (win installer) (the installer skipped some additional downloads as no longer available, so I sourced the missing .h files from a backup and put them in the correct location).
Downloaded opencv_contrib-3.2.0.zip.
Downloaded opencv-3.2.0.zip.
Created folders C:\opencv\opencv-3.2.0\; C:\opencv\opencv_contrib-3.2.0\; C:\opencv\opencv32build.
Extracted the source files into the respective directories.
Checked "C:\Program Files\Tesseract-OCR" was in the Windows/system/environment variables/path.

If you are with me this far, well done :)

Opened CMake GUI, filled in the Source and Build directories.
Hit Configure.
In the freshly populated Variables List I then entered paths for; "CMake_install_prefix", "Executable_output_path", "Lept_library", "Opencv_config_file_include_dir", "Opencv_extra_modules_path", "Tesseract_incude_dir", "Tesseract_library", and some Python directories.
Hit Configure.
"Configure done" no warnings, Tesseract = YES.

Great so far I thought...

Hit Generate and I received the following error (six times in a row); "WARNING: Target "opencv_text" requests linking to directory "C:/Program Files/Tesseract-OCR/lib/". Targets may link only to libraries. CMake is dropping the item."

Having read through the CMakeCache.txt in my build folder I found an oddity that I had not noticed in the CMake configure output text, looking at CMake again I found the variable for extra dependencies read; "Extra dependencies: comctl32 gdi32 ole32 setupapi ws2_32 vfw32 C:/Program Files/Tesseract-OCR/lib/"

Is the reference to the Tesseract Lib folder the issue? should it refer to a specific .lib file instead?
I have not found this answer anywhere, nor have I found a way to change this reference.

Is there and error in the opencv_text CMakeLists.txt?
set(the_description "Text Detection and Recognition") ocv_define_module(text opencv_ml opencv_imgproc opencv_core opencv_features2d OPTIONAL opencv_highgui WRAP python) if(NOT CMAKE_CROSSCOMPILING OR OPENCV_FIND_TESSERACT) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) find_package(Tesseract QUIET) if(Tesseract_FOUND) message(STATUS "Tesseract: YES") set(HAVE_TESSERACT 1) ocv_include_directories(${Tesseract_INCLUDE_DIR}) ocv_target_link_libraries(${the_module} ${Tesseract_LIBRARIES}) else() message(STATUS "Tesseract: NO") endif() endif() configure_file(${CMAKE_CURRENT_SOURCE_DIR}/text_config.hpp.in ${CMAKE_BINARY_DIR}/text_config.hpp @ONLY) ocv_include_directories(${CMAKE_CURRENT_BINARY_DIR}) ocv_add_testdata(samples/ contrib/text FILES_MATCHING PATTERN "*.xml" PATTERN "*.xml.gz" REGEX "scenetext[0-9]+.jpg" )

I appreciate your time and hope there is an easy answer to something I have just missed.

I have come from writing small apps in Pascal in Borland Delphi to moving over to cpp in VS, so although generally familiar with software I am learning a new language.

Regards, Mike