質問

While configuring ccmake I got this warning:

CMake Warning (dev) at cmake/OpenCVDetectCUDA.cmake:245 
(link_directories): This command specifies the relative path

 -Wl,/Developer/NVIDIA/CUDA-6.0
as a link directory.

Policy CMP0015 is not set: link_directories() treats paths relative to the source dir.
Run "cmake --help-policy CMP0015" for policy details. Use the 
cmake_policy command to set the policy and suppress this warning. 
Call Stack (most recent call first): 
cmake/OpenCVFindLibsPerf.cmake:24 (include) CMakeLists.txt:468 (include) 
This warning is for project developers. Use -Wno-dev to suppress it.

When i try to make the project, get this error:

ld: warning: directory not found for option '-L-Wl,/Developer/NVIDIA/CUDA-6.0' 
ld: can't map file, errno=22 for architecture x86_64 
collect2: error: ld returned 1 exit status make[2]: * [lib/libopencv_core.2.4.9.dylib]
Error 1 make[1]: [modules/core/CMakeFiles/opencv_core.dir/all] 
Error 2 make: ** [all] Error 2
役に立ちましたか?

解決

you can try this:

comment out this line(#865) in cmake/FindCUDA.cmake:

#list(APPEND CUDA_LIBRARIES -Wl,-rpath "-Wl,${_cuda_path_to_cudart}")

then opencv249 can be built with CUDA successfully on my mac.

他のヒント

If using brew to install opencv, you might need to edit the formula brew edit opencv

like so: (source https://github.com/Homebrew/homebrew-science/issues/1182)

if build.with? "cuda"
  ENV["CUDA_NVCC_FLAGS"] = "-Xcompiler -stdlib=libstdc++; -Xlinker -stdlib=libstdc++"
  inreplace "cmake/FindCUDA.cmake", "list(APPEND CUDA_LIBRARIES -Wl,-rpath \"-Wl,${_cuda_path_to_cudart}\")", "#list(APPEND CUDA"
  args << "-DWITH_CUDA=ON"
  args << "-DCMAKE_CXX_FLAGS=-stdlib=libstdc++"
else
  args << "-DWITH_CUDA=OFF"
end

this does exactly the same as commenting out the line

#list(APPEND CUDA_LIBRARIES -Wl,-rpath "-Wl,${_cuda_path_to_cudart}")

from the accepted answer.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top