cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

Wieke
Journeyman III

Undefined references when compiling hello world sample program.

0 Likes
4 Replies
genaganna
Journeyman III

Originally posted by: Wieke Hi I've been trying to compile the hello world program provided by the AMD APP SDK samples using Eclipse. But it isn't really working. I'm kinda at a loss here. The sofware I'm using: Ubuntu 11.04 GCC 4.5.2 Eclipse 3.5.2 (with eclipse-cdt) AMD APP SDK 2.5 (64 bit) Catalyst 11.8 (64 bit) libgl1-mesa-dev (to deal with the missing gl.h issue) What I did: 1. Create a new C/C++ project. 2. Import HelloCL.cpp & HelloCL_Kernels.cl 3. Added /opt/AMDAPP/include & /opt/AMDAPP/samples/opencl/SDKUtil/include to the GNU C & GNU C++ includes. 4. Added /opt/AMDAPP/lib/x86_64 to the library paths (Also tried /opt/AMDAPP/lib/x86 same result). 5. Build the project. Result:
**** Build of configuration Debug for project HelloWorldOpenCL **** make all Building target: HelloWorldOpenCL Invoking: GCC C++ Linker g++ -L/opt/AMDAPP/lib/x86_64 -o"HelloWorldOpenCL" ./HelloCL.o ./HelloCL.o: In function `main': /home/wieke/workspace/HelloWorldOpenCL/Debug/../HelloCL.cpp:166: undefined reference to `streamsdk::SDKFile::open(char const*)' ./HelloCL.o: In function `cl::detail::ReferenceHandler<_cl_context*>::release(_cl_context*)': /opt/AMDAPP/include/CL/cl.hpp:1091: undefined reference to `clReleaseContext' ./HelloCL.o: In function `cl::detail::ReferenceHandler<_cl_command_queue*>::release(_cl_command_queue*)': /opt/AMDAPP/include/CL/cl.hpp:1100: undefined reference to `clReleaseCommandQueue' ./HelloCL.o: In function `cl::detail::ReferenceHandler<_cl_program*>::release(_cl_program*)': /opt/AMDAPP/include/CL/cl.hpp:1127: undefined reference to `clReleaseProgram' ./HelloCL.o: In function `cl::detail::ReferenceHandler<_cl_kernel*>::release(_cl_kernel*)': /opt/AMDAPP/include/CL/cl.hpp:1136: undefined reference to `clReleaseKernel' ./HelloCL.o: In function `cl::detail::ReferenceHandler<_cl_event*>::release(_cl_event*)': /opt/AMDAPP/include/CL/cl.hpp:1145: undefined reference to `clReleaseEvent' ./HelloCL.o: In function `cl::Platform::getInfo(unsigned int, cl::string*) const': /opt/AMDAPP/include/CL/cl.hpp:1361: undefined reference to `clGetPlatformInfo' ./HelloCL.o: In function `cl::Platform::get(std::vector >*)': /opt/AMDAPP/include/CL/cl.hpp:1474: undefined reference to `clGetPlatformIDs' /opt/AMDAPP/include/CL/cl.hpp:1481: undefined reference to `clGetPlatformIDs' ./HelloCL.o: In function `Context': /opt/AMDAPP/include/CL/cl.hpp:1536: undefined reference to `clCreateContextFromType' ./HelloCL.o: In function `Program': /opt/AMDAPP/include/CL/cl.hpp:2602: undefined reference to `clCreateProgramWithSource' ./HelloCL.o: In function `cl::Program::build(std::vector > const&, char const*, void (*)(_cl_program*, void*), void*) const': /opt/AMDAPP/include/CL/cl.hpp:2675: undefined reference to `clBuildProgram' ./HelloCL.o: In function `Kernel': /opt/AMDAPP/include/CL/cl.hpp:2768: undefined reference to `clCreateKernel' ./HelloCL.o: In function `CommandQueue': /opt/AMDAPP/include/CL/cl.hpp:2791: undefined reference to `clCreateCommandQueue' ./HelloCL.o: In function `cl::CommandQueue::enqueueNDRangeKernel(cl::Kernel const&, cl::NDRange const&, cl::NDRange const&, cl::NDRange const&, std::vector > const*, cl::Event*) const': /opt/AMDAPP/include/CL/cl.hpp:3255: undefined reference to `clEnqueueNDRangeKernel' ./HelloCL.o: In function `cl::CommandQueue::finish() const': /opt/AMDAPP/include/CL/cl.hpp:3455: undefined reference to `clFinish' ./HelloCL.o: In function `int cl::Context::getInfo> >(unsigned int, std::vector >*) const': /opt/AMDAPP/include/CL/cl.hpp:1569: undefined reference to `clGetContextInfo' ./HelloCL.o: In function `int cl::Program::getBuildInfo(cl::Device const&, unsigned int, cl::string*) const': /opt/AMDAPP/include/CL/cl.hpp:2706: undefined reference to `clGetProgramBuildInfo' collect2: ld returned 1 exit status make: *** [HelloWorldOpenCL] Error 1
Thanks in advance, Wieke

You have not included required source or library.

1. Include SDKUtils code or generate SDKUtils library and include in libs

2. Include OpenCL library in libs.

 



0 Likes

I'm not sure, but i think i did that. Am I correct in assuming that the opencl library is located at "${AMDAPPSDKROOT}/lib/x86_64" and the SDKUtils code at "${AMDAPPSDKROOT}/samples/opencl/SDKUtil/include"? Because I added the first to the project's library paths and the second to the project's include directories.

0 Likes

Originally posted by: Wieke I'm not sure, but i think i did that. Am I correct in assuming that the opencl library is located at "${AMDAPPSDKROOT}/lib/x86_64" and the SDKUtils code at "${AMDAPPSDKROOT}/samples/opencl/SDKUtil/include"? Because I added the first to the project's library paths and the second to the project's include directories.

 

Have you mentioned anywhere in you projects about libOpenCL.so? 

You must include SDKUtils source or library generated from SDKUtils source in your project 

 

0 Likes

Ha! I finally figured it out. I had to add "OpenCL" to project properties > C/C++ Build > Settings > Tool Settings > GCC C Linker > Libraries (which is appearently where one defines libraries, not just library paths). Found a guide where some sample code was compiled using just the console, which worked, and figured out what eclipse was doing differently. Still get some kind of error involving the SDK's sample code, but I think as long as I don't reference SDKUtils I will be fine.

0 Likes