在配置ccmake时,我收到了以下警告:
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.
当我试图制作这个项目时,得到了这个错误:
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
你可以试试这个:
在cmake/FindCUDA.cmake:中注释掉这一行(#865)
#list(APPEND CUDA_LIBRARIES -Wl,-rpath "-Wl,${_cuda_path_to_cudart}")
那么opencv249可以在我的mac上成功地与CUDA一起构建。
如果使用brew安装opencv,您可能需要编辑公式brew编辑opencv
像这样:(来源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
这与注释出行完全相同
#list(APPEND CUDA_LIBRARIES -Wl,-rpath "-Wl,${_cuda_path_to_cudart}")
根据已接受的答案。