several undefined reference errors when using OpenCL C++ Wrapper

several undefined reference errors when using OpenCL C++ Wrapper

Hi to everyone!...

I am working with a random number generator for OpenCL (MTGP32 http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MTGP/ ) and I am having several "undefined reference" errors when I try to compile the program. For example, here is an extract from the make process:

/tmp/cc8w8niK.o: In function `cl::detail::ReferenceHandler<_cl_context*>::retain(_cl_context*)':
/usr/include/CL/cl.hpp:1030: undefined reference to `clRetainContext'
/tmp/cc8w8niK.o: In function `cl::detail::ReferenceHandler<_cl_context*>::release(_cl_context*)':
/usr/include/CL/cl.hpp:1032: undefined reference to `clReleaseContext'
/tmp/cc8w8niK.o: In function `cl::detail::ReferenceHandler<_cl_command_queue*>::retain(_cl_command_queue*)':
/usr/include/CL/cl.hpp:1039: undefined reference to `clRetainCommandQueue'
/tmp/cc8w8niK.o: In function `cl::detail::ReferenceHandler<_cl_command_queue*>::release(_cl_command_queue*)':
/usr/include/CL/cl.hpp:1041: undefined reference to `clReleaseCommandQueue'
/tmp/cc8w8niK.o: In function `cl::detail::ReferenceHandler<_cl_mem*>::retain(_cl_mem*)':
/usr/include/CL/cl.hpp:1048: undefined reference to `clRetainMemObject'
/tmp/cc8w8niK.o: In function `cl::detail::ReferenceHandler<_cl_mem*>::release(_cl_mem*)':

This program uses the OpenCL C++ Wrapper. I am working in Ubuntu 12.04 LTS in a ThinkPad Twist with a Core i5 3317U and the Intel® SDK for OpenCL* Applications XE 2013 R2 64-bit. The strange thing is that error does not happens with other OpenCL SDKs (for example, in my office I have a PC with AMD OpenCL SDK under Fedora 19) and a laptop with the Intel SDK 2012 and this program runs without problems... also, other opencl examples, that use the C++ Wrapper, do not present these errors.

I attach a sample of the code, the program must be compiled inside the openCL_sample subfolder. Thanks for your help!

AttachmentSize
Download mtgp32.zip396.52 KB
2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

I found a solution for this problem... I just have to put the "-lOpenCL" flag at the end of the compilation line...

Originaly this appeared in the command line: 

g++ -g -O0 -m64 -I../ -lOpenCL -o mtgp32-sample mtgp32-sample.cpp \
parse_opt.o \ 
../mtgp32-fast.o \ 
../mtgp32-param-fast.o

I modified the Makefile, so now it can be read:

g++ -g -O0 -m64 -I../ -o mtgp32-sample mtgp32-sample.cpp \
parse_opt.o \
../mtgp32-fast.o \
../mtgp32-param-fast.o \
-lOpenCL

well, I would feel very gratefull if someone could explain this situation. The strange thing is that the original command works with other machines and/or OpenCL SDKs, but not with Ubuntu 12.04 with Intel OpenCL SDK... weird.

Login to leave a comment.