Home | News | Documentation | Download

Shared Library Linking in C++


I am having problems running a C++ program using ROOT. It compiles and links without complaint. Here is the linking step:

Then, when I run, I get the error:

But, the file: /usr/local/lib/root/libGpad.so definitely exists.

If I remove the -lGpad flag in the linking, it complains of things like “/usr/local/lib/root/libGui.so: undefined reference to 'TCanvas” when it tries to link.

What could I be doing wrong?




On the very first look I’d say that your runtime environment is not set up correctly.

The compilation command looks more or less reasonable. But I would’ve implemented it relying on the root-config script a bit more.

So, is the /usr/local/lib/root path in your LD_LIBRARY_PATH or DYLD_LIBRARY_PATH (in case you’re on MacOS X, which I doubt from the application name) environment variable? Did you set up your environment by let’s say sourcing the thisroot.[c]sh script? (Wherever it may be in your installation…)



Thanks. You were correct - My LD_LIBRARY_PATH was not set. I had set it in another terminal, but forgot to set it in my IDE.