Opencv: OpenCV 3.1.0 build fails on Windows with Ninja Generator

Created on 7 Apr 2016  路  3Comments  路  Source: opencv/opencv

This is a template helping you to create an issue which can be processes as quickly as possible. Feel free to add additional information or remove not relevant points if you do not need them.

If you have a question rather than reporting a bug please go to http://answers.opencv.org where you get much faster responses.

Please state the information for your system

  • OpenCV version: 3.1.0
  • Host OS: Windows 10
  • Compiler & CMake: MSVC 120 & CMake 3.5

    In which part of the OpenCV library you got the issue?

  • CMakeLists.txt

    Expected behaviour

Build succeeds

Actual behaviour

LINK : fatal error LNK1104: cannot open file 'Files\NVIDIA.obj'

Additional description

This line breaks the build with Ninja under Windows. I think the line should be:

# this
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${CMAKE_LIBRARY_PATH_FLAG}$<SHELL_PATH:${p}>)
# instead of that
# set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} -L${p})

But even with this change the build fails because of the spaces in the path which Ninja does not like. Maybe $<SHELL_PATH:...> should return a short path but that's a CMake issue.

As a workaround one can use:

if(NOT CMAKE_GENERATOR MATCHES "Ninja" AND NOT MSVC)
  set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} -L${p})
endif()   

This problem also affects consuming projects as the link flags end up in the OpenCVModules*.cmake files.

I find Ninja much faster than msbuild on Windows especially when building with CUDA so it would be nice if OpenCV supported this generator too.

bug builinstall gpcuda (contrib) low

All 3 comments

Posted a related issue to CMake bug tracker: https://cmake.org/Bug/view.php?id=16053

You can use /maxcpucount option with msbuild to speed up the build process. The example for 4-core CPU:

.cmd cmake --build . --config release -- /maxcpucount:5

@mshabunin with respect, but the maxcpucount nothing to do really w.r.t. parallel compilation of translation units.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

terrapass picture terrapass  路  3Comments

opencv-pushbot picture opencv-pushbot  路  3Comments

sturkmen72 picture sturkmen72  路  3Comments

dpo picture dpo  路  3Comments

shravankumar147 picture shravankumar147  路  3Comments