"C编译器不能创建可执行文件".在npm安装期间在libssh2中 [英] "C compiler cannot create executables" in libssh2 during npm install

查看:162
本文介绍了"C编译器不能创建可执行文件".在npm安装期间在libssh2中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在npm安装 nodegit 时出现以下错误:

I got the following error during npm install of nodegit:

> nodegit@0.15.1 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编译器能够创建可执行文件?

Can someone help me with this? Is it because a permission issue that caused the C compiler to bot able to create executables?

我的环境:

os:centos-release-6-8.el6.centos.12.3.x86_64

gcc:4.9.1

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

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

节点: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中出现错误的部分:

Here is the part in config.log in /home/mhu/nodegit/vendor/libssh2 that gives error:

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 "libssh2-devel@cool.haxx.se"
| #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'

这似乎是一个模糊的错误.它在有关堆栈溢出的两个问题中进行了讨论.最有前途的问题是在使用gdc编译D程序时如何修复无法识别的选项-plugin"?.

This appears to be an obscure error. Its discussed in two questions on Stack Overflow. The most promising question is How to fix "unrecognized option '-plugin`" when using gdc to compile D program?.

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

To fix this in Autotools (which produces config.log and friends), you need to do the following:

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

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

Then, in the Autotools world, you would:

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

有时您可以不添加标志到编译器:

You can sometimes get away with adding the flag to the compiler:

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

不幸的是,这就是我的知识结束的地方.我不知道您应该为 npm 做些什么.看起来像是要寻求答案的问题:如何将选项传递给依赖的软件包安装程序?

Unfortunately, that's where my knowledge ends. I don't know what you should do for npm. This looks like the question to turn to for the answer: How to pass options to dependent package installs?

这篇关于"C编译器不能创建可执行文件".在npm安装期间在libssh2中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆