久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

庫已鏈接但引用未定義

library is linked but reference is undefined(庫已鏈接但引用未定義)
本文介紹了庫已鏈接但引用未定義的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在嘗試使用以前運行過一次的 NVIDIA 卡在 Ubuntu 上編譯 openCL 程序,

I'm trying to compile an openCL program on Ubuntu with an NVIDIA card that worked once before,

#include <CL/cl.h>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  cl_platform_id platform;
  cl_device_id device;
  cl_context context;
  cl_command_queue command_queue;
  cl_int error;

  if(clGetPlatformIDs(1, &platform, NULL) != CL_SUCCESS) {
    cout << "platform error" << endl;
  }

  if(clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 1, &device, NULL) != CL_SUCCESS) {
    cout << "device error" << endl;
  }

  context = clCreateContext(NULL, 1, &device, NULL, NULL, &error);
  if(error != CL_SUCCESS) {
    cout << "context error" << endl;
  }

  command_queue = clCreateCommandQueue(context, device, 0, &error);
  if(error != CL_SUCCESS) {
    cout << "command queue error" << endl;
  }

  return 0;
}

我是這樣編譯的,

g++ -I/usr/local/cuda/include -L/usr/lib/nvidia-current -lOpenCL opencl.cpp

我得到了這個結果

/tmp/ccAdS9ig.o: In function `main':
opencl.cpp:(.text+0x1a): undefined reference to `clGetPlatformIDs'
opencl.cpp:(.text+0x3d): undefined reference to `clGetDeviceIDs'
opencl.cpp:(.text+0x65): undefined reference to `clCreateContext'
opencl.cpp:(.text+0x85): undefined reference to `clCreateCommandQueue'
collect2: ld returned 1 exit status

但是 nm -D/usr/lib/nvidia-current/libOpenCL.so 告訴我 libOpenCL.so 至少包含 clGetPlatformIDs

but nm -D /usr/lib/nvidia-current/libOpenCL.so tells me that libOpenCL.so at least contains clGetPlatformIDs

0000000000002400 T clGetKernelWorkGroupInfo
0000000000002140 T clGetMemObjectInfo
0000000000002e80 T clGetPlatformIDs
0000000000002de0 T clGetPlatformInfo
0000000000002310 T clGetProgramBuildInfo
00000000000022f0 T clGetProgramInfo
00000000000021f0 T clGetSamplerInfo

我是不是遺漏了什么.

推薦答案

來自 gcc 手冊頁:

   -llibrary
   -l library
       Search the library named library when linking.  (The second alternative with the library as a separate argument is only for POSIX compliance and is not recommended.)

       It makes a difference where in the command you write this option; the linker searches and processes libraries and object files in the order they are specified.  Thus, foo.o
       -lz bar.o searches library z after file foo.o but before bar.o.  If bar.o refers to functions in z, those functions may not be loaded.

       The linker searches a standard list of directories for the library, which is actually a file named liblibrary.a.  The linker then uses this file as if it had been specified
       precisely by name.

因此嘗試在編譯命令中的文件參數(shù)之后指定 -lOpenCL.

So try to specify the -lOpenCL after the file argument in your compile command.

您還可以在 libOpenCL.so 中搜索符號,這是一個共享庫文件.使用您的命令,您將程序再次鏈接到靜態(tài)庫,格式為 libOpenCL.a.

You also search for symbols in libOpenCL.so, which is a shared library file. With your command you link your program agains a static library, in the format libOpenCL.a.

這篇關于庫已鏈接但引用未定義的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯(lián)系我們刪除處理,感謝您的支持!

相關文檔推薦

What do compilers do with compile-time branching?(編譯器如何處理編譯時分支?)
Can I use if (pointer) instead of if (pointer != NULL)?(我可以使用 if (pointer) 而不是 if (pointer != NULL) 嗎?)
Checking for NULL pointer in C/C++(在 C/C++ 中檢查空指針)
Math-like chaining of the comparison operator - as in, quot;if ( (5lt;jlt;=1) )quot;(比較運算符的數(shù)學式鏈接-如“if((5<j<=1)))
Difference between quot;if constexpr()quot; Vs quot;if()quot;(“if constexpr()之間的區(qū)別與“if())
C++, variable declaration in #39;if#39; expression(C++,if 表達式中的變量聲明)
主站蜘蛛池模板: 日韩最新网站 | 中文字幕免费中文 | 人成在线 | 国产露脸对白88av | 91精品国产自产在线老师啪 | 欧美日韩高清一区 | 日日操夜夜操天天操 | 欧美999| 日韩精品a在线观看图片 | 日韩欧美一级精品久久 | 9191av| 韩日在线视频 | 色资源在线视频 | 激情一区二区三区 | 精品久久久久久久久久久久久 | 欧美 日韩 国产 成人 | 午夜三级在线观看 | 理论片87福利理论电影 | 日韩视频精品在线 | 欧洲色| 亚洲色图综合 | 色男人的天堂 | 国产在线中文字幕 | 真人女人一级毛片免费播放 | 欧美亚洲免费 | av香蕉 | 亚洲va欧美va天堂v国产综合 | 久久精品欧美一区二区三区麻豆 | 欧美日韩亚洲系列 | 国产精品国产三级国产aⅴ中文 | 欧美日韩在线国产 | 亚洲免费视频播放 | 网址黄| 亚洲啪啪| 一级毛片在线看 | av高清毛片 | 国产精品免费视频一区 | 久久成人综合 | 国产精品国产精品 | 91免费在线播放 | 亚洲欧美高清 |