node.js - npm 安装期间 libssh2 中的 "C compiler cannot create executables"

标签 node.js npm libssh2 gcc4.9 nodegit

我在 npm install nodegit 期间遇到以下错误:

> <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="2c424348494b45586c1c021d19021d" rel="noreferrer noopener nofollow">[email protected]</a> preinstall /home/mhu/nodegit
> node lifecycleScripts/preinstall

[nodegit] Running pre-install script
[nodegit] npm@2 installed, pre-loading required packages
[nodegit] Configuring libssh2.
{ [Error: Command failed: /bin/sh -c /home/mhu/nodegit/vendor/libssh2/configure --with-libssl-prefix=/home/mhu/nodegit/vendor/openssl/openssl
configure: error: in `/home/mhu/nodegit/vendor/libssh2':
configure: error: C compiler cannot create executables
See `config.log' for more details
]
  killed: false,
  code: 77,
  signal: null,
  cmd: '/bin/sh -c /home/mhu/nodegit/vendor/libssh2/configure --with-libssl-prefix=/home/mhu/nodegit/vendor/openssl/openssl' }
configure: error: in `/home/mhu/nodegit/vendor/libssh2':
configure: error: C compiler cannot create executables
See `config.log' for more details

[nodegit] ERROR - Could not finish preinstall
{ [Error: Command failed: /bin/sh -c /home/mhu/nodegit/vendor/libssh2/configure --with-libssl-prefix=/home/mhu/nodegit/vendor/openssl/openssl
configure: error: in `/home/mhu/nodegit/vendor/libssh2':
configure: error: C compiler cannot create executables
See `config.log' for more details
]
  killed: false,
  code: 77,
  signal: null,
  cmd: '/bin/sh -c /home/mhu/nodegit/vendor/libssh2/configure --with-libssl-prefix=/home/mhu/nodegit/vendor/openssl/openssl' }

有人可以帮我解决这个问题吗?是否是因为权限问题导致 C 编译器无法创建可执行文件?

我的环境:

操作系统:centos-release-6-8.el6.centos.12.3.x86_64

海湾合作委员会:4.9.1

openssl:openssl-1.0.1e-48.el6.x86_64

libssh2:libssh2-1.4.2-2.el6_7.1.x86_64

Node :v4.4.7

npm:2.15.8

gcc -v 给出:

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/packages/encap/gcc-4.9.1/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.9.1/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-4.9.1/configure --enable-languages=c,c++,fortran --enable-shared --disable-libstdcxx-pch --enable-lto --enable-libgomp --enable-__cxa_atexit --enable-tls --with-gmp --with-mpfr --with-mpc --with-libelf
Thread model: posix
gcc version 4.9.1 (GCC)

这是/home/mhu/nodegit/vendor/libssh2 中 config.log 中给出错误的部分:

configure:3429: $? = 0
configure:3418: gcc -v >&5
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/packages/encap/gcc-4.9.1/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.9.1/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-4.9.1/configure --enable-languages=c,c++,fortran --enable-shared --disable-libstdcxx-pch --enable-lto --enable-libgomp --enable-__cxa_atexit --enable-tls --with-gmp --with-mpfr --with-mpc --with-libelf
Thread model: posix
gcc version 4.9.1 (GCC)
configure:3429: $? = 0
configure:3418: gcc -V >&5
gcc: error: unrecognized command line option '-V'
gcc: fatal error: no input files
compilation terminated.
configure:3429: $? = 1
configure:3418: gcc -qversion >&5
gcc: error: unrecognized command line option '-qversion'
gcc: fatal error: no input files
compilation terminated.
configure:3429: $? = 1
configure:3449: checking whether the C compiler works
configure:3471: gcc  -I/home/mhu/nodegit/vendor/openssl/openssl/include  conftest.c  >&5
/usr/bin/ld: unrecognized option '-plugin'
/usr/bin/ld: use the --help option for usage information
collect2: error: ld returned 1 exit status
configure:3475: $? = 1
configure:3513: result: no
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "libssh2"
| #define PACKAGE_TARNAME "libssh2"
| #define PACKAGE_VERSION "-"
| #define PACKAGE_STRING "libssh2 -"
| #define PACKAGE_BUGREPORT "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="4c20252e3f3f247e6128293a29200c2f23232062242d3434623f29" rel="noreferrer noopener nofollow">[email protected]</a>"
| #define PACKAGE_URL ""
| #define PACKAGE "libssh2"
| #define VERSION "-"
| /* end confdefs.h.  */
|
| int
| main ()
| {
|
|   ;
|   return 0;
| }
configure:3518: error: in `/home/mhu/nodegit/vendor/libssh2':
configure:3520: error: C compiler cannot create executables
See `config.log' for more details

最佳答案

config.log 中,您的问题是:

/usr/bin/ld: unrecognized option '-plugin'

这似乎是一个不起眼的错误。 Stack Overflow 上的两个问题对此进行了讨论。最有希望的问题是How to fix “unrecognized option '-plugin`” when using gdc to compile D program? .

要在 Autotools(生成 config.log 等)中修复此问题,您需要执行以下操作:

export CPPFLAGS="-fno-use-linker-plugin"
export CFLAGS="-fno-use-linker-plugin"
export CXXFLAGS="-fno-use-linker-plugin"

然后,在 Autotools 世界中,您将:

./configure --with-libssl-prefix=/home/mhu/nodegit/vendor/openssl/openssl ...

有时您可以通过向编译器添加标志来逃脱:

export CC=gcc -fno-use-linker-plugin
export CXX=g++ -fno-use-linker-plugin

不幸的是,我的知识就到此为止了。我不知道你应该为 npm 做什么。这看起来像是要寻求答案的问题:How to pass options to dependent package installs?

关于node.js - npm 安装期间 libssh2 中的 "C compiler cannot create executables",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38751514/

相关文章:

node.js - 在 Node 中使用 aes-256-cbc 进行加密时出现无效 IV 长度错误

javascript - 如何在 Mongoose 中添加集合?

node.js - 使用 NPM 为私有(private)存储库添加版本号注释

php - 如何在 Linux Ubuntu Wheezy (raspbian) 上为 PHP7 安装 SSH2-Lib?

javascript - 在 Node 函数中进行数据库调用

version-control - 一次开发多个 npm 模块的方法(具有交叉依赖)

node.js - Hyperledger Explorer 安装失败

c++ - 尝试为 sshlib2 构建conf并收到错误

php - Stream_context_set_params 不适用于 ssh2.sftp 包装器

node.js - 用于提供私有(private)文件​​的 AWS S3 实现