【问题标题】:changed default gcc version, now compiling problems更改了默认 gcc 版本,现在编译问题
【发布时间】:2015-10-13 14:54:03
【问题描述】:

对于安装,我必须更改我的默认 gcc 编译器版本。我使用的版本有一些编译问题,所以我通过 macports 下载了其他几个版本,其中一个最终可以用于我的安装。

我几乎可以确定我之前使用的是 gcc4.2,在我的端口中列为:llvm-gcc42。

在另外两种情况下,我现在面临 c++ 文件的编译问题。我不了解 c++,我使用编译器只是为了编译一些 - 主要是 node.js - 模块,或者现在,一个原子编辑器的包。

这是我得到的,这导致我假设 c++ 编译器的某些内容不正确:

cc1plus:错误:无法识别的命令行选项“-std=gnu++0x”

在第一种情况下,我可以通过更改默认 gcc 版本来摆脱这种情况。但我不能每次都尝试几个版本。

那么:我应该使用哪个 gcc 版本,或者还有其他可能导致这种情况的原因吗? gcc5,最新的也一样..


在特定情况下:安装 termrk(原子编辑器的模块)时出现问题

gcc --version
gcc (MacPorts gcc5 5.2.0_0) 5.2.0
[...]

有两种方法可以安装 atom 包:在编辑器中使用 gui 和使用命令行工具 apm。两者都不起作用,但我收到不同的错误消息。

1.在 gui 内:

> pty.js@0.2.13 install /private/var/folders/nl/2ppbw8fn0cjbw04pdqbxmqtr0000gn/T/apm-install-dir-115913-1105-1g6fykw/node_modules/Termrk/node_modules/pty.js
> node-gyp rebuild

  CXX(target) Release/obj.target/pty/src/unix/pty.o

cc1plus: error: unrecognized command line option "-std=gnu++0x"
make: *** [Release/obj.target/pty/src/unix/pty.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Applications/Atom.app/Contents/Resources/app/apm/node_modules/npm/node_modules/node-gyp/lib/build.js:269:23)
gyp ERR! stack     at ChildProcess.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:820:12)
gyp ERR! System Darwin 12.6.0
gyp ERR! command "node" "/Applications/Atom.app/Contents/Resources/app/apm/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /private/var/folders/nl/2ppbw8fn0cjbw04pdqbxmqtr0000gn/T/apm-install-dir-115913-1105-1g6fykw/node_modules/Termrk/node_modules/pty.js
gyp ERR! node -v v0.10.40
gyp ERR! node-gyp -v v2.0.2
gyp ERR! not ok 
npm ERR! Darwin 12.6.0
npm ERR! argv "/Applications/Atom.app/Contents/Resources/app/apm/bin/node" "/Applications/Atom.app/Contents/Resources/app/apm/node_modules/npm/bin/npm-cli.js" "--globalconfig" "/Users/michael/.atom/.apm/.apmrc" "--userconfig" "/Users/michael/.atom/.apmrc" "install" "/private/var/folders/nl/2ppbw8fn0cjbw04pdqbxmqtr0000gn/T/d-115913-1105-1hg4ytj/package.tgz" "--target=0.30.7" "--arch=x64"
npm ERR! node v0.10.40
npm ERR! npm  v2.13.3
npm ERR! code ELIFECYCLE

npm ERR! pty.js@0.2.13 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the pty.js@0.2.13 install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the pty.js package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls pty.js
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /private/var/folders/nl/2ppbw8fn0cjbw04pdqbxmqtr0000gn/T/apm-install-dir-115913-1105-1g6fykw/npm-debug.log

1.在终端:

~ michael$ sudo apm install termrk
Installing termrk to /Users/michael/.atom/packages ✗

> pty.js@0.2.13 install /private/tmp/apm-install-dir-115913-1063-2zj63h/node_modules/Termrk/node_modules/pty.js
> node-gyp rebuild


shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied
shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied

node.js:844
    var cwd = process.cwd();
                      ^
Error: EACCES, permission denied
    at Function.startup.resolveArgv0 (node.js:844:23)
    at startup (node.js:58:13)
    at node.js:935:3
npm ERR! Darwin 12.6.0
npm ERR! argv "/Applications/Atom.app/Contents/Resources/app/apm/bin/node" "/Applications/Atom.app/Contents/Resources/app/apm/node_modules/npm/bin/npm-cli.js" "--globalconfig" "/Users/michael/.atom/.apm/.apmrc" "--userconfig" "/Users/michael/.atom/.apmrc" "install" "/private/tmp/d-115913-1063-1cgkfyq/package.tgz" "--target=0.30.7" "--arch=x64"
npm ERR! node v0.10.40
npm ERR! npm  v2.13.3
npm ERR! code ELIFECYCLE

npm ERR! pty.js@0.2.13 install: `node-gyp rebuild`
npm ERR! Exit status 8
npm ERR! 
npm ERR! Failed at the pty.js@0.2.13 install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the pty.js package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls pty.js
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /private/tmp/apm-install-dir-115913-1063-2zj63h/npm-debug.log

【问题讨论】:

  • 我想我会删除我的答案,因为它实际上没有什么意义。似乎 node-gyp 选择了旧版本的编译器。我对此一无所知,也无济于事。祝你好运!

标签: c++ node.js gcc atom-editor


【解决方案1】:

这是 GCC 5.2 的有效选项,所以如果它说它无法识别,则表示您没有使用 GCC 5.2。

您可能仍在使用旧的 GCC 4.2 版本进行编译。

【讨论】:

  • 有道理,但 gcc --version 告诉我 gcc (MacPorts gcc5 5.2.0_0) 5.2.0 。知道如何检查 node-gyp 是否使用正确的版本吗?
猜你喜欢
  • 2017-08-28
  • 1970-01-01
  • 2011-12-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-10-28
相关资源
最近更新 更多