macos系統升級到catalina后,我的c++編譯開發環境遇到了諸多的問題



關於在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
-----------------------------------------------------------------------------


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM