1. 程式人生 > >Ubuntu 15.04 clang++ 3.6 編譯boost 1.59/1.55

Ubuntu 15.04 clang++ 3.6 編譯boost 1.59/1.55

clipboard data 3.6 target blank ger prefix apt-get data-

Ubuntu 15.04已經可以直接通過apt-get insall 安裝clang 3.6, 並且預裝的gcc版本是4.9.2。這些安裝過程在這裏介紹。

首先下載boost源碼

[plain] view plain copy print?
  1. wget -O boost.1.59.tar.bz2 http://sourceforge.net/projects/boost/files/latest/download?source=files


解壓

[plain] view plain copy print?
  1. tar jxvf ./boost.1.59.tar.bz2

指定clang工具,生成編譯腳本

[plain] view plain copy print?
  1. ./bootstrap.sh --with-libraries=system,filesystem,log,atomic,thread,program_options --with-toolset=clang

編譯並安裝

[plain] view plain copy print?
  1. ./b2 toolset=clang cxxflags="-std=c++11"
  2. sudo ./b2 install --prefix=/usr

等一會兒就好。

要註意的是,boost 1.59 似乎有問題,因為編譯安裝之後,我的一個簡單的使用boost log的程序編譯會報錯,錯誤如下:

[plain] view plain copy print?
  1. clang++ -g -std=c++11 -I../include -Wall -DBOOST_LOG_DYN_LINK -o
  2. ./object/main.cc.o -c ../src/main.cc In file included from
  3. ../src/main.cc:8: In file included from ../include/helper/logger.h:16:
  4. In file included from /usr/include/boost/log/sinks.hpp:25: In file
  5. included from /usr/include/boost/log/sinks/async_frontend.hpp:42: In
  6. file included from
  7. /usr/include/boost/log/sinks/unbounded_fifo_queue.hpp:29: In file
  8. included from /usr/include/boost/log/detail/event.hpp:25: In file
  9. included from /usr/include/boost/atomic/capabilities.hpp:18: In file
  10. included from /usr/include/boost/atomic/detail/platform.hpp:22:
  11. /usr/include/boost/atomic/detail/gcc-atomic.hpp:35:67: error: unknown
  12. type name ‘memory_order‘ BOOST_FORCEINLINE BOOST_CONSTEXPR int
  13. convert_memory_order_to_gcc(memory_order order) BOOST_NOEXCEPT
  14. /usr/include/boost/atomic/detail/gcc-atomic.hpp:37:22: error: use of
  15. undeclared identifier ‘memory_order_relaxed‘


當我降級到boost 1.55.0後,問題消失。

http://blog.csdn.net/csfreebird/article/details/48877657

Ubuntu 15.04 clang++ 3.6 編譯boost 1.59/1.55