[SOLVED]undefined reference errors while compiling a QT program after install QtSDK 1.2 on rhel 5.6?
-
wrote on 15 Feb 2012, 12:23 last edited by
I just installed QtSDK 1.2 on rhel 5.6 x86_64. QtSDK 1.2 requires GLIBCXX_3.4.9 from libstdc++.so.6, but redhat enterprise linux 5.6 uses libstdc++4.1.2( libstdc++.so.6.0.8) by default which doesn't have GLIBCXX_3.4.9. So I downloaded libstdc++-4.3.2-7.x86_64.rpm from rpm.pbone.net, extracted libstdc++.so.6.0.10 to /usr/libc64 and relink libstdc++.so.6 to libstdc++.so.6.0.10 library. While compiling a QT program after running qmake, I got the following errors:
@[root@stack example1]# make
g++ -m64 -Wl,-O1 -Wl,-rpath,/opt/QtSDK/Desktop/Qt/4.8.0/gcc/lib -o example1 fac1.o -L/opt/QtSDK/Desktop/Qt/4.8.0/gcc/lib -lQtGui -lQtCore -lpthread
/opt/QtSDK/Desktop/Qt/4.8.0/gcc/lib/libQtCore.so: undefined reference to 'g_main_context_push_thread_default'
/opt/QtSDK/Desktop/Qt/4.8.0/gcc/lib/libQtCore.so: undefined reference to 'inotify_init1@GLIBC_2.9'
/opt/QtSDK/Desktop/Qt/4.8.0/gcc/lib/libQtGui.so: undefined reference to 'pipe2@GLIBC_2.9'
/opt/QtSDK/Desktop/Qt/4.8.0/gcc/lib/libQtCore.so: undefined reference to 'g_main_context_pop_thread_default'
/opt/QtSDK/Desktop/Qt/4.8.0/gcc/lib/libQtGui.so: undefined reference to 'FcFreeTypeQueryFace'
/opt/QtSDK/Desktop/Qt/4.8.0/gcc/lib/libQtGui.so: undefined reference to 'FT_Library_SetLcdFilter'
/opt/QtSDK/Desktop/Qt/4.8.0/gcc/lib/libQtGui.so: undefined reference to '__longjmp_chk@GLIBC_2.11'
collect2: ld returned 1 exit status
make: *** [example1] Error 1
[root@stack example1]# @It seems g++ compiler uses all correct options. Is the newly copied libstdc++.so.6.0.10 the source of the problem? If so, how could I install QtSDK 1.2 on rhel 5.6 x86_64? Any advice? Thanks in advance.
-
wrote on 15 Feb 2012, 13:02 last edited by
Well, I found that my .pro file doesn't contain required header files. Now, i've changed my program to include correct header files. Then when make, I got new error messages:
@g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I/opt/QtSDK/Desktop/Qt/4.8.0/gcc/mkspecs/default -I. -I/opt/QtSDK/Desktop/Qt/4.8.0/gcc/include/QtCore -I/opt/QtSDK/Desktop/Qt/4.8.0/gcc/include/QtGui -I/opt/QtSDK/Desktop/Qt/4.8.0/gcc/include -I. -I. -o moc_qactiongroup.o moc_qactiongroup.cpp
moc_qactiongroup.cpp: In static member function ‘static void QActionGroup::qt_static_metacall(QObject*, QMetaObject::Call, int, void**)’:
moc_qactiongroup.cpp:78: error: invalid use of undefined type ‘struct QActionGroupPrivate’
/opt/QtSDK/Desktop/Qt/4.8.0/gcc/include/QtGui/qactiongroup.h:55: error: forward declaration of ‘struct QActionGroupPrivate’
moc_qactiongroup.cpp:79: error: invalid use of undefined type ‘struct QActionGroupPrivate’
/opt/QtSDK/Desktop/Qt/4.8.0/gcc/include/QtGui/qactiongroup.h:55: error: forward declaration of ‘struct QActionGroupPrivate’
moc_qactiongroup.cpp:80: error: invalid use of undefined type ‘struct QActionGroupPrivate’
/opt/QtSDK/Desktop/Qt/4.8.0/gcc/include/QtGui/qactiongroup.h:55: error: forward declaration of ‘struct QActionGroupPrivate’
make: *** [moc_qactiongroup.o] Error 1@I don't quite get it. My program is just a simple program which just includes QtGui header. But after make command, I found there are a lot of moc*.cpp files in my directory and moc_qactiongroup.cpp could not be compiled through. Now I'm quite confused about this. Any help? Thanks.
-
wrote on 15 Feb 2012, 14:04 last edited by
There is little we can do without some code to look at.
-
wrote on 16 Feb 2012, 02:44 last edited by
Sorry, my fault. The following is the code from the book 'Introduction to Design Patterns in C++ with Qt 2nd Edition'.
@[root@stack example1]# more fac1.cpp
#include <QtGui>int main (int argc, char* argv[]) { /* Start of function "main" which returns int. /
QApplication app(argc, argv); / Start of every Qt GUI application. /
QTextStream cout(stdout); / Create a QTextStream to standard output. */// Declarations of variables int answer = 0; /* Must be defined outside the do loop because it is used in the condition outside the do block. */ do { // local variables to the loop: int factArg = 0; int fact(1); factArg = QInputDialog::getInt(0, "Factorial Calculator", "Factorial of:", 1); /* Pop up dialog, wait for user to enter an integer, return it. */ cout << "User entered: " << factArg << endl; int i=2; while (i <= factArg) { fact = fact * i; ++i; } QString response = QString("The factorial of %1 is %2.\n%3") .arg(factArg).arg(fact) /* Each %n is replaced with an arg() value. */ .arg("Compute another factorial?"); /* Long statements can continue on multiple lines, as long as they are broken on token boundaries. */ answer = QMessageBox::question(0, "Play again?", response, QMessageBox::Yes | QMessageBox::No); /* Bitwise or of two values. */ } while (answer == QMessageBox::Yes); return EXIT_SUCCESS;
}@
I find that it's quite troublesome to install QtSDK 1.2 on rhel 5.6. The version of glibc on rhel 5.6 seems too old. I'm not sure if I should update glibc, since this may cause other problems in the system.
@[root@stack example1]# ldd /opt/QtSDK/Desktop/Qt/4.8.0/gcc/lib/libQtCore.so
/opt/QtSDK/Desktop/Qt/4.8.0/gcc/lib/libQtCore.so: /lib64/libc.so.6: version 'GLIBC_2.9' not found (required by /opt/QtSDK/Desktop/Qt/4.8.0/gcc/lib/libQtCore.so)
linux-vdso.so.1 => (0x00007fffb9ffc000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00002addfd9e0000)
libz.so.1 => /usr/lib64/libz.so.1 (0x00002addfdbfb000)
libdl.so.2 => /lib64/libdl.so.2 (0x00002addfde0f000)
libgthread-2.0.so.0 => /lib64/libgthread-2.0.so.0 (0x00002addfe014000)
librt.so.1 => /lib64/librt.so.1 (0x00002addfe218000)
libglib-2.0.so.0 => /lib64/libglib-2.0.so.0 (0x00002addfe421000)
libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00002addfe6c0000)
libm.so.6 => /lib64/libm.so.6 (0x00002addfe9ca000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00002addfec4d000)
libc.so.6 => /lib64/libc.so.6 (0x00002addfee5c000)
/lib64/ld-linux-x86-64.so.2 (0x00002addfd7c3000)
[root@stack example1]#
[root@stack example1]# ldd /opt/QtSDK/Desktop/Qt/4.8.0/gcc/lib/libQtGui.so
/opt/QtSDK/Desktop/Qt/4.8.0/gcc/lib/libQtGui.so: /lib64/libc.so.6: version 'GLIBC_2.9' not found (required by /opt/QtSDK/Desktop/Qt/4.8.0/gcc/lib/libQtGui.so)
/opt/QtSDK/Desktop/Qt/4.8.0/gcc/lib/libQtGui.so: /lib64/libc.so.6: version 'GLIBC_2.11' not found (required by /opt/QtSDK/Desktop/Qt/4.8.0/gcc/lib/libQtGui.so)
/opt/QtSDK/Desktop/Qt/4.8.0/gcc/lib/libQtGui.so: /lib64/libc.so.6: version 'GLIBC_2.9' not found (required by /opt/QtSDK/Desktop/Qt/4.8.0/gcc/lib/libQtCore.so.4)
linux-vdso.so.1 => (0x00007fff0b2ac000)
libQtCore.so.4 => /opt/QtSDK/Desktop/Qt/4.8.0/gcc/lib/libQtCore.so.4 (0x00002ab8725cc000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00002ab872af6000)
libgthread-2.0.so.0 => /lib64/libgthread-2.0.so.0 (0x00002ab872d11000)
librt.so.1 => /lib64/librt.so.1 (0x00002ab872f15000)
libglib-2.0.so.0 => /lib64/libglib-2.0.so.0 (0x00002ab87311f000)
libpng12.so.0 => /usr/lib64/libpng12.so.0 (0x00002ab8733bd000)
libz.so.1 => /usr/lib64/libz.so.1 (0x00002ab8735e1000)
libfreetype.so.6 => /usr/lib64/libfreetype.so.6 (0x00002ab8737f6000)
libgobject-2.0.so.0 => /lib64/libgobject-2.0.so.0 (0x00002ab873a7a000)
libSM.so.6 => /usr/lib64/libSM.so.6 (0x00002ab873cba000)
libICE.so.6 => /usr/lib64/libICE.so.6 (0x00002ab873ec5000)
libXrender.so.1 => /usr/lib64/libXrender.so.1 (0x00002ab8740e0000)
libfontconfig.so.1 => /usr/lib64/libfontconfig.so.1 (0x00002ab8742e9000)
libXext.so.6 => /usr/lib64/libXext.so.6 (0x00002ab87451e000)
libX11.so.6 => /usr/lib64/libX11.so.6 (0x00002ab87472f000)
libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00002ab874a3b000)
libm.so.6 => /lib64/libm.so.6 (0x00002ab874d46000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00002ab874fc9000)
libc.so.6 => /lib64/libc.so.6 (0x00002ab8751d7000)
libdl.so.2 => /lib64/libdl.so.2 (0x00002ab875530000)
/lib64/ld-linux-x86-64.so.2 (0x0000003705200000)
libexpat.so.0 => /lib64/libexpat.so.0 (0x00002ab875734000)
libXau.so.6 => /usr/lib64/libXau.so.6 (0x00002ab875957000)
libXdmcp.so.6 => /usr/lib64/libXdmcp.so.6 (0x00002ab875b59000)
[root@stack example1]#
[root@stack example1]# rpm -qf /lib64/libc.so.6
glibc-2.5-58
[root@stack example1]# strings /lib64/libc.so.6 | grep GLIBC
GLIBC_2.2.5
GLIBC_2.2.6
GLIBC_2.3
GLIBC_2.3.2
GLIBC_2.3.3
GLIBC_2.3.4
GLIBC_2.4
GLIBC_2.5
GLIBC_PRIVATE@ -
wrote on 16 Feb 2012, 03:52 last edited by
Is Qt 4.8.0 compiled under glibc_2.11? Does it work to compile Qt from source under rhel 5.6 which has lower version of glibc?
-
wrote on 16 Feb 2012, 07:12 last edited by
Solved. Finally, I compiled qt from source and it works now. It's impossible to just install QtSDK 1.2 on rhel 5.6 and run qt program.
1/6