g++ -o testQT maino -L/opt/Qt511/511/gcc_64/lib -lqt-mt -lXext -lX11 -lm
maino: In function `main':
/home/wanglj/testQT/maincpp:6: undefined reference to `QApplication::QApplication(int&, char, int)'
maino: In function `QString':
/usr/include/QtCore/qstringh:413: undefined reference to `QString::fromAscii_helper(char const, int)'
maino: In function `main':
/home/wanglj/testQT/maincpp:7: undefined reference to `QLabel::QLabel(QString const&, QWidget, QFlags<Qt::WindowType>)'
maino: In function `~QString':
/usr/include/QtCore/qstringh:869: undefined reference to `QString::free(QString::Data)'
/usr/include/QtCore/qstringh:869: undefined reference to `QString::free(QString::Data)'
collect2: ld 返回 1
make: [testQT] 错误 1
但若直接用 qtcreator 打开编译,则无错误
并且find -name libqt-mt 也找不到其他版本的该文件
用qtcreator编译好的可执行文件,也找不到连接该lib文件
[wanglj@localhost build-testQT-桌面-Debug]$ ldd testQT
linux-vdsoso1 => (0x00007fff4ddff000)
libQtGuiso4 => /usr/lib64/libQtGuiso4 (0x000000397f000000)
libQtCoreso4 => /usr/lib64/libQtCoreso4 (0x000000397ea00000)
libpthreadso0 => /lib64/libpthreadso0 (0x0000003978600000)
libstdc++so6 => /usr/lib64/libstdc++so6 (0x00007fda6a081000)
libmso6 => /lib64/libmso6 (0x0000003977a00000)
libgcc_sso1 => /lib64/libgcc_sso1 (0x0000003983a00000)
libcso6 => /lib64/libcso6 (0x0000003977e00000)
libgthread-20so0 => /lib64/libgthread-20so0 (0x000000397a600000)
librtso1 => /lib64/librtso1 (0x0000003978e00000)
libglib-20so0 => /lib64/libglib-20so0 (0x0000003979200000)
libpng12so0 => /usr/lib64/libpng12so0 (0x000000397be00000)
libzso1 => /lib64/libzso1 (0x0000003978a00000)
libfreetypeso6 => /usr/lib64/libfreetypeso6 (0x000000397ba00000)
libgobject-20so0 => /lib64/libgobject-20so0 (0x0000003979e00000)
libSMso6 => /usr/lib64/libSMso6 (0x0000003985a00000)
libICEso6 => /usr/lib64/libICEso6 (0x0000003984e00000)
libXiso6 => /usr/lib64/libXiso6 (0x000000397ce00000)
libXrenderso1 => /usr/lib64/libXrenderso1 (0x000000397d600000)
libXrandrso2 => /usr/lib64/libXrandrso2 (0x000000397de00000)
libXfixesso3 => /usr/lib64/libXfixesso3 (0x000000397da00000)
libXcursorso1 => /usr/lib64/libXcursorso1 (0x000000397e200000)
libXineramaso1 => /usr/lib64/libXineramaso1 (0x000000397e600000)
libfontconfigso1 => /usr/lib64/libfontconfigso1 (0x000000397d200000)
libXextso6 => /usr/lib64/libXextso6 (0x000000397c600000)
libX11so6 => /usr/lib64/libX11so6 (0x000000397b600000)
libdlso2 => /lib64/libdlso2 (0x0000003978200000)
/lib64/ld-linux-x86-64so2 (0x0000003977600000)
libuuidso1 => /lib64/libuuidso1 (0x0000003983600000)
libexpatso1 => /lib64/libexpatso1 (0x000000397c200000)
libxcbso1 => /usr/lib64/libxcbso1 (0x000000397ae00000)
libXauso6 => /usr/lib64/libXauso6 (0x000000397aa00000)
------解决方案--------------------
INCPATH = -I/usr/lib64/qt-33/mkspecs/default -I -I -I$(QTDIR)/include
这一行看上去你调用的qmake不是511的。试试指定完整路径运行qmake
/opt/Qt511/511/gcc_64/bin/qmake testQTpro
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)