OpenCL设备查询

OpenCL设备查询,opencl,Opencl,我是OpenCL新手,正在尝试运行nvidia“OpenCL设备查询”中的示例代码,此示例代码可在ubuntu 12.04上获得() 我得到了很多未定义的参考: 标准::基本字符串 shrLogEx shrLog shrSetLogFileName 我想我在包含正确的头文件时犯了一些错误,但无法找到问题所在。有人能告诉我如何运行示例代码吗 以下是错误消息: oclDeviceQuery.o: In function `main': oclDeviceQuery.cpp:(.text+0x45

我是OpenCL新手,正在尝试运行nvidia“OpenCL设备查询”中的示例代码,此示例代码可在ubuntu 12.04上获得()

我得到了很多未定义的参考:
标准::基本字符串
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  
ocldevicequiry.o:在函数'main'中:
oclDeviceQuery.cpp:(.text+0x45):对“shrSetLogFileName”的未定义引用
ocldevicequiry.cpp:(.text+0x61):对“shrLog”的未定义引用
oclDeviceQuery.cpp:(.text+0x77):对“std::allocator::allocator()”的未定义引用
oclDeviceQuery.cpp:(.text+0x92):对“std::basic_string::basic_string(char const*,std::allocator const&)”的未定义引用
oclDeviceQuery.cpp:(.text+0xa1):对“std::allocator::~allocator()”的未定义引用
oclDeviceQuery.cpp:(.text+0xb0):对“shrLog”的未定义引用
oclDeviceQuery.cpp:(.text+0xca):对“oclGetPlatformID”的未定义引用
oclDeviceQuery.cpp:(.text+0x144):对“shrLog”的未定义引用
oclDeviceQuery.cpp:(.text+0x15d):对“std::basic_string::operator+=(char const*)”的未定义引用
oclDeviceQuery.cpp:(.text+0x176):对“shrLog”的未定义引用
oclDeviceQuery.cpp:(.text+0x191):对“std::basic_string::operator+=(char const*)”的未定义引用
oclDeviceQuery.cpp:(.text+0x1e3):对“shrLog”的未定义引用
oclDeviceQuery.cpp:(.text+0x1fc):对“std::basic_string::operator+=(char const*)”的未定义引用
oclDeviceQuery.cpp:(.text+0x215):对“shrLog”的未定义引用
oclDeviceQuery.cpp:(.text+0x230):对“std::basic_string::operator+=(char const*)”的未定义引用
oclDeviceQuery.cpp:(.text+0x244):对“shrLog”的未定义引用
oclDeviceQuery.cpp:(.text+0x258):对“std::basic_string::operator+=(char const*)”的未定义引用
oclDeviceQuery.cpp:(.text+0x26c):对“std::basic_string::operator+=(char const*)”的未定义引用
oclDeviceQuery.cpp:(.text+0x27b):对“shrLog”的未定义引用
oclDeviceQuery.cpp:(.text+0x2ca):对“shrLog”的未定义引用
oclDeviceQuery.cpp:(.text+0x2e5):对“std::basic_string::operator+=(char const*)”的未定义引用
oclDeviceQuery.cpp:(.text+0x30b):对“shrLog”的未定义引用
oclDeviceQuery.cpp:(.text+0x32e):对“shrLog”的未定义引用
oclDeviceQuery.cpp:(.text+0x366):对“std::basic_string::operator+=(char const*)”的未定义引用
oclDeviceQuery.cpp:(.text+0x39f):对“shrLog”的未定义引用
oclDeviceQuery.cpp:(.text+0x43b):对“shrLog”的未定义引用
oclDeviceQuery.cpp:(.text+0x465):对“shrLog”的未定义引用
ocldevicequiry.cpp:(.text+0x4b4):对“shrLog”的未定义引用
oclDeviceQuery.cpp:(.text+0x4c3):对“shrLog”的未定义引用
ocldevicequiry.cpp:(.text+0x4e4):对“oclPrintDevInfo”的未定义引用
oclDeviceQuery.cpp:(.text+0x4f8):对“std::basic_string::operator+=(char const*)”的未定义引用
oclDeviceQuery.cpp:(.text+0x511):对“std::basic_string::operator+=(char const*)”的未定义引用
oclDeviceQuery.cpp:(.text+0x548):对“shrLog”的未定义引用
oclDeviceQuery.cpp:(.text+0x563):对“std::basic_string::operator+=(char const*)”的未定义引用
oclDeviceQuery.cpp:(.text+0x572):对'std::basic_string::c_str()const'的未定义引用
oclDeviceQuery.cpp:(.text+0x589):对'shrLogEx'的未定义引用
oclDeviceQuery.cpp:(.text+0x598):对“shrLog”的未定义引用
ocldevicequiry.cpp:(.text+0x5d2):对“std::basic_string::~basic_string()”的未定义引用
oclDeviceQuery.cpp:(.text+0x5fa):对“std::allocator::~allocator()”的未定义引用
ocldevicequiry.cpp:(.text+0x617):对“std::basic_string::~basic_string()”的未定义引用
o:在函数“静态初始化”和“销毁0(int,int)”中:
oclDeviceQuery.cpp:(.text+0x658):对“std::ios_base::Init::Init()”的未定义引用
ocldevicequiry.cpp:(.text+0x65d):对“std::ios_base::Init::~Init()的未定义引用”
o:在函数`(int,int,void(*)(int),char const*,int)中:
ocldevicequiry.cpp:(.text.Z17_uuuuoclcheckerrorexiipfviepkci[uuuuuuocheckerrorex(int,int,void(*)(int),char const*,int)]+0x3b):未定义对“oclerorstring”的引用
ocldevicequiry.cpp:(.text.Z17_uuoclcheckerrorexiipfviepkci[uu oclCheckErrorEX(int,int,void(*)(int),char const*,int)]+0x5c):对“shrLog”的未定义引用
ocldevicequiry.cpp:(.text._Z17_uuoclcheckerrorexiipfviepkci[u oclCheckErrorEX(int,int,void(*)(int),char const*,int)]+0x89):对“shrLogEx”的未定义引用
o:(.eh_frame+0xe7):未定义对“\uuuugxx\u personality\uv0”的引用
collect2:ld返回了1个退出状态

问题其实不是你的错,而是NVIDIA的错:本质上他们已经放弃了对opencl的支持。这并不奇怪,因为他们希望你使用CUDA。他们将opencl示例从主cuda SDK中取出,并逐个上传。现在,它们缺少依赖项,而且都不起作用

要解决此问题,请下载旧版本的SDK:从中选择适当的版本

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

在终端中,导航到
/home/usrname/gpusdk/OpenCL
并键入
make
。这次它将构建所需的库,为您排序链接,并且应该可以很好地编译所有示例(至少对我来说是这样)