c++ - 在 Linux 上编译没有问题时,如何在 Mac 上正确编译 C++?
问题描述
我正在使用其他人编写的在 Linux 上成功编译的 C++ 项目。在我将它克隆到 Mac 并执行“制作”后,它给出了这个错误:
clang: error: unknown argument: '-mpreferred-stack-boundary=4'
make: *** [all] Error 1
在我的 Mac 上,我安装了 g++。然后我从 Makefile 中删除 -mpreferred-stack-boundary=4 选项:
$(CC) $(CFLAGS) -mpreferred-stack-boundary=4 -mstackrealign -o ${NAME}.so $(SEGSRC) $(CFILE)
这些是 Makefile 中的一些定义:
CC = /usr/bin/g++
CFLAGS = -D_ChaiScriptON -g -w -O0 -fPIC -shared -std=c++11
'c++11' 是否意味着我应该在我的 Mac 上安装 c++11?我已经安装了 g++。
我尝试从命令中删除 -mpreferred-stack-boundary=4 ,然后我给出了这个错误:
./CObjectRecognizer/include/commonsFun.h:15:10: fatal error: 'io.h' file not found
#include <io.h>
^~~~~~
1 error generated.
'io.h' 是否来自标准 c 库?
解决方案
C++11
is a version of C++. Unless your version of g++ is extremely old it will support C++11 without problems.
<io.h>
is a non-standard header file. You should remove it, but unfortunately it's presence might mean that the code you are trying to compile is also non-standard. In which case you may have trouble getting the code to work in a different environment.
EDIT clang should have no trouble with C++11 either.
推荐阅读
- octave - 八度错误:返回列表中未定义的元素
- pandas - 如何将数据框中的多个条目合并为一个条目,Python
- ios - iphone x中的UICollection标头已满
- flutter - Flutter中,如何解决`AnimatedCrossFade`低效设计?
- ajax - Django:Ajas 和反向错误:“str”对象不可调用
- javascript - 在不支持 JQuery 的浏览器上获取 HTML5 必填字段
- elasticsearch - [created_utc] 之后的 Elasticsearch [match] 未知令牌 [START_OBJECT]
- image - 求卫星图API
- vba - Excel VBA 运行时错误“424”需要对象
- javascript - NextJs - next.config.js - CSS 加载器 + 自定义 Webpack 配置