liux下的Qt 4要想让程序在没有库的时候也能运行,你需要把库的内容静态连接到你的运行文件中,即在连接的时候加 -static 选项。我先生成静态库过程如下:在qt目录下
./configure -static -thread -release
make clean
make
然后我就想把我的程序和库静态连接好让没有qt环境也能运行,在.pro文件中加上QMAKE_LFLAGS += -static,应该就可以连接静态库了,接着就
qmake
make
出现了错误:g++ -static -Wl,-rpath,/usr/local/Trolltech/Qt-4.2.3/lib -o localrom main.o mywindow.o moc_mywindow.o qrc_resource.o -L/usr/local/Trolltech/Qt-4.2.3/lib -lQtGui -L/usr/local/qt-x11-opensource-src-4.2.3/lib -L/usr/X11R6/lib -lpng -lSM -lICE -pthread -pthread -lXi -lXrender -lXrandr -lXfixes -lXcursor -lXinerama -lfreetype -lfontconfig -lXext -lX11 -lQtNetwork -pthread -pthread -lQtCore -lz -lm -pthread -lgthread-2.0 -lglib-2.0 -ldl -lpthread
/usr/bin/ld: cannot find -lQtGui
collect2: ld returned 1 exit status
make: *** [localrom] 错误 1
[user@localhost 3]$
[ 此贴被hrz520520在2007-04-06 14:00重新编辑 ]