繁体   English   中英

是否可以使用Bundler安装gems并告诉它为特定的gem使用特定的编译器?

[英]Is it possible to install gems with Bundler and tell it to use a specific compiler for a specific gem?

我无法在运行Yosemite的新Mac上安装我的gem捆绑包,因为一个gem只与操作系统一起提供的C编译器一起安装,而另一个gem则需要Homebrew的C编译器。

我根本无法工作,仅仅是因为这个错误,据说是新的gcc版本4.9.1具有:

cc1: error: -Werror=shorten-64-to-32: no option -Wshorten-64-to-32

我不了解此错误的含义,也不了解如何告诉编译器忽略它。 甚至有可能

我的具体情况是在v8 gem上运行bundle install失败:

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

/Users/me/.rbenv/versions/2.1.0/bin/ruby extconf.rb 
creating Makefile
Compiling v8 for x64
Using python 2.7.6
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Unable to find a compiler officially supported by v8.
It is recommended to use GCC v4.4 or higher
Using compiler: g++
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Unable to find a compiler officially supported by v8.
It is recommended to use GCC v4.4 or higher
../src/cached-powers.cc:136:18: error: unused variable 'kCachedPowersLength' [-Werror,-Wunused-const-variable]
static const int kCachedPowersLength = ARRAY_SIZE(kCachedPowers);

XCode的新版本附带的g++编译器将其指定为以下版本:

Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1

因此, 4.2已经很老了。 如果我可以配置一个gem来使用Homebrew gcc (即4.9.1)构建,我认为它会起作用。

我尝试将CCCXX变量设置为Homebrew gcc ,但是Nokogiri gem不会随上面的第一条错误消息一起安装。 优胜美地cc安装了更多的宝石,也许留下了最好的路线。 我不知道。

使用bundle config可以很好地传递编译器标志。 多一点信息将有助于为您提供更好的答案。

参见: http : //bundler.io/man/bundle-config.1.html

我刚刚发现: 如何在10.10优胜美地上安装therubyracer gem? 这将为您提供libv8,然后v8应该编译并进行gem安装。 在研究此问题时,我发现了优胜美地和clang / gcc等周围的大量问题,包括针对nokogiri的此修复程序: 在OSX 10.10 Yosemite上安装Nokogiri

基本上,从我收集的数据来看,优胜美地gcc编译器已经过时(原始错误表示编译器无法识别给定的编译选项,即该功能在gcc 4.2中不存在)。 我认为最好的解决方案是通过自制程序和设置路径等安装更新的gcc,因此gem安装仅使用自制程序版本。

希望这些链接有所帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM