簡體   English   中英

編譯boost C ++ 11 clang mac找不到cstddef

[英]Compile boost C++11 clang mac cannot find cstddef

我無法使用Mac OS x 10.8.2上的clang 3.1編譯boost。

這就是我做的:

./bootstrap.sh --with-toolset=clang
./b2 toolset=clang cxxflags="-std=c++11 -stdlib=libc++" linkflags="-stdlib=libc++"

我也試過沒有計時,測試,波動和信號。 我嘗試了一個user-config.jam

using clang-darwin

這是我幾乎每個文件都有的錯誤:

/boost/config/select_stdlib_config.hpp:18:12: fatal error: 'cstddef' file not found

它有點類似於如何用clang ++ / libc ++編譯/鏈接Boost?

謝謝 :-)

更新:我確實安裝了最新的Xcode 4.5.2並安裝了命令行工具。

這是控制台輸出的一部分:

Kikohs:trunk kikohs$ ./b2 toolset=clang cxxflags="-std=c++11 -stdlib=libc++" linkflags="-stdlib=libc++"
Performing configuration checks

- 32-bit                   : no
- 64-bit                   : yes
- x86                      : yes
- has_icu builds           : no
warning: Graph library does not contain MPI-based parallel components.
note: to enable them, add "using mpi ;" to your user-config.jam
    - gcc visibility           : yes
    - long double support      : no
warning: skipping optional Message Passing Interface (MPI) library.
note: to enable MPI support, add "using mpi ;" to user-config.jam.
note: to suppress this message, pass "--without-mpi" to bjam.
note: otherwise, you can safely ignore this message.

構建Boost C ++庫。

- iconv (libc)             : no
- iconv (separate)         : yes
- icu                      : no
- icu (lib64)              : no

組件配置:

- atomic                   : building
- chrono                   : building
- context                  : building
- date_time                : building
- exception                : building
- filesystem               : building
- graph                    : building
- graph_parallel           : building
- iostreams                : building
- locale                   : building
- math                     : building
- mpi                      : building
- program_options          : building
- python                   : building
- random                   : building
- regex                    : building
- serialization            : building
- signals                  : building
- system                   : building
- test                     : building
- thread                   : building
- timer                    : building
- wave                     : building

...patience...
...patience...
...patience...
...patience...
...found 8672 targets...
...updating 1127 targets...
common.mkdir bin.v2/libs/atomic
common.mkdir bin.v2/libs/atomic/build
common.mkdir bin.v2/libs/atomic/build/clang-darwin-4.2.1
common.mkdir bin.v2/libs/atomic/build/clang-darwin-4.2.1/debug
clang-darwin.compile.c++ bin.v2/libs/atomic/build/clang-darwin-4.2.1/debug/lockpool.o
In file included from libs/atomic/src/lockpool.cpp:1:
./boost/atomic.hpp:10:10: fatal error: 'cstddef' file not found
#include <cstddef>
     ^
1 error generated.

"clang++" -x c++ -O0 -g -std=c++11 -stdlib=libc++ -O0 -fno-inline -Wall -g -DBOOST_ALL_NO_LIB=1 -DBOOST_ATOMIC_DYN_LINK=1 -DBOOST_ATOMIC_SOURCE -I"." -c -o "bin.v2/libs/atomic/build/clang-darwin-4.2.1/debug/lockpool.o" "libs/atomic/src/lockpool.cpp"

看起來您忘了在clang旁邊安裝libc ++標頭。

如果您不想安裝標題,請嘗試Apple分發的clang版本作為Command Line Tools包的一部分; 它已通過更多測試,並且已經正確設置。

幾個小時后我終於解決了我的問題。

Homebrew正在弄亂我的路徑,由於某種原因,我的clang找不到libc ++頭文件。

有一個錯誤是提升1.52。

請參閱Boost數字限制錯誤

我不得不編輯文件:

boost/config/stdlib/libcpp.hpp

並修補它:

#if _LIBCPP_VERSION < 1002 
#   define BOOST_NO_CXX11_NUMERIC_LIMITS 
#endif 

現在提升正在建設......

對於Ubuntu 16.04,我可以使用gcc使用c ++ 11構建boost:

cd / home / user / install / boost / boost_1_54 /

./bootstrap.sh --with-toolset = gcc

./b2 toolset = gcc cxxflags =“ - std = c ++ 11 -I / usr / include / c ++ / 5 / -I / usr / include / x86_64-linux-gnu / c ++ / 5 /”

mkdir ../2

./b2 install --prefix = .. / 2 /

構建程序的命令:

g ++ -std = c ++ 11 -O2 fprint.cpp -o fprint -I / home / user / install / boost / 2 / include / -L / home / user / install / boost / 2 / lib / -lboost_regex -lboost_program_options

在此之前,命令是:

g ++ -std = c ++ 11 fprint.cpp -o fprint -lboost_regex -lboost_program_options

,但是這個舊的命令(在以前的操作系統和boost / etc之前運行良好)不再起作用,說錯誤“未定義引用boost :: re_detail_106501”(由/tmp/cc0Zn8lo.o說:在函數`bool boost: :regex_search ...)

((如果我不使用“-I / usr / include / c ++ / 5 / -I / usr / include / x86_64-linux-gnu / c ++ / 5 /”for ./b2,那么錯誤是“不能找到cstddef“在構建提升期間,所以與此票證的主題完全相同))

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM