首先是问题:我需要一种无需在 /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 盒:
[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 盒子:
[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