没有找到C编译器,但是已经安装了GCC。

时间:2022-04-14 07:03:57

I have a fresh install of a Slackware64 14.0 on a dedicate server and I'm having a hard time to compile nginx.

我在专用服务器上安装了一个新安装的Slackware64 .0,我很难编译nginx。

./configure (my options)

returns

返回

checking for OS
 + Linux 3.10.23-xxxx-std-ipv6-64 x86_64
checking for C compiler ... not found

./configure: error: C compiler cc is not found

but gcc is installed, as this is what gcc -v returns:

但是gcc已经安装了,因为这是gcc -v的回报:

Reading specs from /usr/lib64/gcc/x86_64-slackware-linux/4.7.1/specs
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-slackware-linux/4.7.1/lto-wrapper
Target: x86_64-slackware-linux
Configured with: ../gcc-4.7.1/configure --prefix=/usr --libdir=/usr/lib64 --mandir=/usr/man --infodir=/usr/info --enable-shared --enable-bootstrap --enable-languages=ada,c,c++,fortran,go,java,lto,objc --enable-threads=posix --enable-checking=release --enable-objc-gc --with-system-zlib --with-python-dir=/lib64/python2.7/site-packages --disable-libunwind-exceptions --enable-__cxa_atexit --enable-libssp --enable-lto --with-gnu-ld --verbose --enable-java-home --with-java-home=/usr/lib64/jvm/jre --with-jvm-root-dir=/usr/lib64/jvm --with-jvm-jar-dir=/usr/lib64/jvm/jvm-exports --with-arch-directory=amd64 --with-antlr-jar=/home/slackware/slackbuilds/gcc/antlr-runtime-3.4.jar --enable-multilib --target=x86_64-slackware-linux --build=x86_64-slackware-linux --host=x86_64-slackware-linux
Thread model: posix
gcc version 4.7.1 (GCC) 

What I tried (after googling)

我试过(谷歌搜索之后)

"/tmp is mounted with noexec."
Indeed it was, as part of my hardening configurations. I changed it and reboot to make sure, now my /etc/fstab looks like this:

“/tmp与noexec安装。”事实上,这是我硬化结构的一部分。我改变了它,重新启动以确保,现在我的/etc/fstab是这样的:

# <file system> <mount point>   <type>  <options>   <dump>  <pass>
/dev/md1    /   ext4    errors=remount-ro,discard   0   1
/dev/md2    /home   ext4    defaults,discard    1   2
/dev/md5    /var/www    ext4    defaults,discard    1   2
/dev/md6    /var/log    ext4    defaults,discard    1   2
/dev/md7    /tmp    ext4    defaults,discard,nodev,nosuid   1   2
/dev/md8    /var/lib/mysql  ext4    defaults,discard    1   2
/dev/sda3   swap    swap    defaults    0   0
/dev/sdb3   swap    swap    defaults    0   0
proc            /proc   proc    defaults        0       0
sysfs           /sys    sysfs   defaults        0       0
/tmp            /var/tmp none   rw,nosuid,nodev,bind    0   0

The new fstab without noexec does not work though. (I even tried with explicit exec)

但是,没有noexec的新fstab并不起作用。(我甚至尝试过显式exec)

"gcc is not on your $PATH"
It is.

“gcc不是在你的$PATH上”它是。

whereis gcc
gcc: /usr/bin/gcc /usr/lib64/gcc /usr/X11R6/bin/gcc /usr/bin/X11/gcc /usr/X11/bin/gcc /usr/libexec/gcc /usr/man/man1/gcc.1.gz /usr/share/man/man1/gcc.1.gz /usr/X11/man/man1/gcc.1.gz

echo $PATH
/usr/local/sbin:/usr/local/bin:/sbin:/usr/sbin:/bin:/usr/bin

Other things I did:

其他的事情我做了:

Looking nginx configure file, they make use of a CC var. This CC did not exist.

看nginx配置文件,他们使用CC var。这个CC不存在。

CC=/usr/bin/gcc

This did not work too.

这也不起作用。

I tried compiling another program from source to make sure this is not nginx problem, and I found something interesting maybe:

我尝试从源代码编译另一个程序以确保这不是nginx的问题,我发现了一些有趣的东西:

By trying to compile htop, I got this:

通过编译htop,我得到了这个:

./configure 

checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/home/napster/htop-master':
configure: error: C compiler cannot create executables
See `config.log' for more details

Which is expected, because even though I have a minimal installation without most deveveloper tools, the gcc is found. This error should be solved by installing the required tool.

这是意料之中的,因为即使我安装了一个没有大多数deveveloper工具的最小安装,gcc也被发现了。这个错误应该通过安装所需的工具来解决。

I even checked symbolic links on /usr/bin to make sure gcc and cc are ok:

我甚至在/usr/bin上检查了符号链接,以确保gcc和cc可以:

ls -l /usr/bin

cc -> gcc
gcc -> gcc-4.7.1

Any ideas?
Thanks in advance.

什么好主意吗?提前谢谢。

2 个解决方案

#1


0  

What are the contents of the 'config.log' file?

配置的内容是什么?日志的文件吗?

Most likely you're picking up some bad CFLAGS or LDFLAGS somewhere -- possibly in the config script or from nginx/htop defaults.

很可能是在某个地方(可能是配置脚本或nginx/htop默认值)中找到一些坏的CFLAGS或LDFLAGS。

CFLAGS and LDFLAGS are options passed to the compiler's command line. If they're invalid then the compiler won't run.

CFLAGS和LDFLAGS是传递给编译器命令行的选项。如果它们无效,编译器就不会运行。

The same symptom could result if you're missing a basic library that nginx/htop needs and the LDFLAG that specifies that is causing gcc to bail out.

如果您丢失了nginx/htop需要的基本库和指定导致gcc退出的LDFLAG,同样的症状也会出现。

You really need to check the config.log file.

您确实需要检查配置。日志文件。

#2


-3  

I think maybe it is the permission problem. I use sudo ./configure it will be OK.

我想可能是权限问题。我用sudo ./configure可以。

#1


0  

What are the contents of the 'config.log' file?

配置的内容是什么?日志的文件吗?

Most likely you're picking up some bad CFLAGS or LDFLAGS somewhere -- possibly in the config script or from nginx/htop defaults.

很可能是在某个地方(可能是配置脚本或nginx/htop默认值)中找到一些坏的CFLAGS或LDFLAGS。

CFLAGS and LDFLAGS are options passed to the compiler's command line. If they're invalid then the compiler won't run.

CFLAGS和LDFLAGS是传递给编译器命令行的选项。如果它们无效,编译器就不会运行。

The same symptom could result if you're missing a basic library that nginx/htop needs and the LDFLAG that specifies that is causing gcc to bail out.

如果您丢失了nginx/htop需要的基本库和指定导致gcc退出的LDFLAG,同样的症状也会出现。

You really need to check the config.log file.

您确实需要检查配置。日志文件。

#2


-3  

I think maybe it is the permission problem. I use sudo ./configure it will be OK.

我想可能是权限问题。我用sudo ./configure可以。