【发布时间】:2014-12-02 10:46:22
【问题描述】:
我正在尝试在 Centos 7 机器上安装 rose compiler infrastructure。通常我会纠缠玫瑰编译器邮件列表上的人,但我相信问题出在 boost 库上。
首先,rose 有一些严格的构建要求
- gcc,版本 4.0 到 4.4.x(含)
- gfortran,版本 4.2.x 到 4.4.x(含)
- boost,版本 1.36.0 到 1.45.0(含)
问题在于,Centos 7 附带的 gcc 正常版本是 4.8.2 版,而 boost 库的正常版本是 1.53 .... 所以它对我来说是重新编译地狱 :)。
所以,我下载了 gcc-4.4.7 的源代码并编译它 /opt/gcc447。我确实运行了测试套件并获得了预期的通过次数和失败次数,因此我确信编译器工具链正在工作。
我还下载了 boost-1.45 的源代码,构建并安装到 /opt/boost-1.45 中。
现在,运行 rose 的配置脚本时出现此错误:
CC=gcc44 CXX=g++44 ../rose/configure --prefix=/home/******/bin/rose --with-boost=/opt/boost-1.45.0
checking for ROSE Git version information in '../rose'... 9a977c899a09c17903dd3005b88ae7d2c06bfacf 1377627277
Configuring ROSE, version 0.9.5a (9a977c899a09c17903dd3005b88ae7d2c06bfacf)
....
In ROSE/configure: ac_boost_path = /opt/boost-1.45.0
checking for GraphViz's dot program in path... yes
checking whether the Boost::Thread library is available... no
checking whether the Boost::Date_Time library is available... yes
checking for toupper in -lboost_date_time... no
checking for toupper in -lboost_date_time... (cached) no
checking for toupper in -lboost_date_time... (cached) no
configure: error: Could not link against boost_date_time !
在进行正常检查时,我确保 libboost_data_time.so.1.45.0 存在(确实存在),它是正确的文件类型,并且权限不可靠。查看 config.log,我发现:
configure:13690: g++44 -o conftest -I/opt/boost-1.45.0/include -L/opt/boost-1.45.0/lib conftest.cpp -lboost_date_time >&5
/opt/boost-1.45.0/lib/libboost_date_time.so: undefined reference to `std::out_of_range::~out_of_range()@GLIBCXX_3.4.15'
collect2: ld returned 1 exit status
configure:13690: $? = 1
configure: failed program was:
| #ifdef __cplusplus
| extern "C"
| #endif
| char toupper ();
| int main ()
| {
| return toupper ();
| ;
| return 0;
| }
因此,我复制了失败的程序(将其命名为 toupper_test.cpp)并尝试先使用默认编译器进行编译:
[******@broadsword rose-build]$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.2/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.2-20140120/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.2-20140120/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.8.2 20140120 (Red Hat 4.8.2-16) (GCC)
[******@broadsword rose-build]$ g++ -o toupper1 -I/opt/boost-1.45.0/include -L/opt/boost-1.45.0/lib toupper_test.cpp -lboost_date_time
[******@broadsword rose-build]$
并且测试程序编译成功,但是尝试使用 4.4.7 版本的 gcc 进行编译会产生:
[******@broadsword rose-build]$ /opt/gcc447/bin/g++44 -v
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-4.4.7/configure --prefix=/opt/gcc447 --program-suffix=44 --enable-languages=c,c++,objc,java,fortran --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --disable--libunwind-exceptions
Thread model: posix
gcc version 4.4.7 (GCC)
[******@broadsword rose-build]$ /opt/gcc447/bin/g++ -o toupper2 -I/opt/boost-1.45.0/include -L/opt/boost-1.45.0/lib toupper_test.cpp -lboost_date_time
bash: /opt/gcc447/bin/g++: No such file or directory
[******@broadsword rose-build]$ /opt/gcc447/bin/g++44 -o toupper2 -I/opt/boost-1.45.0/include -L/opt/boost-1.45.0/lib toupper_test.cpp -lboost_date_time
/opt/boost-1.45.0/lib/libboost_date_time.so: undefined reference to `std::out_of_range::~out_of_range()@GLIBCXX_3.4.15'
collect2: ld returned 1 exit status
编译失败。
所以,当我意识到我用默认编译器编译了 boost 之后,我并没有太惊讶,但我似乎无法用 4.4 版本的编译器编译 boost..我尝试了很多东西;
- 在用户配置文件中设置gcc的版本
- 在项目配置文件中设置gcc的版本
- 试图在命令行上设置环境变量 CC 和 CXX(好吧..我在这里绝望了)
- 创建从 /opt/gcc447/bin/gcc47 到 /opt/gcc47/bin/gcc 的符号链接(以及其他程序),并确保 /opt/gcc447/bin/ 位于路径的首位李>
迄今为止没有任何效果。
我没有想法在这里尝试...有人有建议或提示吗?
谢谢!
【问题讨论】:
-
你能补充更多关于 boost 编译的信息吗?比如你创建user-config.jam,你在那个文件里写什么?之后你运行“./b2”,你给它什么选项,比如“toolset=”?
-
boost 的初始构建是通过命令序列
./bootstrap.sh --prefix=.....; ./bjam --prefix=.....完成的,之后我尝试在不同的文件中添加使用行using gcc ; 4.4.7 ; /opt/gcc447/bin/g++ ;.... (1) user-config.jam; (2) project-config.jam 和 (3) tools/build/v2/user-config.jam(参见stackoverflow.com/questions/7240635/…)。我也厌倦了 SO 问题的各种答案中建议的几个命令行选项(目前找不到链接)。
标签: c++ boost rose-compiler-framework