首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >OSX10.8.3上的CUDA 5.0、CMake和Make失败

OSX10.8.3上的CUDA 5.0、CMake和Make失败
EN

Stack Overflow用户
提问于 2013-04-30 03:24:16
回答 2查看 3.2K关注 0票数 4

我尝试在MacOSX10.8.3上使用CMake编译一个简单的CUDA "Hello World“。

调用cmake .似乎成功了。这是我的CMakeList.txt

代码语言:javascript
运行
复制
project(HelloWorld)
cmake_minimum_required(VERSION 2.8)

FIND_PACKAGE(CUDA)

CUDA_INCLUDE_DIRECTORIES(/Developer/NVIDIA/CUDA-5.0/samples/common/inc)
CUDA_ADD_EXECUTABLE(helloWorld helloWorld.cu)

..。和输出:

代码语言:javascript
运行
复制
-- The C compiler identification is Clang 4.2.0
-- The CXX compiler identification is Clang 4.2.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Found CUDA: /Developer/NVIDIA/CUDA-5.0 (found version "5.0")
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/mennny/Documents/UNI/6_Semester/0_PMPP/1_exercises/cuda-hello-world

但之后调用make失败,并出现以下错误:

代码语言:javascript
运行
复制
[100%] Building NVCC (Device) object CMakeFiles/helloWorld.dir//./helloWorld_generated_helloWorld.cu.o
clang: error: unsupported option '-dumpspecs'
clang: error: no input files
CMake Error at helloWorld_generated_helloWorld.cu.o.cmake:206 (message): Error generating /Users/mennny/Documents/UNI/6_Semester/0_PMPP/1_exercises/cuda-hello-world/CMakeFiles/helloWorld.dir//./helloWorld_generated_helloWorld.cu.o


make[2]: *** [CMakeFiles/helloWorld.dir/./helloWorld_generated_helloWorld.cu.o] Error 1
make[1]: *** [CMakeFiles/helloWorld.dir/all] Error 2
make: *** [all] Error 2

我用谷歌搜索了显示的错误,但找不到任何足够的答案。尽管cmake成功了,但是为什么make失败了呢?

谢谢你的帮助。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-04-30 07:13:28

在OS X Lion中,XCode中的默认C编译器更改为CLang。CLang与nvcc不兼容,因此您需要更改nvcc用于非cuda(主机)代码的编译器。将以下内容添加到您的CMakeList.txt中将起作用:

代码语言:javascript
运行
复制
if (NOT DEFINED CUDA_HOST_COMPILER AND CMAKE_C_COMPILER_ID STREQUAL "Clang" AND EXISTS /usr/bin/gcc)
  set(CUDA_HOST_COMPILER /usr/bin/gcc CACHE FILEPATH "Host side compiler used by NVCC")
  message(STATUS "Setting CMAKE_HOST_COMPILER to /usr/bin/gcc instead of ${CMAKE_C_COMPILER}.")
endif()

如有必要,请将路径调整为gcc。

票数 1
EN

Stack Overflow用户

发布于 2013-07-10 17:53:14

如果您不想更改您的CMakeLists.txt,那么将环境变量CXX设置为" GCC“就可以了(假设在/usr/bin之前的path中没有其他的GCC)。

CMake会自动拾取它。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16286588

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档