C&C++   发布时间:2022-04-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了macos – CUDA 5.0,CMake并在OSX 10.8.3上失败大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我尝试在Mac OSX 10.8.3上使用CMake编译一个简单的CUDA“Hello World”.

打电话给cmake.似乎成功了.这是我的CMakeList.txt:

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)

……和输出

-- 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

但之后@L_170_5@make失败并出现以下错误

[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成功了,但任何想法都会失败.

谢谢你的帮助.

解决方法

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

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 ${CR_954_11845@AKE_C_COMPILER}.")
endif()

如有必要,调整gcc的路径.

大佬总结

以上是大佬教程为你收集整理的macos – CUDA 5.0,CMake并在OSX 10.8.3上失败全部内容,希望文章能够帮你解决macos – CUDA 5.0,CMake并在OSX 10.8.3上失败所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。