关于在macos catalina 平台上编译boos_1_67_0版本所遇到的问题

macos系统升级到catalina后,我的c++编译开发环境遇到了诸多的问题。花费了我两天的工作时间来解决。
现在将我遇到的问题做个描述,并记录下解决方法:希望能帮助到其他人。

1.boost_1_67_0版本
在我的环境上我尝了使用不同的clang版本来编译boost_1_67_0版本,发现clang-11以上版本都不能正确编译通过。向下试到clang-9才编译通过。
boost_1_67_0版本,使用clang-9编译输出如下:
clang-darwin.compile.c++ bin.v2/libs/test/build/clang-darwin-9.0.1/release/link-static/threading-multi/execution_monitor.o
clang-darwin.compile.c++ bin.v2/libs/test/build/clang-darwin-9.0.1/release/link-static/threading-multi/debug.o
clang-darwin.compile.c++ bin.v2/libs/test/build/clang-darwin-9.0.1/release/link-static/threading-multi/cpp_main.o
clang-darwin.archive bin.v2/libs/test/build/clang-darwin-9.0.1/release/link-static/threading-multi/libboost_prg_exec_monitor.a

#################################################################################################################
#使用clang-12使用boost67遇到的问题
error: No best alternative for libs/context/build/asm_sources
next alternative: required properties: <abi>aapcs <address-model>32 <architecture>arm <binary-format>elf <threading>multi <toolset>clang
not matched
next alternative: required properties: <abi>aapcs <address-model>32 <architecture>arm <binary-format>elf <threading>multi <toolset>gcc
not matched
#################################################################################################################

 

关于macos catalina如何安装clang编译环境,这里总结我的几点做法。
1.到clang官方开源网站上下载源代码,进行编译安装。
作为一个软件开发者,这类方法是我最喜欢的。但不幸的是遇到不了问题,直到目前我还是没有能解决。

2.安装苹果提供的command-line-tool开发包。
macos系统升级到catalina后,不再默认安装command-line-tool.如果要使用苹果官方发问的clang编译环境,需要用户自己去下面的官网下载需要的clang版本。
https://developer.apple.com/download/more/
这种做法有个好处是,可以安装到苹果发布的clang的最新发行版本。比如说brew只能选到clang-11版本,而通过本方法能安装clang-12版本。

这个安装方法,安装好后,编译代码时总是遇到找不到c++标准系统头文件的问题。

#################################################################################################################
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:328:7: error: no member named \’isgreaterequal\’ in the global namespace; did you mean \’::std::greater_equal\’?
using ::isgreaterequal;
^~
/usr/local/opt/llvm/bin/../include/c++/v1/functional:771:29: note: \’::std::greater_equal\’ declared here
struct _LIBCPP_TEMPLATE_VIS greater_equal : binary_function<_Tp, _Tp, bool>
^
In file included from libs/serialization/src/xml_wgrammar.cpp:146:
In file included from libs/serialization/src/basic_xml_grammar.ipp:30:
In file included from ./boost/spirit/include/classic_numerics.hpp:11:
In file included from ./boost/spirit/home/classic/core/primitives/numerics.hpp:18:
In file included from ./boost/spirit/home/classic/core/primitives/impl/numerics.ipp:13:
In file included from ./boost/config/no_tr1/cmath.hpp:21:
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:329:9: error: no member named \’isless\’ in the global namespace
using ::isless;
~~^
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:330:9: error: no member named \’islessequal\’ in the global namespace
using ::islessequal;
~~^
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:331:9: error: no member named \’islessgreater\’ in the global namespace
using ::islessgreater;
~~^
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:332:9: error: no member named \’isunordered\’ in the global namespace
using ::isunordered;
~~^
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:333:9: error: no member named \’isunordered\’ in the global namespace
using ::isunordered;
#################################################################################################################
解决方法是,切换使用低版本的clang进行编译,比如我使用clang-9编译通过。

 

./bootstrap.sh
Building Boost.Build engine with toolset clang…
Failed to build Boost.Build build engine
Consult \’bootstrap.log\’ for more details

打开日志查看到如下的详细信息:
###
###
### Using \’clang\’ toolset.
###
###
clang++ –version
Apple clang version 12.0.0 (clang-1200.0.32.2)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
###
###
clang++ -x c++ -O3 -std=c++11 -O3 -s -DNDEBUG builtins.cpp class.cpp command.cpp compile.cpp constants.cpp cwd.cpp debug.cpp debugger.cpp execcmd.cpp filesys.cpp frames.cpp function.cpp glob.cpp hash.cpp hcache.cpp hdrmacro.cpp headers.cpp jam.cpp jambase.cpp jamgram.cpp lists.cpp make.cpp make1.cpp md5.cpp mem.cpp modules.cpp native.cpp object.cpp option.cpp output.cpp parse.cpp pathsys.cpp regexp.cpp rules.cpp scan.cpp search.cpp strings.cpp subst.cpp sysinfo.cpp timestamp.cpp variable.cpp w32_getreg.cpp modules/order.cpp modules/path.cpp modules/property-set.cpp modules/regex.cpp modules/sequence.cpp modules/set.cpp execunix.cpp fileunix.cpp pathunix.cpp -o b2
In file included from builtins.cpp:7:
./jam.h:336:10: fatal error: \’sys/types.h\’ file not found
#include <sys/types.h>
^~~~~~~~~~~~~
1 error generated.
In file included from class.cpp:15:
In file included from ./rules.h:35:
./timestamp.h:21:10: fatal error: \’time.h\’ file not found
#include <time.h>
^~~~~~~~
1 error generated.
In file included from command.cpp:17:
./jam.h:336:10: fatal error: \’sys/types.h\’ file not found
#include <sys/types.h>
^~~~~~~~~~~~~
1 error generated.
In file included from compile.cpp

解决方法是:
在环境变量里加入下面的设置,指定clang-12所去使用的sdk目录。
export SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk

 

—————————————————————————–
交流QQ号:1175372067
电话:18551717618(同微信)
元几科技.软件3部
迈开步伐去探索
南京元几科技有限公司
元几社区: https://www.cnblogs.com/colin-vio
元几官网: http://www.yuanji.tech
—————————————————————————–

版权声明:本文为colin-vio原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/colin-vio/p/13904398.html