OpenCL设备查询

时间:2013-11-20 19:23:49

标签: opencl

我是OpenCL的新手,并尝试在ubuntu 12.04上运行nvidia'OpenCL设备查询'中的示例代码(https://developer.nvidia.com/opencl

我得到了很多未定义的参考:
性病:: basic_string的
shrLogEx
shrLog
shrSetLogFileName

我想我在包含正确的头文件方面犯了一些错误但无法找到问题。有谁能告诉我如何运行示例代码?

以下是错误消息:

oclDeviceQuery.o: In function `main':  
oclDeviceQuery.cpp:(.text+0x45): undefined reference to `shrSetLogFileName'  
oclDeviceQuery.cpp:(.text+0x61): undefined reference to `shrLog'  
oclDeviceQuery.cpp:(.text+0x77): undefined reference to `std::allocator<char>::allocator()'  
oclDeviceQuery.cpp:(.text+0x92): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'  
oclDeviceQuery.cpp:(.text+0xa1): undefined reference to `std::allocator<char>::~allocator()'  
oclDeviceQuery.cpp:(.text+0xb0): undefined reference to `shrLog'  
oclDeviceQuery.cpp:(.text+0xca): undefined reference to `oclGetPlatformID'  
oclDeviceQuery.cpp:(.text+0x144): undefined reference to `shrLog'  
oclDeviceQuery.cpp:(.text+0x15d): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator+=(char const*)'  
oclDeviceQuery.cpp:(.text+0x176): undefined reference to `shrLog'  
oclDeviceQuery.cpp:(.text+0x191): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator+=(char const*)'  
oclDeviceQuery.cpp:(.text+0x1e3): undefined reference to `shrLog'  
oclDeviceQuery.cpp:(.text+0x1fc): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator+=(char const*)'  
oclDeviceQuery.cpp:(.text+0x215): undefined reference to `shrLog'  
oclDeviceQuery.cpp:(.text+0x230): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator+=(char const*)'  
oclDeviceQuery.cpp:(.text+0x244): undefined reference to `shrLog'  
oclDeviceQuery.cpp:(.text+0x258): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator+=(char const*)'  
oclDeviceQuery.cpp:(.text+0x26c): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator+=(char const*)'  
oclDeviceQuery.cpp:(.text+0x27b): undefined reference to `shrLog'  
oclDeviceQuery.cpp:(.text+0x2ca): undefined reference to `shrLog'  
oclDeviceQuery.cpp:(.text+0x2e5): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator+=(char const*)'  
oclDeviceQuery.cpp:(.text+0x30b): undefined reference to `shrLog'  
oclDeviceQuery.cpp:(.text+0x32e): undefined reference to `shrLog'  
oclDeviceQuery.cpp:(.text+0x366): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator+=(char const*)'  
oclDeviceQuery.cpp:(.text+0x39f): undefined reference to `shrLog'  
oclDeviceQuery.cpp:(.text+0x43b): undefined reference to `shrLog'  
oclDeviceQuery.cpp:(.text+0x465): undefined reference to `shrLog'  
oclDeviceQuery.cpp:(.text+0x4b4): undefined reference to `shrLog'  
oclDeviceQuery.cpp:(.text+0x4c3): undefined reference to `shrLog'  
oclDeviceQuery.cpp:(.text+0x4e4): undefined reference to `oclPrintDevInfo'  
oclDeviceQuery.cpp:(.text+0x4f8): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator+=(char const*)'  
oclDeviceQuery.cpp:(.text+0x511): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator+=(char const*)'  
oclDeviceQuery.cpp:(.text+0x548): undefined reference to `shrLog'  
oclDeviceQuery.cpp:(.text+0x563): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator+=(char const*)'  
oclDeviceQuery.cpp:(.text+0x572): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::c_str() const'  
oclDeviceQuery.cpp:(.text+0x589): undefined reference to `shrLogEx'  
oclDeviceQuery.cpp:(.text+0x598): undefined reference to `shrLog'  
oclDeviceQuery.cpp:(.text+0x5d2): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'  
oclDeviceQuery.cpp:(.text+0x5fa): undefined reference to `std::allocator<char>::~allocator()'  
oclDeviceQuery.cpp:(.text+0x617): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'  
oclDeviceQuery.o: In function `__static_initialization_and_destruction_0(int, int)':  
oclDeviceQuery.cpp:(.text+0x658): undefined reference to `std::ios_base::Init::Init()'  
oclDeviceQuery.cpp:(.text+0x65d): undefined reference to `std::ios_base::Init::~Init()'  
oclDeviceQuery.o: In function `__oclCheckErrorEX(int, int, void (*)(int), char const*, int)':  
oclDeviceQuery.cpp:(.text._Z17__oclCheckErrorEXiiPFviEPKci[__oclCheckErrorEX(int, int, void (*)(int), char const*, int)]+0x3b): undefined reference to `oclErrorString'  
oclDeviceQuery.cpp:(.text._Z17__oclCheckErrorEXiiPFviEPKci[__oclCheckErrorEX(int, int, void (*)(int), char const*, int)]+0x5c): undefined reference to `shrLog'  
oclDeviceQuery.cpp:(.text._Z17__oclCheckErrorEXiiPFviEPKci[__oclCheckErrorEX(int, int, void (*)(int), char const*, int)]+0x89): undefined reference to `shrLogEx'  
oclDeviceQuery.o:(.eh_frame+0xe7): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status  

1 个答案:

答案 0 :(得分:2)

问题实际上不是你的错,但实际上是NVIDIA的:基本上他们已经放弃了他们的opencl支持。因为他们希望你使用CUDA,所以不足为奇。他们从主cuda SDK中取出opencl样本,然后逐个上传。现在他们已经缺少了依赖关系,但没有一个工作。

要解决此问题,请下载旧版SDK:从https://developer.nvidia.com/cuda-toolkit-42-archive

中选择适当的版本

对于linux:下载后,使用通常的./gpucomputing*.run从终端运行它。在安装过程中,我建议您在提示时选择将sdk放在主文件夹/home/usrname/gpusdk中,否则它将提取到root。接下来我收到一条关于无法找到CUDA的消息,所以我就把它留空了。

在终端中,导航至/home/usrname/gpusdk/OpenCL并输入make。这次将构建所需的库,为您排序链接,并且应该编译所有样本(至少它对我来说)