PDA

View Full Version : qt does not try to find a 3rd party lib even though its location is specified



ohuohuo
25th February 2016, 01:40
I put four 3rd party .so files in total in same folder. And qt can find 3 of them, except only one: libMPCtrl.so

Below is part of my pro file: (notice that I just put three .so files to LIBS but interestingly, qt find another one automatically.) How can I make qt find the libMPCtrl.so ?

unix{
LIBS += -L$$PWD/lib -lhcnetsdk \
-lPlayCtrl \
-lMPCtrl
}

INCLUDEPATH += $$PWD/include/ \
$$PWD/Configuration/Public/ \
$$PWD/lib/

(It doesn't matter whether I use . or $$PWD, same result.)

I mean, actually instead of "cannot find it", qt even didn't TRY to find it. According to strace tool, qt never tried to open() this .so file.

anda_skoa
25th February 2016, 09:12
I am not sure what you mean by "qt doesn't try to find it".

Qt itself only ever tries to look for plugins for one of its subsystems that are plugin extensible, e.g. image I/O plugins.

Did you mean your application doesn't start because the system linker can't find the library or did you mean your build process doesn't attempt to link the library?

Cheers,
_

ChrisW67
25th February 2016, 20:18
The issue is almost certainly that the OP thinks "." and "$$PWD" refer to somewhere other than where qmake does, and consequently the compiler (in the case of INCLUDEPATH) and linker (LIBS) are being told to look. Inspection of the compiler/linker commands issued by make (or nmake) should make plain where it is actually looking.

ohuohuo
28th February 2016, 04:47
I've checked makefile, nothing seems wrong. any ideas?

CC = gcc
CXX = g++
DEFINES = -DQT_WEBKIT -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED
CFLAGS = -pipe -g -Wall -W -D_REENTRANT $(DEFINES)
CXXFLAGS = -pipe -g -Wall -W -D_REENTRANT $(DEFINES)
INCPATH = -I/usr/share/qt4/mkspecs/linux-g++ -I../RemoteClient -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtOpenGL -I/usr/include/qt4 -I../RemoteClient/include -I../RemoteClient/Configuration/Public -I../RemoteClient/lib -I../RemoteClient -I/usr/X11R6/include -I. -I. -I../RemoteClient -I.
LINK = g++
LFLAGS =
LIBS = $(SUBLIBS) -L/usr/lib/i386-linux-gnu -L/usr/X11R6/lib -L./lib/ -Wl,-rpath=./lib/,-rpath=./ -lhcnetsdk -lPlayCtrl -lMPCtrl -lQtOpenGL -lQtGui -lQtCore -lGL -lpthread
AR = ar cqs
RANLIB =
QMAKE = /usr/bin/qmake-qt4
TAR = tar -cf
COMPRESS = gzip -9f
COPY = cp -f
SED = sed
COPY_FILE = $(COPY)
COPY_DIR = $(COPY) -r
STRIP = strip
INSTALL_FILE = install -m 644 -p
INSTALL_DIR = $(COPY_DIR)
INSTALL_PROGRAM = install -m 755 -p
DEL_FILE = rm -f
SYMLINK = ln -f -s
DEL_DIR = rmdir
MOVE = mv -f
CHK_DIR_EXISTS= test -d
MKDIR = mkdir -p

####### Output directory

OBJECTS_DIR = ./

Added after 11 minutes:

The latter one, the build process doesn't attempt to link the library. because the strace found that it didn't make open() call to the .so file. and ldd shows that it only depends on libhcnetsdk.so => ./libhcnetsdk.so (0xb6eaa000) and libhpr.so => ./libhpr.so (0xb5c0c000) besides standard libs.

Moreover, after I changed that to unix{
LIBS += -L./lib/ -Wl,-rpath=./lib/,-rpath=./ -lhcnetsdk -lPlayCtrl -lMPCtrl
}

still problem.

anda_skoa
28th February 2016, 10:56
Ok, so your build fails with an "undefined reference" error and MPCtrl contains that symbol?

Cheers,
_