【发布时间】:2013-04-22 10:34:47
【问题描述】:
我正在尝试在 Mac OS X 中编译带有 CUDA 支持的 opencv 2.4.5。我正在使用带有 Qt 4.8 的 cmake gui 2.8.10
之后
clang: error: unsupported option '-dumpspecs'
在制作中,我将条目 CUDA_HOST_COMPILER 设置为 /usr/bin/llvm-g++ 。但现在我收到此错误:
[ 16%] Built target IlmImf
[ 16%] Building NVCC (Device) object modules/core/CMakeFiles/cuda_compile.dir/src/cuda/./cuda_compile_generated_matrix_operations.cu.o
cc1plus: warning: command line option "-Wmissing-declarations" is valid for C/ObjC but not for C++
cc1plus: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
cc1plus: error: unrecognized command line option "-Wno-narrowing"
cc1plus: error: unrecognized command line option "-Wno-delete-non-virtual-dtor"
cc1plus: error: unrecognized command line option "-Wno-unnamed-type-template-args"
我现在能做什么?
系统设置
OS X 10.8.3 (12D78)
和
>>> clang --version
Apple LLVM version 4.2 (clang-425.0.24) (based on LLVM 3.2svn)
Target: x86_64-apple-darwin12.3.0
Thread model: posix
和
>>> g++ --version
i686-apple-darwin11-llvm-g++-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
>>> ls -al /usr/bin/g++
/usr/bin/g++ -> llvm-g++-4.2
和
>>> cc --version
Apple LLVM version 4.2 (clang-425.0.24) (based on LLVM 3.2svn)
Target: x86_64-apple-darwin12.3.0
Thread model: posix
>>> ls -al /usr/bin/cc
/usr/bin/cc -> clang
【问题讨论】:
-
您使用了哪些 CMake 选项“-D”?仅“-D CUDA_HOST_COMPILER=/usr/bin/llvm-g++”?尝试将 CUDA_HOST_COMPILER 设置为您的 NVCC 编译器完整路径,而不是您的 llvm-g++ 完整路径。此外,检查 OpenCV 要求:GCC 4.4.x 或更高版本。您使用的是 llvm-g++,而不是 GCC。
-
我已经尝试过使用 gcc 而不是 llvm-g++。无论如何,我的 gcc 是一个链接:'/usr/bin/gcc -> llvm-gcc-4.2' 但我认为这是使用 xcode 命令行工具在 mac 平台上实现 gcc 的标准方法.. 不是吗?跨度>
-
无论如何,如果我使用 /Developer/NVIDIA/CUDA-5.0/bin/nvcc(nvcc 的路径),我会收到
nvcc fatal : Unknown option 'dumpspecs' -
是的,XCode命令行工具将GCC安装在/usr/bin/gcc-4.2但最低要求版本是4.4.x(根据OpenCV的Linux安装教程),所以你应该试试从源代码编译和安装 GCC 以获得最新版本。一个问题:您是否尝试使用 MacPorts?最近我在一台装有 OSX 10.8.3 的机器上使用它们进行了快速设置,效果很好。
-
OpenCV 在 OSX 上支持 CUDA 的问题由来已久。我确认在 2.4.5 中,如果您尝试使用 g++,则会失败,因为 clang++ 不理解传递给 CUDA_HOST_COMPILER 的默认 /usr/bin/cc 编译器的某些参数(由 /usr/bin/cc 链接)。使用 clang 并为 CUDA 设置 /usr/bin/gcc 会因您报告的无法识别的命令而失败(在这种情况下,-dumpspecs 不是问题,因为它由 gcc 管理)。