library is linked but reference is undefined

前端 未结 3 1920
太阳男子
太阳男子 2020-12-01 06:05

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

#include 
#include 
#include &         


        
3条回答
  •  日久生厌
    2020-12-01 06:57

    when you are linking, the order of your libraries and source files makes a difference. for example for your case,

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

    functions defined in the OpenCL library might not be loaded, since there nothing before them asking for a look-up. however if you use,

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

    then any requests for functions will be found in the OpenCL library and they will be loaded.

提交回复
热议问题