Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenCV 3.1.0 build fails on Windows with Ninja Generator #6372

Closed
willyd opened this issue Apr 7, 2016 · 3 comments · Fixed by #8819
Closed

OpenCV 3.1.0 build fails on Windows with Ninja Generator #6372

willyd opened this issue Apr 7, 2016 · 3 comments · Fixed by #8819

Comments

@willyd
Copy link

willyd commented Apr 7, 2016

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.

@willyd
Copy link
Author

willyd commented Apr 7, 2016

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

@mshabunin
Copy link
Contributor

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

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

@mloskot
Copy link

mloskot commented May 24, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants