从源代码安装 ruby​​ 并遇到 gcc 问题

从源代码安装 ruby​​ 并遇到 gcc 问题

我正在尝试遵循本指南在 Snow Leopard 上编译 Ruby、RubyGems 和 Rails我遇到了配置问题。

下载并提取源代码后,我运行命令来设置一些配置。

这是我得到的输出:

my-macbook-pro:ruby-1.9.1-p243 lillq$ ./configure --enable-shared --enable-pthread CFLAGS=-D_XOPEN_SOURCE=1
checking build system type... i386-apple-darwin10.0.0
checking host system type... i386-apple-darwin10.0.0
checking target system type... i386-apple-darwin10.0.0
checking for gcc... gcc
checking for C compiler default output file name... 
configure: error: in `/Users/lillq/src/ruby-1.9.1-p243':
configure: error: C compiler cannot create executables
See `config.log' for more details.

注意:第一次运行此程序时找不到 gcc。为了解决这个问题,我在路径中添加了 /Xcode3.1.4/usr/bin 和 sbin。

然后我决定检查我是否可以编译代码。(这是一台新电脑,我之前没有在上面编译过,而且我最近安装了 Xcode)

my-macbook-pro:~ lillq$ gcc test.c
test.c:1:19: error: stdio.h: No such file or directory
test.c: In function ‘main’:
test.c:5: warning: incompatible implicit declaration of built-in function ‘printf’

唔...

我以为 Xcode 应该能为我正确安装编译器。我是不是遗漏了什么或做错了什么?

谢谢-

答案1

在 XCode 安装期间,还有一个选项可以将工具安装在标准 unix 位置(/usr/bin 中的二进制文件、/usr/include 中的包含文件等)。您在安装期间选择了该选项吗?

我猜测错误是因为编译器在这些标准路径中搜索头文件(以及标准库)但无法找到它们。

相关内容