1

I try to include one dynamic library(.so) into another. Than I include first library into app. TDS-Converter/Converter it's directory with source code. With this config I get error when try to call any function of second library via undefined reference to.

QT -= gui
TEMPLATE = lib

unix {
    DEPENDPATH += . ../../TDS-Converter/Converter
    INCLUDEPATH +=  ../../TDS-Converter/Converter
    LIBS += ../../TDS-Converter/Converter/Converter -lConverter
}
win32 {
}

SOURCES += main.cpp\
   ...

HEADERS += \ 
    ...

How to fix this ?

NG_
  • 6,895
  • 7
  • 45
  • 67
YYY
  • 191
  • 16

1 Answers1

0

Your LIBS seems wrong, it should probably be

LIBS += -L../../TDS-Converter/Converter/Converter -lConverter

...and double-check the file really is this, and fix if not:

../../TDS-Converter/Converter/Converter/libConverter.so


If you're talking about runtime, then read on:

The other library is not "inluded" in your library, it is used by your library. So it needs to be available at runtime. A quick fix, set LD_LIBRARY_PATH environment variable to the ../../TDS-Converter/Converter/Converter directory, when running an application which uses your library.

Alternatives to LD_LIBRARY_PATH environment variable are

  • use rpath, which puts the preferred library search path into the executable. Downside is, this needs to be decided at compile time.
  • Copy libConverter.so to some current system include directory, and run ldconfig to refresh library cache. Downside is, you need root and clutter system library directories.
  • Add the directory where libConvereter.so is to /etc/ld.so.conf (or preferably to a new file under /etc/ld.so.conf.d), and run ldconfig to refresh library cache. Downside is, you need root, and clutter system configuration.
Community
  • 1
  • 1
hyde
  • 60,639
  • 21
  • 115
  • 176