Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【Node.JS来一打C++扩展】node-gyp build失败 #81

Open
hushicai opened this issue Sep 21, 2019 · 0 comments
Open

【Node.JS来一打C++扩展】node-gyp build失败 #81

hushicai opened this issue Sep 21, 2019 · 0 comments

Comments

@hushicai
Copy link
Owner

hushicai commented Sep 21, 2019

Node.js: v6.9.4
node-gyp: 3.6.0
MacOS:10.14.5

按照书中的套路,先install头部文件,再configure生成构建文件,最后build时失败了:

gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | darwin | x64
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
  CXX(target) Release/obj.target/first/first.o
warning: include path for stdlibc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead
      [-Wstdlibcxx-not-found]
In file included from ../first.cpp:1:
In file included from /Users/hushicai/Library/Caches/node-gyp/6.9.4/include/node/node.h:42:
/Users/hushicai/Library/Caches/node-gyp/6.9.4/include/node/v8.h:21:10: fatal error: 'utility' file not found
#include <utility>
         ^~~~~~~~~
1 warning and 1 error generated.
make: *** [Release/obj.target/first/first.o] Error 1

从报错信息中可知,stdlibc++头部没找着,建议用libc++

这里有相关解决方案。

主要的问题在于:

In OS X 10.9, Apple switched from gcc to clang which results in a change in the name of the standard library name from libstdc++ (gcc) to libc++ (clang).

MacOS 10.14.5用clang,链接的c++头部应为libc++,而[email protected]链接的却是libstdc++,所以出错了。

最终解决方案:

export CXXFLAGS="-mmacosx-version-min=10.9" LDFLAGS="-mmacosx-version-min=10.9"

试了一下,[email protected]没有以上问题。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant