Problems with linking in Linux

Hi,

I tried to add OpenCL to my program, so all I did for the beginning is defining a global variable:

// GLOBALS

cl_context context;

(I use ATI SDK with CPU only)

I include proper -I and -L pathes as well as -lOpenCL, it gets compiled, and it finds libOpenCL.so, but I get following errors:

ocl-ocl.o: In function global constructors keyed to context': /usr/include/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp:114: multiple definition ofcontext’
ocl-main.o:/home/qwer/src/main.cc:33: first defined here
ocl-oclSum.o: In function global constructors keyed to context': /home/qwer/src/oclSum.cxx:31: multiple definition ofcontext’
ocl-main.o:/home/qwer/src/main.cc:33: first defined here
ocl-oclProduct.o: In function global constructors keyed to context': /usr/include/boost/smart_ptr/shared_ptr.hpp:169: multiple definition ofcontext’

what is this?
(I have the same error even if I change context to context234)

oops didn’t see your last comment, was going to suggest changing variable name…

maybe use preprocessor defines so it doesn’t try to create the same cl_context variable twice? “#pragma once” or similar

Can you show us the source code around /home/qwer/src/main.cc:33 and /home/qwer/src/oclSum.cxx:31?

the problem was that I have declared global varibles in a .h file and included it later several times… using “extern” solved this issue. The program compiles and links, however I now have problem with running the app. It complains that it can’t find libOpenCL.so shared library. I did define the path to it in an envirenment variable and I can run example apps from ATI SDK. Is there a way to say to the app that it should check the environemt variable? What could be the problem here?

thank you

the problem was that I did export LD_LIBRARY_PATH=$ATISTREAMSDKROOT/lib/x86_64 in one terminal and launched the program in another terminal. Doing both things in the same terminal solved the issue. There must be a way to solve it in a better way I presume…

you can export the LD_LIBRARY_PATH in your .bashrc file to make sure it is exported whenever you open up a new terminal.