dlopen(): ./libhello.so: undefined symbol: _ZN10QTransformC1Ev ,这是什么错误?
要在Linux下做个共享库(libhello.so),在其他类里调用这个libhello.so库时,
出现了下面的错误:
dlopen(): ./libhello.so: undefined symbol: _ZN10QTransformC1Ev
这是什么错误?如何解决?谢谢!
下面是我写的Makefile文件:
#**** Makefile ****
CXX := g++
all: libhello.so bar
clean:
INCPATH =-I/usr/local/Trolltech/Qt-4.3.2/mkspecs/linux-g++ -I. -I/usr/local/Trolltech/Qt-4.3.2/include/QtCore -I/usr/local/Trolltech/Qt-4.3.2/include/QtCore -I/usr/local/Trolltech/Qt-4.3.2/include/QtGui -I/usr/local/Trolltech/Qt-4.3.2/include/QtGui -I/usr/local/Trolltech/Qt-4.3.2/include -I. -I.
test: all
LD_LIBRARY_PATH=.
./bar
libhello.so: hello.o
$(CXX) -Wl,-soname,$@ -shared -o $@ $^
bar: bar.o
$(CXX) -Wl,-E -o $@ $^ -ldl
bar.o:bar.cpp hello.h
$(CXX) -c -o bar.o bar.cpp $(INCPATH)
hello.o: hello.h
$(CXX) -c -o hello.o hello.cpp $(INCPATH)
------解决方案--------------------
没加 LIBS
link 的时候要加 -lhello
------解决方案--------------------
BatchFile code
CLIBS = -L/... -lhello #这里需要制定你的库的路径
bar.o:bar.cpp hello.h
$(CXX) -c -o bar.o bar.cpp $(INCPATH) $CLIBS