Hello,
I am trying to compile some sample code from ARM Mali SDK (I am using a cross-compiler). I am trying to compile on a Linux Ubuntu system. The sample code is 'Hello_World_OpenCL' and when I tried to compile, I saw this error (I copied the error message directly from the Linux terminal):
hello_world_opencl.cpp: In function ‘int main()’:
hello_world_opencl.cpp:167:42: warning: narrowing conversion of ‘arraySize’ from ‘cl_int {aka int}’ to ‘size_t {aka unsigned int}’ inside { } [-Wnarrowing]
size_t globalWorksize[1] = {arraySize};
^
/tmp/ccFGhUGl.o: In function `main':
hello_world_opencl.cpp:(.text+0x3c): undefined reference to `createContext(_cl_context**)'
hello_world_opencl.cpp:(.text+0x5e): undefined reference to `cleanUpOpenCL(_cl_context*, _cl_command_queue*, _cl_program*, _cl_kernel*, _cl_mem**, int)'
hello_world_opencl.cpp:(.text+0xc2): undefined reference to `createCommandQueue(_cl_context*, _cl_command_queue**, _cl_device_id**)'
hello_world_opencl.cpp:(.text+0xe4): undefined reference to `cleanUpOpenCL(_cl_context*, _cl_command_queue*, _cl_program*, _cl_kernel*, _cl_mem**, int)'
hello_world_opencl.cpp:(.text+0x16c): undefined reference to `createProgram(_cl_context*, _cl_device_id*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, _cl_program**)'
hello_world_opencl.cpp:(.text+0x1a2): undefined reference to `cleanUpOpenCL(_cl_context*, _cl_command_queue*, _cl_program*, _cl_kernel*, _cl_mem**, int)'
hello_world_opencl.cpp:(.text+0x20a): undefined reference to `clCreateKernel'
hello_world_opencl.cpp:(.text+0x216): undefined reference to `checkSuccess(int)'
hello_world_opencl.cpp:(.text+0x238): undefined reference to `cleanUpOpenCL(_cl_context*, _cl_command_queue*, _cl_program*, _cl_kernel*, _cl_mem**, int)'
hello_world_opencl.cpp:(.text+0x2bc): undefined reference to `clCreateBuffer'
hello_world_opencl.cpp:(.text+0x2c8): undefined reference to `checkSuccess(int)'
hello_world_opencl.cpp:(.text+0x2f8): undefined reference to `clCreateBuffer'
hello_world_opencl.cpp:(.text+0x304): undefined reference to `checkSuccess(int)'
hello_world_opencl.cpp:(.text+0x334): undefined reference to `clCreateBuffer'
hello_world_opencl.cpp:(.text+0x340): undefined reference to `checkSuccess(int)'
hello_world_opencl.cpp:(.text+0x374): undefined reference to `cleanUpOpenCL(_cl_context*, _cl_command_queue*, _cl_program*, _cl_kernel*, _cl_mem**, int)'
hello_world_opencl.cpp:(.text+0x3fa): undefined reference to `clEnqueueMapBuffer'
hello_world_opencl.cpp:(.text+0x406): undefined reference to `checkSuccess(int)'
hello_world_opencl.cpp:(.text+0x448): undefined reference to `clEnqueueMapBuffer'
hello_world_opencl.cpp:(.text+0x454): undefined reference to `checkSuccess(int)'
hello_world_opencl.cpp:(.text+0x488): undefined reference to `cleanUpOpenCL(_cl_context*, _cl_command_queue*, _cl_program*, _cl_kernel*, _cl_mem**, int)'
hello_world_opencl.cpp:(.text+0x51a): undefined reference to `clEnqueueUnmapMemObject'
hello_world_opencl.cpp:(.text+0x522): undefined reference to `checkSuccess(int)'
hello_world_opencl.cpp:(.text+0x544): undefined reference to `cleanUpOpenCL(_cl_context*, _cl_command_queue*, _cl_program*, _cl_kernel*, _cl_mem**, int)'
hello_world_opencl.cpp:(.text+0x5aa): undefined reference to `clEnqueueUnmapMemObject'
hello_world_opencl.cpp:(.text+0x5b2): undefined reference to `checkSuccess(int)'
hello_world_opencl.cpp:(.text+0x5d4): undefined reference to `cleanUpOpenCL(_cl_context*, _cl_command_queue*, _cl_program*, _cl_kernel*, _cl_mem**, int)'
hello_world_opencl.cpp:(.text+0x638): undefined reference to `clSetKernelArg'
hello_world_opencl.cpp:(.text+0x640): undefined reference to `checkSuccess(int)'
hello_world_opencl.cpp:(.text+0x662): undefined reference to `clSetKernelArg'
hello_world_opencl.cpp:(.text+0x66a): undefined reference to `checkSuccess(int)'
hello_world_opencl.cpp:(.text+0x68c): undefined reference to `clSetKernelArg'
hello_world_opencl.cpp:(.text+0x694): undefined reference to `checkSuccess(int)'
hello_world_opencl.cpp:(.text+0x6c8): undefined reference to `cleanUpOpenCL(_cl_context*, _cl_command_queue*, _cl_program*, _cl_kernel*, _cl_mem**, int)'
hello_world_opencl.cpp:(.text+0x746): undefined reference to `clEnqueueNDRangeKernel'
hello_world_opencl.cpp:(.text+0x74e): undefined reference to `checkSuccess(int)'
hello_world_opencl.cpp:(.text+0x770): undefined reference to `cleanUpOpenCL(_cl_context*, _cl_command_queue*, _cl_program*, _cl_kernel*, _cl_mem**, int)'
hello_world_opencl.cpp:(.text+0x7ca): undefined reference to `clFinish'
hello_world_opencl.cpp:(.text+0x7d2): undefined reference to `checkSuccess(int)'
hello_world_opencl.cpp:(.text+0x7f4): undefined reference to `cleanUpOpenCL(_cl_context*, _cl_command_queue*, _cl_program*, _cl_kernel*, _cl_mem**, int)'
hello_world_opencl.cpp:(.text+0x84e): undefined reference to `printProfilingInfo(_cl_event*)'
hello_world_opencl.cpp:(.text+0x856): undefined reference to `clReleaseEvent'
hello_world_opencl.cpp:(.text+0x85e): undefined reference to `checkSuccess(int)'
hello_world_opencl.cpp:(.text+0x880): undefined reference to `cleanUpOpenCL(_cl_context*, _cl_command_queue*, _cl_program*, _cl_kernel*, _cl_mem**, int)'
hello_world_opencl.cpp:(.text+0x902): undefined reference to `clEnqueueMapBuffer'
hello_world_opencl.cpp:(.text+0x90e): undefined reference to `checkSuccess(int)'
hello_world_opencl.cpp:(.text+0x930): undefined reference to `cleanUpOpenCL(_cl_context*, _cl_command_queue*, _cl_program*, _cl_kernel*, _cl_mem**, int)'
hello_world_opencl.cpp:(.text+0x996): undefined reference to `clEnqueueUnmapMemObject'
hello_world_opencl.cpp:(.text+0x99e): undefined reference to `checkSuccess(int)'
hello_world_opencl.cpp:(.text+0x9c0): undefined reference to `cleanUpOpenCL(_cl_context*, _cl_command_queue*, _cl_program*, _cl_kernel*, _cl_mem**, int)'
hello_world_opencl.cpp:(.text+0xa28): undefined reference to `cleanUpOpenCL(_cl_context*, _cl_command_queue*, _cl_program*, _cl_kernel*, _cl_mem**, int)'
collect2: error: ld returned 1 exit status
Any advice? Any help? What should I do to fix this issue?
Thanks for your time,
David
Indeed !
In the platform.mk, try to replace AR=arm-none-linux-gnueabi-ar by
AR=arm-none-linux-gnueabi-ar
AR=arm-linux-gnueabihf-ar
arm-none-linux-gnueabi- is just a prefix for a particular set of ARM cross-compiling softwares.
Generally, gcc will require ld and ar when linking.
Therefore, if you currently use a cross-compiling GCC with the following prefix "arm-linux-gnueabihf-", you most likely want to use the ARchiver with the same prefix "arm-linux-gnueabihf-".