1

After installing qwt-6.1.2.zip I see it at:

/usr/local/qwt-6.1.2/lib/libqwt.so

The Qt app I'm developing depends on in, so the .pro has the following:

    INCLUDEPATH += "/usr/local/qwt-6.1.2/include"
    LIBS += -L"/usr/local/qwt-6.1.2/lib"
    CONFIG(debug, debug|release) {
        LIBS += -lqwtd
    } else {
        LIBS += -lqwt
    }

It compiles well but executing (outside QtCreator) gives:

"symbol lookup error: ...: undefined symbol"

Which is solved by doing:

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/qwt-6.1.2/lib
export LD_LIBRARY_PATH

If I understand it correctly, LD_LIBRARY_PATH should only be set in case the .so files are in exotic (non-standard) locations. Question, /usr/local/qwt-6.1.2/lib is standard (I guess not)?

When and where should LD_LIBRARY_PATH be set? I think one option is to do that at installation time, something like:

echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/qwt-6.1.2/lib" >> .bashrc
echo "export LD_LIBRARY_PATH" >> .bashrc

One downside of this is that multiple installations will write that stuff multiple times to .bashrc.

My question is related to this and actually I ended up using the -rpath idea, but I think the context here could be seen as more specific, related to Qt, so isn't duplicate. In fact, I ended up using this.

Community
  • 1
  • 1
KcFnMi
  • 5,516
  • 10
  • 62
  • 136
  • Possible duplicate of [What's the difference between -rpath and -L?](http://stackoverflow.com/questions/8482152/whats-the-difference-between-rpath-and-l) – n. m. could be an AI Oct 08 '15 at 17:52

1 Answers1

2

For your given use case it seems like you shouldn't be using LD_LIBRARY_PATH. Instead, you should add a configuration file to /etc/ld.so.conf.d/ and the run ldconfig.

For example as root run the following commands:

echo "/usr/local/qwt-6.1.2/lib" > /etc/ld.so.conf.d/qwt.conf
ldconfig

ldconfig creates information required for dynamically linked programs to resolve where the libraries are located. The configuration file created tells ldconfig to search in the specified directory for more libraries to include in its database of shared libraries. This allows programs to use the shared library without have to set the LD_LIBRARY_PATH environment variable because it is now a standard library.

Jay Hirata
  • 71
  • 2
  • Didn't tried this (found another solution, as edit at the end of the question), but in this case what will happen if another version of Qwt is already installed (at /usr/lib/libqwt.so)? – KcFnMi Oct 08 '15 at 18:52