Make 在 Mac 上失败
Make fails on Mac
我正在尝试使用 Makefile 制作我的项目。 Makefile 对其他 Mac 可以正常工作,但在我的情况下会出错。
输出结果如下:
CC kernel.cpp
In file included from kernel.cpp:13:
In file included from ./kernel.hpp:22:
In file included from /usr/local/include/Poco/JSON/Object.h:24:
In file included from /usr/local/include/Poco/JSON/Array.h:25:
In file included from /usr/local/include/Poco/Dynamic/Var.h:26:
In file included from /usr/local/include/Poco/Dynamic/VarHolder.h:24:
In file included from /usr/local/include/Poco/NumberFormatter.h:24:
In file included from /usr/local/include/Poco/NumericString.h:25:
In file included from /usr/local/include/Poco/FPEnvironment.h:35:
In file included from /usr/local/include/Poco/FPEnvironment_C99.h:25:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:313:9: error:
no member named 'signbit' in the global namespace
using ::signbit;
~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:314:9: error:
no member named 'fpclassify' in the global namespace
using ::fpclassify;
~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:315:9: error:
no member named 'isfinite' in the global namespace; did you mean 'finite'?
using ::isfinite;
~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/math.h:757:12: note:
'finite' declared here
extern int finite(double) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __M...
^
In file included from kernel.cpp:13:
In file included from ./kernel.hpp:22:
In file included from /usr/local/include/Poco/JSON/Object.h:24:
In file included from /usr/local/include/Poco/JSON/Array.h:25:
In file included from /usr/local/include/Poco/Dynamic/Var.h:26:
In file included from /usr/local/include/Poco/Dynamic/VarHolder.h:24:
In file included from /usr/local/include/Poco/NumberFormatter.h:24:
In file included from /usr/local/include/Poco/NumericString.h:25:
In file included from /usr/local/include/Poco/FPEnvironment.h:35:
In file included from /usr/local/include/Poco/FPEnvironment_C99.h:25:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:316:9: error:
no member named 'isinf' in the global namespace
using ::isinf;
~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:317:9: error:
no member named 'isnan' in the global namespace
using ::isnan;
~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:318:9: error:
no member named 'isnormal' in the global namespace
using ::isnormal;
~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:319:7: error:
no member named 'isgreater' in the global namespace; did you mean
'::std::greater'?
using ::isgreater;
^~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/functional:718:29: note:
'::std::greater' declared here
struct _LIBCPP_TEMPLATE_VIS greater : binary_function<_Tp, _Tp, bool>
^
In file included from kernel.cpp:13:
In file included from ./kernel.hpp:22:
In file included from /usr/local/include/Poco/JSON/Object.h:24:
In file included from /usr/local/include/Poco/JSON/Array.h:25:
In file included from /usr/local/include/Poco/Dynamic/Var.h:26:
In file included from /usr/local/include/Poco/Dynamic/VarHolder.h:24:
In file included from /usr/local/include/Poco/NumberFormatter.h:24:
In file included from /usr/local/include/Poco/NumericString.h:25:
In file included from /usr/local/include/Poco/FPEnvironment.h:35:
In file included from /usr/local/include/Poco/FPEnvironment_C99.h:25:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:320:7: error:
no member named 'isgreaterequal' in the global namespace; did you mean
'::std::greater_equal'?
using ::isgreaterequal;
^~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/functional:747:29: note:
'::std::greater_equal' declared here
struct _LIBCPP_TEMPLATE_VIS greater_equal : binary_function<_Tp, _Tp, bool>
^
makefile 已经在 Linux 平台上进行了测试,可以正常工作。
任何建议,我的 Mac c++ 配置有什么问题?
我正在使用 MacOS High Sierra(10.13) 和 Xcode v9.0.1
已编辑
这是编译命令:
gcc -pipe -x c++ -std=c++11 -fPIC -pedantic -W -Wall -Wwrite-strings -Wcast-align -Wcast-qual -Wpointer-arith -Wshadow -Wendif-labels -Wundef -Wfloat-equal -Werror -Wconversion -DPROJECT_VERSION="0.0.1" -DUSE_SDK="no" -g -g3 -ggdb3 -D__i386__=1 -D__ppc64__=0 -Wno-sign-conversion -Wno-conversion -Wno-float-equal -Wno-unused-parameter -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/include -I/usr/local/opt/openssl/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/c++/version -I/git/p2p/inc -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/c++/version src/kernel.cpp -o /git/p2p/obj/kernel.o
升级你的包:
$ brew update
$ brew upgrade
随着 XCode 的更新,它可以得到修复。
而不是 运行ning gcc -x c++
我推荐你 运行 g++
或者,在 MacOS 上更好,clang++
.
此外,您的编译行似乎缺少 -c
选项,该选项会告诉编译器生成一个 object 文件;否则它将尝试 link 你的文件并创建一个可执行文件。
我还觉得很奇怪,你在编译行中添加了 -D__i386__
和 -D__ppc64__
:这些通常是由你的操作系统定义的系统宏,而不是在命令行中提供编译器。
另一个潜在的问题是为什么您使用 -I
显式地将系统 header 文件目录添加到您的编译行。编译器将自己添加这些,并使用适当的配置。系统 header 通常需要格外小心,以正确的顺序等
如果您更改到正确的目录并且 运行 从您的 shell 提示:
clang++ -pipe -std=c++11 -fPIC -pedantic -W -Wall -Wwrite-strings \
-Wcast-align -Wcast-qual -Wpointer-arith -Wshadow -Wendif-labels \
-Wundef -Wfloat-equal -Werror -Wconversion -DPROJECT_VERSION="0.0.1" \
-DUSE_SDK="no" -g -g3 -ggdb3 -Wno-sign-conversion -Wno-conversion \
-Wno-float-equal -Wno-unused-parameter -I/usr/local/include \
-I/usr/local/opt/openssl/include -I/git/p2p/inc \
-c -o /git/p2p/obj/kernel.o src/kernel.cpp
编译正确吗?
我正在尝试使用 Makefile 制作我的项目。 Makefile 对其他 Mac 可以正常工作,但在我的情况下会出错。
输出结果如下:
CC kernel.cpp
In file included from kernel.cpp:13:
In file included from ./kernel.hpp:22:
In file included from /usr/local/include/Poco/JSON/Object.h:24:
In file included from /usr/local/include/Poco/JSON/Array.h:25:
In file included from /usr/local/include/Poco/Dynamic/Var.h:26:
In file included from /usr/local/include/Poco/Dynamic/VarHolder.h:24:
In file included from /usr/local/include/Poco/NumberFormatter.h:24:
In file included from /usr/local/include/Poco/NumericString.h:25:
In file included from /usr/local/include/Poco/FPEnvironment.h:35:
In file included from /usr/local/include/Poco/FPEnvironment_C99.h:25:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:313:9: error:
no member named 'signbit' in the global namespace
using ::signbit;
~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:314:9: error:
no member named 'fpclassify' in the global namespace
using ::fpclassify;
~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:315:9: error:
no member named 'isfinite' in the global namespace; did you mean 'finite'?
using ::isfinite;
~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/math.h:757:12: note:
'finite' declared here
extern int finite(double) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __M...
^
In file included from kernel.cpp:13:
In file included from ./kernel.hpp:22:
In file included from /usr/local/include/Poco/JSON/Object.h:24:
In file included from /usr/local/include/Poco/JSON/Array.h:25:
In file included from /usr/local/include/Poco/Dynamic/Var.h:26:
In file included from /usr/local/include/Poco/Dynamic/VarHolder.h:24:
In file included from /usr/local/include/Poco/NumberFormatter.h:24:
In file included from /usr/local/include/Poco/NumericString.h:25:
In file included from /usr/local/include/Poco/FPEnvironment.h:35:
In file included from /usr/local/include/Poco/FPEnvironment_C99.h:25:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:316:9: error:
no member named 'isinf' in the global namespace
using ::isinf;
~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:317:9: error:
no member named 'isnan' in the global namespace
using ::isnan;
~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:318:9: error:
no member named 'isnormal' in the global namespace
using ::isnormal;
~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:319:7: error:
no member named 'isgreater' in the global namespace; did you mean
'::std::greater'?
using ::isgreater;
^~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/functional:718:29: note:
'::std::greater' declared here
struct _LIBCPP_TEMPLATE_VIS greater : binary_function<_Tp, _Tp, bool>
^
In file included from kernel.cpp:13:
In file included from ./kernel.hpp:22:
In file included from /usr/local/include/Poco/JSON/Object.h:24:
In file included from /usr/local/include/Poco/JSON/Array.h:25:
In file included from /usr/local/include/Poco/Dynamic/Var.h:26:
In file included from /usr/local/include/Poco/Dynamic/VarHolder.h:24:
In file included from /usr/local/include/Poco/NumberFormatter.h:24:
In file included from /usr/local/include/Poco/NumericString.h:25:
In file included from /usr/local/include/Poco/FPEnvironment.h:35:
In file included from /usr/local/include/Poco/FPEnvironment_C99.h:25:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:320:7: error:
no member named 'isgreaterequal' in the global namespace; did you mean
'::std::greater_equal'?
using ::isgreaterequal;
^~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/functional:747:29: note:
'::std::greater_equal' declared here
struct _LIBCPP_TEMPLATE_VIS greater_equal : binary_function<_Tp, _Tp, bool>
^
makefile 已经在 Linux 平台上进行了测试,可以正常工作。 任何建议,我的 Mac c++ 配置有什么问题?
我正在使用 MacOS High Sierra(10.13) 和 Xcode v9.0.1
已编辑
这是编译命令:
gcc -pipe -x c++ -std=c++11 -fPIC -pedantic -W -Wall -Wwrite-strings -Wcast-align -Wcast-qual -Wpointer-arith -Wshadow -Wendif-labels -Wundef -Wfloat-equal -Werror -Wconversion -DPROJECT_VERSION="0.0.1" -DUSE_SDK="no" -g -g3 -ggdb3 -D__i386__=1 -D__ppc64__=0 -Wno-sign-conversion -Wno-conversion -Wno-float-equal -Wno-unused-parameter -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/include -I/usr/local/opt/openssl/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/c++/version -I/git/p2p/inc -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/c++/version src/kernel.cpp -o /git/p2p/obj/kernel.o
升级你的包:
$ brew update
$ brew upgrade
随着 XCode 的更新,它可以得到修复。
而不是 运行ning gcc -x c++
我推荐你 运行 g++
或者,在 MacOS 上更好,clang++
.
此外,您的编译行似乎缺少 -c
选项,该选项会告诉编译器生成一个 object 文件;否则它将尝试 link 你的文件并创建一个可执行文件。
我还觉得很奇怪,你在编译行中添加了 -D__i386__
和 -D__ppc64__
:这些通常是由你的操作系统定义的系统宏,而不是在命令行中提供编译器。
另一个潜在的问题是为什么您使用 -I
显式地将系统 header 文件目录添加到您的编译行。编译器将自己添加这些,并使用适当的配置。系统 header 通常需要格外小心,以正确的顺序等
如果您更改到正确的目录并且 运行 从您的 shell 提示:
clang++ -pipe -std=c++11 -fPIC -pedantic -W -Wall -Wwrite-strings \
-Wcast-align -Wcast-qual -Wpointer-arith -Wshadow -Wendif-labels \
-Wundef -Wfloat-equal -Werror -Wconversion -DPROJECT_VERSION="0.0.1" \
-DUSE_SDK="no" -g -g3 -ggdb3 -Wno-sign-conversion -Wno-conversion \
-Wno-float-equal -Wno-unused-parameter -I/usr/local/include \
-I/usr/local/opt/openssl/include -I/git/p2p/inc \
-c -o /git/p2p/obj/kernel.o src/kernel.cpp
编译正确吗?