编译时链接与运行时链接针对 std:: 库
首先是问题: 我需要一种无需在 /etc/ld.so.conf.d 中放置配置文件的方法,以允许客户端使用默认安装的 gcc 在 RHEL5.7 和 RHEL6.1 上针对我的 SDK 进行构建。在这种情况下,设置 LD_LIBRARY_PATH 不起作用。是否有其他方法允许客户链接到我的 sdk,而无需向他们提供有关如何配置其系统的知识库文章?请阅读以下内容以进行澄清。
其次是情况:
我负责在 RHEL5 和 RHEL6 上构建运行时 SDK。我的 RHEL5.7 盒子是标准的非注册安装,我的 RHEL6.1 盒子也是如此。然而,在我的 RHEL6 机器上,我自己编译了 gcc:
[mehoggan@hoggant35002 ~]$ cat /etc/redhat-release; gcc --version
Red Hat Enterprise Linux Server release 5.7 (Tikanga)
gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-51)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOS
--
[mehoggan@hogganz400 session2]$ cat /etc/redhat-release; gcc --version
Red Hat Enterprise Linux Server release 6.1 (Santiago)
gcc (GCC) 4.5.2
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
--
我无法提供我尝试链接的 .so 和 .a 文件。然而,我将尝试描述正在发生的事情。采用相同的源代码并根据我的 SDK 构建并运行它。我得到以下结果:
RHEL 6 Box:
[mehoggan@hogganz400 session2]$ ls -l
total 1848
-rw-rw-r-- 1 mehoggan mehoggan 189 Nov 3 13:02 main.cpp
-rw-rw-r-- 1 mehoggan mehoggan 845 Nov 3 13:02 mainwindow.cpp
-rw-rw-r-- 1 mehoggan mehoggan 288 Nov 3 13:02 mainwindow.h
-rwxrwxr-x 1 mehoggan mehoggan 25818 Nov 4 09:26 Session2
-rw-rw-r-- 1 mehoggan mehoggan 649 Nov 3 13:02 Session2.pro
-rw-rw-r-- 1 mehoggan mehoggan 1847296 Nov 3 13:02 vc90.pdb
[mehoggan@hogganz400 session2]$ qmake
[mehoggan@hogganz400 session2]$ cat Session2.pro
#-------------------------------------------------
#
# Project created by QtCreator 2011-10-21T09:32:55
#
#-------------------------------------------------
QT += core gui
TARGET = Session2
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
#Modify the path accordingly
CONFIG += debug_and_release
INCLUDEPATH += "/home/mehoggan/arcgis/runtime_sdk/qt10.1/SDK/include"
CONFIG(debug, debug|release) {
LIBS += -L"/home/mehoggan/arcgis/runtime_sdk/qt10.1/SDK/bin" \
-lArcGISQtd
} else {
LIBS += -L"/home/mehoggan/arcgis/runtime_sdk/qt10.1/SDK/bin" \
-lArcGISQt
}
[mehoggan@hogganz400 session2]$ make
make -f Makefile.Release
make[1]: Entering directory `/home/mehoggan/arcgis/runtime_sdk/qt10.1/SDK/workshops/session2'
g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/mkspecs/default -I. -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/include/QtCore -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/include/QtGui -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/include -I../../include -Irelease -o release/main.o main.cpp
g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/mkspecs/default -I. -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/include/QtCore -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/include/QtGui -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/include -I../../include -Irelease -o release/mainwindow.o mainwindow.cpp
/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/bin/moc -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/mkspecs/default -I. -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/include/QtCore -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/include/QtGui -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/include -I../../include -Irelease mainwindow.h -o release/moc_mainwindow.cpp
g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/mkspecs/default -I. -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/include/QtCore -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/include/QtGui -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/include -I../../include -Irelease -o release/moc_mainwindow.o release/moc_mainwindow.cpp
g++ -m64 -Wl,-O1 -Wl,-rpath,/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/lib -o Session2 release/main.o release/mainwindow.o release/moc_mainwindow.o -L/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/lib -L/home/mehoggan/arcgis/runtime_sdk/qt10.1/SDK/bin -lArcGISQt -lQtGui -lQtCore -lpthread
make[1]: Leaving directory `/home/mehoggan/arcgis/runtime_sdk/qt10.1/SDK/workshops/session2'
[mehoggan@hogganz400 session2]$ echo ${LD_LIBRARY_PATH}
/home/mehoggan/arcgis/runtime_sdk/qt10.1/ArcGISRuntime10.1/LocalServerLx/bin/wine/lib64:/home/mehoggan/arcgis/runtime_sdk/qt10.1/ArcGISRuntime10.1/LocalServerLx/bin/wine/lib64/wine:/home/mehoggan/arcgis/runtime_sdk/qt10.1/ArcGISRuntime10.1/LocalServerLx/bin/wine/lib64/wine/supp:/home/mehoggan/arcgis/runtime_sdk/qt10.1/ArcGISRuntime10.1/LocalServerLx/bin/wine/lib64:/home/mehoggan/arcgis/runtime_sdk/qt10.1/ArcGISRuntime10.1/LocalServerLx/bin/wine/lib64/wine:/home/mehoggan/arcgis/runtime_sdk/qt10.1/ArcGISRuntime10.1/LocalServerLx/bin/wine/lib64/wine/supp:
[mehoggan@hogganz400 session2]$ ./Session2
./Session2: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.14' not found (required by /home/mehoggan/arcgis/runtime_sdk/qt10.1/SDK/bin/libArcGISQt.so.1)
如果运行以下命令: export LD_LIBRARY_PATH=/usr/local/lib64:${LD_LIBRARY_PATH}; ./Session2
或在应用程序运行的 /etc/ld.so.conf.d 中设置 libstdc++ 编译版本的路径。
RHEL5 Box:
[mehoggan@hoggant35002 session2]$ ls -l
total 1852
-rw-rw-r-- 1 mehoggan mehoggan 189 Nov 3 15:21 main.cpp
-rw-rw-r-- 1 mehoggan mehoggan 845 Nov 3 15:21 mainwindow.cpp
-rw-rw-r-- 1 mehoggan mehoggan 288 Nov 3 15:21 mainwindow.h
-rw-rw-r-- 1 mehoggan mehoggan 649 Nov 3 15:21 Session2.pro
-rw-rw-r-- 1 mehoggan mehoggan 25151 Nov 3 15:51 Session2.pro.user
-rw-rw-r-- 1 mehoggan mehoggan 1847296 Nov 3 15:21 vc90.pdb
[mehoggan@hoggant35002 session2]$ qmake
[mehoggan@hoggant35002 session2]$ ls -l ./Session2.pro
-rw-rw-r-- 1 mehoggan mehoggan 649 Nov 3 15:21 ./Session2.pro
[mehoggan@hoggant35002 session2]$ cat ./Session2.pro
#-------------------------------------------------
#
# Project created by QtCreator 2011-10-21T09:32:55
#
#-------------------------------------------------
QT += core gui
TARGET = Session2
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
#Modify the path accordingly
CONFIG += debug_and_release
INCLUDEPATH += "/home/mehoggan/arcgis/runtime_sdk/qt10.1/SDK/include"
CONFIG(debug, debug|release) {
LIBS += -L"/home/mehoggan/arcgis/runtime_sdk/qt10.1/SDK/bin" \
-lArcGISQtd
} else {
LIBS += -L"/home/mehoggan/arcgis/runtime_sdk/qt10.1/SDK/bin" \
-lArcGISQt
}
[mehoggan@hoggant35002 session2]$ make
make -f Makefile.Release
make[1]: Entering directory `/home/mehoggan/arcgis/runtime_sdk/qt10.1/SDK/workshops/session2'
g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/mkspecs/default -I. -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/include/QtCore -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/include/QtGui -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/include -I../../include -Irelease -o release/main.o main.cpp
g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/mkspecs/default -I. -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/include/QtCore -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/include/QtGui -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/include -I../../include -Irelease -o release/mainwindow.o mainwindow.cpp
/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/bin/moc -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/mkspecs/default -I. -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/include/QtCore -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/include/QtGui -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/include -I../../include -Irelease mainwindow.h -o release/moc_mainwindow.cpp
g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/mkspecs/default -I. -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/include/QtCore -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/include/QtGui -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/include -I../../include -Irelease -o release/moc_mainwindow.o release/moc_mainwindow.cpp
g++ -m64 -Wl,-O1 -Wl,-rpath,/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/lib -o Session2 release/main.o release/mainwindow.o release/moc_mainwindow.o -L/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/lib -L/home/mehoggan/arcgis/runtime_sdk/qt10.1/SDK/bin -lArcGISQt -lQtGui -lQtCore -lpthread
/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/lib/libQtGui.so: undefined reference to `FT_Library_SetLcdFilter'
/home/mehoggan/arcgis/runtime_sdk/qt10.1/SDK/bin/libArcGISQt.so: undefined reference to `std::_List_node_base::_M_unhook()@GLIBCXX_3.4.14'
/home/mehoggan/arcgis/runtime_sdk/qt10.1/SDK/bin/libArcGISQt.so: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long)@GLIBCXX_3.4.9'
/home/mehoggan/arcgis/runtime_sdk/qt10.1/SDK/bin/libArcGISQt.so: undefined reference to `std::_List_node_base::_M_hook(std::_List_node_base*)@GLIBCXX_3.4.14'
/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/lib/libQtGui.so: undefined reference to `FcFreeTypeQueryFace'
/home/mehoggan/arcgis/runtime_sdk/qt10.1/SDK/bin/libArcGISQt.so: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::basic_ostream<char, std::char_traits<char> >::_M_insert<double>(double)@GLIBCXX_3.4.9'
/home/mehoggan/arcgis/runtime_sdk/qt10.1/SDK/bin/libArcGISQt.so: undefined reference to `std::ctype<char>::_M_widen_init() const@GLIBCXX_3.4.11'
collect2: ld returned 1 exit status
make[1]: *** [Session2] Error 1
make[1]: Leaving directory `/home/mehoggan/arcgis/runtime_sdk/qt10.1/SDK/workshops/session2'
make: *** [release] Error 2
这是一篇非常长的文章,我想我已经提供了足够的内容来开始提供帮助。如果您需要任何具体帮助,请告诉我。
关于我链接的 libstdc++ 的最后一点信息。
RHEL6:
[mehoggan@hogganz400 session2]$ strings /usr/local/lib64/libstdc++.so.6 | grep GLIB
GLIBCXX_3.4
GLIBCXX_3.4.1
GLIBCXX_3.4.2
GLIBCXX_3.4.3
GLIBCXX_3.4.4
GLIBCXX_3.4.5
GLIBCXX_3.4.6
GLIBCXX_3.4.7
GLIBCXX_3.4.8
GLIBCXX_3.4.9
GLIBCXX_3.4.10
GLIBCXX_3.4.11
GLIBCXX_3.4.12
GLIBCXX_3.4.13
GLIBCXX_3.4.14
GLIBC_2.2.5
GLIBC_2.3
GLIBC_2.3.2
GLIBCXX_FORCE_NEW
GLIBCXX_DEBUG_MESSAGE_LENGTH
RHEL5:
[mehoggan@hoggant35002 session2]$ strings /usr/lib64/libstdc++.so.6 | grep GLIBC
GLIBCXX_3.4
GLIBCXX_3.4.1
GLIBCXX_3.4.2
GLIBCXX_3.4.3
GLIBCXX_3.4.4
GLIBCXX_3.4.5
GLIBCXX_3.4.6
GLIBCXX_3.4.7
GLIBCXX_3.4.8
GLIBC_2.3
GLIBC_2.3.2
GLIBC_2.4
GLIBC_2.2.5
GLIBCXX_FORCE_NEW
First the question:
I need a way without placing a config file in /etc/ld.so.conf.d to allow clients to build against my SDK on both RHEL5.7 and RHEL6.1 using the default install of gcc. Setting the LD_LIBRARY_PATH does not work in this case. Are there any other ways to allow clients to link against my sdk without having to provide them with a knowledge base article on how to configure their system? Please read below for clarification.
Second the senario:
I am responsible for the build of a runtime SDK on both RHEL5 and RHEL6. My RHEL5.7 box is a standard non-registered install as is my RHEL6.1 box. However, on my RHEL6 box I have compiled gcc myself:
[mehoggan@hoggant35002 ~]$ cat /etc/redhat-release; gcc --version
Red Hat Enterprise Linux Server release 5.7 (Tikanga)
gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-51)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOS
--
[mehoggan@hogganz400 session2]$ cat /etc/redhat-release; gcc --version
Red Hat Enterprise Linux Server release 6.1 (Santiago)
gcc (GCC) 4.5.2
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
--
I cannot provide the .so and .a files I am trying to link against. However, I will attempt to depict what is happening. Taking the same source and building it against my SDK and running it. I get the following results:
RHEL 6 Box:
[mehoggan@hogganz400 session2]$ ls -l
total 1848
-rw-rw-r-- 1 mehoggan mehoggan 189 Nov 3 13:02 main.cpp
-rw-rw-r-- 1 mehoggan mehoggan 845 Nov 3 13:02 mainwindow.cpp
-rw-rw-r-- 1 mehoggan mehoggan 288 Nov 3 13:02 mainwindow.h
-rwxrwxr-x 1 mehoggan mehoggan 25818 Nov 4 09:26 Session2
-rw-rw-r-- 1 mehoggan mehoggan 649 Nov 3 13:02 Session2.pro
-rw-rw-r-- 1 mehoggan mehoggan 1847296 Nov 3 13:02 vc90.pdb
[mehoggan@hogganz400 session2]$ qmake
[mehoggan@hogganz400 session2]$ cat Session2.pro
#-------------------------------------------------
#
# Project created by QtCreator 2011-10-21T09:32:55
#
#-------------------------------------------------
QT += core gui
TARGET = Session2
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
#Modify the path accordingly
CONFIG += debug_and_release
INCLUDEPATH += "/home/mehoggan/arcgis/runtime_sdk/qt10.1/SDK/include"
CONFIG(debug, debug|release) {
LIBS += -L"/home/mehoggan/arcgis/runtime_sdk/qt10.1/SDK/bin" \
-lArcGISQtd
} else {
LIBS += -L"/home/mehoggan/arcgis/runtime_sdk/qt10.1/SDK/bin" \
-lArcGISQt
}
[mehoggan@hogganz400 session2]$ make
make -f Makefile.Release
make[1]: Entering directory `/home/mehoggan/arcgis/runtime_sdk/qt10.1/SDK/workshops/session2'
g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/mkspecs/default -I. -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/include/QtCore -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/include/QtGui -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/include -I../../include -Irelease -o release/main.o main.cpp
g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/mkspecs/default -I. -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/include/QtCore -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/include/QtGui -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/include -I../../include -Irelease -o release/mainwindow.o mainwindow.cpp
/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/bin/moc -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/mkspecs/default -I. -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/include/QtCore -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/include/QtGui -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/include -I../../include -Irelease mainwindow.h -o release/moc_mainwindow.cpp
g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/mkspecs/default -I. -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/include/QtCore -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/include/QtGui -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/include -I../../include -Irelease -o release/moc_mainwindow.o release/moc_mainwindow.cpp
g++ -m64 -Wl,-O1 -Wl,-rpath,/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/lib -o Session2 release/main.o release/mainwindow.o release/moc_mainwindow.o -L/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/lib -L/home/mehoggan/arcgis/runtime_sdk/qt10.1/SDK/bin -lArcGISQt -lQtGui -lQtCore -lpthread
make[1]: Leaving directory `/home/mehoggan/arcgis/runtime_sdk/qt10.1/SDK/workshops/session2'
[mehoggan@hogganz400 session2]$ echo ${LD_LIBRARY_PATH}
/home/mehoggan/arcgis/runtime_sdk/qt10.1/ArcGISRuntime10.1/LocalServerLx/bin/wine/lib64:/home/mehoggan/arcgis/runtime_sdk/qt10.1/ArcGISRuntime10.1/LocalServerLx/bin/wine/lib64/wine:/home/mehoggan/arcgis/runtime_sdk/qt10.1/ArcGISRuntime10.1/LocalServerLx/bin/wine/lib64/wine/supp:/home/mehoggan/arcgis/runtime_sdk/qt10.1/ArcGISRuntime10.1/LocalServerLx/bin/wine/lib64:/home/mehoggan/arcgis/runtime_sdk/qt10.1/ArcGISRuntime10.1/LocalServerLx/bin/wine/lib64/wine:/home/mehoggan/arcgis/runtime_sdk/qt10.1/ArcGISRuntime10.1/LocalServerLx/bin/wine/lib64/wine/supp:
[mehoggan@hogganz400 session2]$ ./Session2
./Session2: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.14' not found (required by /home/mehoggan/arcgis/runtime_sdk/qt10.1/SDK/bin/libArcGISQt.so.1)
If I run the following command: export LD_LIBRARY_PATH=/usr/local/lib64:${LD_LIBRARY_PATH}; ./Session2
or set the path to the compiled version of libstdc++ in /etc/ld.so.conf.d the application runs.
RHEL5 Box:
[mehoggan@hoggant35002 session2]$ ls -l
total 1852
-rw-rw-r-- 1 mehoggan mehoggan 189 Nov 3 15:21 main.cpp
-rw-rw-r-- 1 mehoggan mehoggan 845 Nov 3 15:21 mainwindow.cpp
-rw-rw-r-- 1 mehoggan mehoggan 288 Nov 3 15:21 mainwindow.h
-rw-rw-r-- 1 mehoggan mehoggan 649 Nov 3 15:21 Session2.pro
-rw-rw-r-- 1 mehoggan mehoggan 25151 Nov 3 15:51 Session2.pro.user
-rw-rw-r-- 1 mehoggan mehoggan 1847296 Nov 3 15:21 vc90.pdb
[mehoggan@hoggant35002 session2]$ qmake
[mehoggan@hoggant35002 session2]$ ls -l ./Session2.pro
-rw-rw-r-- 1 mehoggan mehoggan 649 Nov 3 15:21 ./Session2.pro
[mehoggan@hoggant35002 session2]$ cat ./Session2.pro
#-------------------------------------------------
#
# Project created by QtCreator 2011-10-21T09:32:55
#
#-------------------------------------------------
QT += core gui
TARGET = Session2
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
#Modify the path accordingly
CONFIG += debug_and_release
INCLUDEPATH += "/home/mehoggan/arcgis/runtime_sdk/qt10.1/SDK/include"
CONFIG(debug, debug|release) {
LIBS += -L"/home/mehoggan/arcgis/runtime_sdk/qt10.1/SDK/bin" \
-lArcGISQtd
} else {
LIBS += -L"/home/mehoggan/arcgis/runtime_sdk/qt10.1/SDK/bin" \
-lArcGISQt
}
[mehoggan@hoggant35002 session2]$ make
make -f Makefile.Release
make[1]: Entering directory `/home/mehoggan/arcgis/runtime_sdk/qt10.1/SDK/workshops/session2'
g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/mkspecs/default -I. -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/include/QtCore -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/include/QtGui -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/include -I../../include -Irelease -o release/main.o main.cpp
g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/mkspecs/default -I. -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/include/QtCore -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/include/QtGui -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/include -I../../include -Irelease -o release/mainwindow.o mainwindow.cpp
/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/bin/moc -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/mkspecs/default -I. -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/include/QtCore -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/include/QtGui -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/include -I../../include -Irelease mainwindow.h -o release/moc_mainwindow.cpp
g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/mkspecs/default -I. -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/include/QtCore -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/include/QtGui -I/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/include -I../../include -Irelease -o release/moc_mainwindow.o release/moc_mainwindow.cpp
g++ -m64 -Wl,-O1 -Wl,-rpath,/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/lib -o Session2 release/main.o release/mainwindow.o release/moc_mainwindow.o -L/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/lib -L/home/mehoggan/arcgis/runtime_sdk/qt10.1/SDK/bin -lArcGISQt -lQtGui -lQtCore -lpthread
/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/lib/libQtGui.so: undefined reference to `FT_Library_SetLcdFilter'
/home/mehoggan/arcgis/runtime_sdk/qt10.1/SDK/bin/libArcGISQt.so: undefined reference to `std::_List_node_base::_M_unhook()@GLIBCXX_3.4.14'
/home/mehoggan/arcgis/runtime_sdk/qt10.1/SDK/bin/libArcGISQt.so: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long)@GLIBCXX_3.4.9'
/home/mehoggan/arcgis/runtime_sdk/qt10.1/SDK/bin/libArcGISQt.so: undefined reference to `std::_List_node_base::_M_hook(std::_List_node_base*)@GLIBCXX_3.4.14'
/home/mehoggan/QtSDK/Desktop/Qt/474/gcc/lib/libQtGui.so: undefined reference to `FcFreeTypeQueryFace'
/home/mehoggan/arcgis/runtime_sdk/qt10.1/SDK/bin/libArcGISQt.so: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::basic_ostream<char, std::char_traits<char> >::_M_insert<double>(double)@GLIBCXX_3.4.9'
/home/mehoggan/arcgis/runtime_sdk/qt10.1/SDK/bin/libArcGISQt.so: undefined reference to `std::ctype<char>::_M_widen_init() const@GLIBCXX_3.4.11'
collect2: ld returned 1 exit status
make[1]: *** [Session2] Error 1
make[1]: Leaving directory `/home/mehoggan/arcgis/runtime_sdk/qt10.1/SDK/workshops/session2'
make: *** [release] Error 2
This is getting to be a really long post, and I think I have provided enough to start helping. Please let me know if you need anything specific to help.
One last bit of information on the libstdc++ I am linking against.
RHEL6:
[mehoggan@hogganz400 session2]$ strings /usr/local/lib64/libstdc++.so.6 | grep GLIB
GLIBCXX_3.4
GLIBCXX_3.4.1
GLIBCXX_3.4.2
GLIBCXX_3.4.3
GLIBCXX_3.4.4
GLIBCXX_3.4.5
GLIBCXX_3.4.6
GLIBCXX_3.4.7
GLIBCXX_3.4.8
GLIBCXX_3.4.9
GLIBCXX_3.4.10
GLIBCXX_3.4.11
GLIBCXX_3.4.12
GLIBCXX_3.4.13
GLIBCXX_3.4.14
GLIBC_2.2.5
GLIBC_2.3
GLIBC_2.3.2
GLIBCXX_FORCE_NEW
GLIBCXX_DEBUG_MESSAGE_LENGTH
RHEL5:
[mehoggan@hoggant35002 session2]$ strings /usr/lib64/libstdc++.so.6 | grep GLIBC
GLIBCXX_3.4
GLIBCXX_3.4.1
GLIBCXX_3.4.2
GLIBCXX_3.4.3
GLIBCXX_3.4.4
GLIBCXX_3.4.5
GLIBCXX_3.4.6
GLIBCXX_3.4.7
GLIBCXX_3.4.8
GLIBC_2.3
GLIBC_2.3.2
GLIBC_2.4
GLIBC_2.2.5
GLIBCXX_FORCE_NEW
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来您的 Qt 库(libQtGui.so 和 libArcGISQt.so)依赖于 GLIBCXX_3.4.14,而您的 RHEL 5 机器上不存在该依赖项,可能是因为您在 RHEL 6 机器上构建并安装了它 (Qt)。您需要在 RHEL 5 上构建 Qt,或者提供对 RHEL 5 机器上更新的 3.4.14 库的访问。任何想要运行您的二进制文件的人都需要访问其构建所针对的共享库的正确版本。
为了“访问”库,它需要在相关计算机上可读,并且位于 ld.so.conf 中配置的位置、应用程序运行时的 LD_LIBRARY_PATH envvar 中,或者配置为通过 -rpath 链接选项的可执行文件。
我发现对于避免/处理此问题非常有用的一个链接选项是
-Wl,-rpath,'$ORIGIN'
。这将导致应用程序查找包含动态库可执行文件的目录以及(并优先于)ld.so.conf。因此,您可以构建一个可执行文件,并向人们提供一个包含可执行文件和一堆 .so 动态库的包,并告诉他们“要么在您的计算机上安装 .so 文件,要么将它们全部放在与可执行文件相同的目录中,无论您喜欢哪种”然后他们就可以运行可执行文件而不会遇到太多麻烦。这允许单个二进制包可以在几乎任何 Linux 变体上使用。请注意,当您将此选项放入 Makefile 中时,通常需要为
-Wl,-rpath,'$$ORIGIN'
,因为 make 会将$
视为变量扩展($$
扩展为$
)。 qmake 可能是一样的。It looks like your Qt libraries (libQtGui.so and libArcGISQt.so) have a dependency on GLIBCXX_3.4.14, which is not present on your RHEL 5 box, probably as you built and installed it (Qt) on your RHEL 6 box. You need to build Qt on RHEL 5, or provide access to the updated 3.4.14 lib on the RHEL 5 box. Anyone who wants to run your binary will need access to the correct versions of the shared libraries it was built against.
In order to have 'access' to a library, it needs to be readable on the machine in question and be in a location that is either configured in ld.so.conf, in the LD_LIBRARY_PATH envvar at the app is run, OR configured into the executable via a -rpath link option.
One linking option I find EXTREMELY useful for avoiding/dealing with this issue is
-Wl,-rpath,'$ORIGIN'
. This will cause the application to look in the directory containing the executable for dynamic libs as well as (and in preference to) ld.so.conf. So you can build an executable and give people a package with the executable and a bunch of .so dynamic libs and tell them "either install the .so files on your machine or stick them all in the same directory as the executable, whichever you prefer" and then they can run the executable without too much trouble. This allows for a single binary package that can be used on pretty much any linux variant.Note that when you put this option in a Makefile it generally needs to be
-Wl,-rpath,'$$ORIGIN'
as make will treat the$
as a variable expansion ($$
expands to$
). qmake may be the same.