我如何编译OS X 64B平台与stdlibc提升++? [英] How do I compile boost for OS X 64b platforms with stdlibc++?

查看:205
本文介绍了我如何编译OS X 64B平台与stdlibc提升++?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编译升压为Mac OS X 10.9,与stdlibc ++。我运行下面的命令:

  ./ B2线程=多链接=静态运行时链接=静态CXXFLAGS = -  STDLIB = ++的libstdcLINKFLAGS = -  STDLIB = ++的libstdc

构建成功完成;但是,我的应用程序构建失败,在连接时,当它不能找到符号作为吸的std :: __ 1 ::区域:: use_facet,性病:: __ 1 :: basic_string的等相关细节还有就是__1,我相信。

我的问题是,我该如何编译提升为OSX 64B平台与stdlibc ++?

更多信息:

我在编译过程中注意到以下日志:


  

/Applications/X$c$c.app/Contents/Developer/Toolchains/X$c$cDefault.xctoolchain/usr/bin/ranlib:文件: bin.v2/libs/filesystem/build/clang-darwin-4.2.1/release/link-static/runtime-link-static/threading-multi/libboost_filesystem.a(windows_file_$c$ccvt.o)没有符号



解决方案

下载升压1.55,使用自举:

  ./ bootstrap.sh  -  preFIX =的/ usr /本地/ boost155 CXXFLAGS = - 拱i386的-arch x86_64的\\
    地址模型= 32_64线程=多的MacOS版本= 10.8舞台

使用内置:

  ./ B2线程=多链接=静态运行时链接=静态\\
    CXXFLAGS = - STDLIB = ++的libstdcLINKFLAGS = - STDLIB = ++的libstdc

收益率 libboost_chrono.a

  U的标准::字符串:: _众议员:: _ M_destroy(性病::分配器<焦炭>常量和放大器;)
     ü标准::字符串:: _众议员:: _ S_empty_rep_storage
     ü标准::字符串::追加(字符常量*,无符号长)
     ü标准::字符串::追加(标准::字符串常量和放大器;)
     ü标准::字符串::分配(字符常量*,无符号长)
     ü的std :: basic_string的<焦炭,的std :: char_traits<焦炭>中的std ::分配器<&烧焦GT; > :: basic_string的(字符常量*,性病::分配器<&烧焦GT;常量和放大器;)
     ü的std :: basic_string的<焦炭,的std :: char_traits<焦炭>中的std ::分配器<&烧焦GT; > :: basic_string的(标准::字符串常量和放大器;)

这意味着该库是用选项 -stdlib = ++的libstdc 建造 - 这是对C ++运行时的GNU版本链接即

我们使用清除编译:

 找到。 -name \\ *○-print0。| xargs的-0 RM
找 。 。-name \\ *一个-print0 | xargs的-0 RM

如果我们不这样做,那么它不重建,和你以前一样结束了相同的code。下一步,我们建立使用:

  ./ B2线程=多链接=静态运行时链接=静态\\
    CXXFLAGS = - STDLIB = libc中++LINKFLAGS = - STDLIB = libc中++

收益率 libboost_chrono.a

 ü的std :: __ 1 :: basic_string的<焦炭,性病:: __ 1 :: char_traits<焦炭>中的std :: __ 1 ::分配器<焦炭> > ::追加(字符常量*)
     ü的std :: __ 1 :: basic_string的<焦炭,性病:: __ 1 :: char_traits<焦炭>中的std :: __ 1 ::分配器<焦炭> > ::追加(字符常量*,无符号长)
     ü的std :: __ 1 :: basic_string的<焦炭,性病:: __ 1 :: char_traits<焦炭>中的std :: __ 1 ::分配器<焦炭> > ::分配(字符常量*)
     ü的std :: __ 1 :: basic_string的<焦炭,性病:: __ 1 :: char_traits<焦炭>中的std :: __ 1 ::分配器<焦炭> > :: basic_string的(STD :: __ 1 :: basic_string的<焦炭,性病:: __ 1 :: char_traits<焦炭>中的std :: __ 1 ::分配器<焦炭>>常量和放大器;)
     ü的std :: __ 1 :: basic_string的<焦炭,性病:: __ 1 :: char_traits<焦炭>中的std :: __ 1 ::分配器<焦炭> > :: basic_string的〜()

这意味着它的建成对的libc ++

这可以通过使用一个简单的测试C ++程序(以指示联)进行验证:

 的#include<串GT;INT
主(INT ARGC,字符** argv的)
{
    性病::字符串s(的Hello World);
    返回0;
}$化妆测试
C ++ TEST.CPP -o测试
$纳米./test | C ++ FILT
                 ü的std :: __ 1 :: basic_string的<焦炭,性病:: __ 1 :: char_traits<焦炭>中的std :: __ 1 ::分配器<焦炭> > :: __的init(字符常量*,无符号长)
                 ü的std :: __ 1 :: basic_string的<焦炭,性病:: __ 1 :: char_traits<焦炭>中的std :: __ 1 ::分配器<焦炭> > :: basic_string的〜()$ RM测试
$使测试CXXFLAGS = -stdlib = ++的libstdc
C ++ -stdlib = ++的libstdc TEST.CPP -o测试
$纳米./test | C ++ FILT
                 ü的std :: basic_string的<焦炭,的std :: char_traits<焦炭>中的std ::分配器<&烧焦GT; > :: basic_string的(字符常量*,性病::分配器<&烧焦GT;常量和放大器;)
                 ü的std :: basic_string的<焦炭,的std :: char_traits<焦炭>中的std ::分配器<&烧焦GT; > :: basic_string的〜()

所以,是的,它的相关标志进行编译。它所做的表示你必须通过 -stdlib = ++的libstdc 所有你,如果你用X code编译5,因为它现在默认使用 -stdlib = ++的libc 。这意味着任何 C ++依赖于 C ++ STDLIB你依赖也使用相同的标志进行编译。

根据库

小心提升的的增量的构建 - 如果你不清除的.o .A 文件,他们没有得到基于改变的标志,这使该文件作为编译,所以,如果他们被编译错误,那么你遇到问题重新编译。

I would like to compile boost for Mac OS X 10.9, with stdlibc++. I run the following command:

./b2 threading=multi link=static runtime-link=static cxxflags="-stdlib=libstdc++" linkflags="-stdlib=libstdc++"

The build completes successfully; however, my application build fails at linkage time, when it can't find symbols suck as std::__1::locale::use_facet, std::__1::basic_string etc. The pertinent detail there is the __1, I believe.

My question is, how do I compile boost for OSX 64b platforms with stdlibc++?

More info:

I have noticed the following logs during compilation:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: bin.v2/libs/filesystem/build/clang-darwin-4.2.1/release/link-static/runtime-link-static/threading-multi/libboost_filesystem.a(windows_file_codecvt.o) has no symbols

解决方案

Downloaded Boost 1.55, bootstrapped using:

./bootstrap.sh --prefix=/usr/local/boost155 cxxflags="-arch i386 -arch x86_64" \
    address-model=32_64 threading=multi macos-version=10.8 stage

Built using:

./b2 threading=multi link=static runtime-link=static \
    cxxflags="-stdlib=libstdc++" linkflags="-stdlib=libstdc++"

Yields in libboost_chrono.a:

     U std::string::_Rep::_M_destroy(std::allocator<char> const&)
     U std::string::_Rep::_S_empty_rep_storage
     U std::string::append(char const*, unsigned long)
     U std::string::append(std::string const&)
     U std::string::assign(char const*, unsigned long)
     U std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)
     U std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&)

Which implies that the library was built with the option -stdlib=libstdc++ - i.e. it's linked against the gnu version of the C++ runtime.

We purge the build using:

find . -name \*.o -print0 | xargs -0 rm
find . -name \*.a -print0 | xargs -0 rm

If we don't do that then it doesn't rebuild, and you end up with the same code as before. Next we build using:

./b2 threading=multi link=static runtime-link=static \
    cxxflags="-stdlib=libc++" linkflags="-stdlib=libc++"

Yields in libboost_chrono.a:

     U std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::append(char const*)
     U std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::append(char const*, unsigned long)
     U std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::assign(char const*)
     U std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::basic_string(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)
     U std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::~basic_string()

Which implies that it's built against libc++.

This can be verified by using a simple test c++ program (to indicate the linking):

#include <string>

int
main(int argc, char **argv)
{
    std::string s("Hello World");
    return 0;
}

$ make test
c++     test.cpp   -o test
$ nm ./test | c++filt
                 U std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__init(char const*, unsigned long)
                 U std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::~basic_string()

$ rm test
$ make test CXXFLAGS=-stdlib=libstdc++
c++ -stdlib=libstdc++    test.cpp   -o test
$ nm ./test | c++filt
                 U std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)
                 U std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()

so yes, it's compiling with the relevant flag. What it does indicate that you have to pass the -stdlib=libstdc++ to everything you're compiling if you're using XCode 5 as it now defaults to using -stdlib=libc++. This means that any C++ based libraries that depend on c++ stdlib that you depend on also have to be compiled with the same flag.

Be careful with an incremental build of boost - if you don't purge the .o and .a files, they don't get recompiled based on the changed flags, which keeps the files as compiled, so if they were miscompiled then you encounter the problem.

这篇关于我如何编译OS X 64B平台与stdlibc提升++?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆