【问题标题】:Can't install cocoapods on mavericks无法在 Mavericks 上安装 cocoapods
【发布时间】:2014-03-31 23:03:19
【问题描述】:

我在 Mavericks 上安装 gem motion-cocoapods 时遇到问题。我正在使用 ruby​​ 1.9.3-p484、OS X Mavericks、Xcode 5.1。

我找到了很多解决方案,但没有一个有效。

这是我尝试安装时的错误日志

checking for -std=c99 option to compiler... yes
checking for CoreFoundation... no
checking for main() in -lCoreFoundation... no
CoreFoundation is needed to build the Xcodeproj C extension.
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

xcode/mkmf.log 文件

checking for -std=c99 option to compiler... -------------------- yes

"/usr/local/opt/gcc46/bin/gcc-4.6 -o conftest -I/Users/**/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1/x86_64-darwin13.1.0 -I/Users/**/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1/ruby/backward -I/Users/**/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include  -fno-common -pipe conftest.c  -L. -L/Users/**/.rvm/rubies/ruby-1.9.3-p484/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -L.  -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib      -lruby.1.9.1  -lpthread -ldl -lobjc "
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */

"/usr/local/opt/gcc46/bin/gcc-4.6 -I/Users/**/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1/x86_64-darwin13.1.0 -I/Users/**/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1/ruby/backward -I/Users/**/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include  -fno-common -pipe  -std=c99 -c conftest.c"
checked program was:
/* begin */
1: #include "ruby.h"
/* end */

--------------------

have_framework: checking for CoreFoundation... -------------------- no

"/usr/local/opt/gcc46/bin/gcc-4.6 -o conftest -I/Users/**/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1/x86_64-darwin13.1.0 -I/Users/**/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1/ruby/backward -I/Users/**/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include  -fno-common -pipe -std=c99 conftest.c  -L. -L/Users/**/.rvm/rubies/ruby-1.9.3-p484/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -L.  -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib      -lruby.1.9.1 -ObjC -framework CoreFoundation -lpthread -ldl -lobjc "
cc1: error: argument to '-O' should be a non-negative integer
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <CoreFoundation/CoreFoundation.h>
4: 
5: int main(void){return 0;}
/* end */

--------------------

have_library: checking for main() in -lCoreFoundation... -------------------- no

"/usr/local/opt/gcc46/bin/gcc-4.6 -o conftest -I/Users/**/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1/x86_64-darwin13.1.0 -I/Users/**/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1/ruby/backward -I/Users/**/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include  -fno-common -pipe -std=c99 conftest.c  -L. -L/Users/**/.rvm/rubies/ruby-1.9.3-p484/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -L.  -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib      -lruby.1.9.1 -lCoreFoundation  -lpthread -ldl -lobjc "
conftest.c: In function 't':
conftest.c:4:53: error: 'main' undeclared (first use in this function)
conftest.c:4:53: note: each undeclared identifier is reported only once for each function it appears in
checked program was:
/* begin */
 1: #include "ruby.h"
 2: 
 3: /*top*/
 4: int t() { void ((*volatile p)()); p = (void ((*)()))main; return 0; }
 5: int main(int argc, char **argv)
 6: {
 7:   if (argc > 1000000) {
 8:     printf("%p", &t);
 9:   }
10: 
11:   return 0;
12: }
/* end */

"/usr/local/opt/gcc46/bin/gcc-4.6 -o conftest -I/Users/**/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1/x86_64-darwin13.1.0 -I/Users/**/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1/ruby/backward -I/Users/**/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include  -fno-common -pipe -std=c99 conftest.c  -L. -L/Users/**/.rvm/rubies/ruby-1.9.3-p484/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -L.  -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib      -lruby.1.9.1 -lCoreFoundation  -lpthread -ldl -lobjc "
conftest.c: In function 't':
conftest.c:4:1: warning: implicit declaration of function 'main' [-Wimplicit-function-declaration]
ld: library not found for -lCoreFoundation
collect2: ld returned 1 exit status
checked program was:
/* begin */
 1: #include "ruby.h"
 2: 
 3: /*top*/
 4: int t() { main(); return 0; }
 5: int main(int argc, char **argv)
 6: {
 7:   if (argc > 1000000) {
 8:     printf("%p", &t);
 9:   }
10: 
11:   return 0;
12: }
/* end */

--------------------

这是我尝试过的一些解决方案

重新安装 Xcode 并指向它

xcode-select -p
/Applications/Xcode.app/Contents/Developer

运行以下命令 (command line tools for new 10.9 OSX for ruby gems?)

sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2

运行此命令 (https://github.com/CocoaPods/CocoaPods/issues/192)

CFLAGS="-F /System/Library/Frameworks" gem install motion-cocoapods -- --with-ldflags="-F/System/Library/Frameworks"

【问题讨论】:

  • mkmf.log文件的相关内容贴出来怎么样?
  • 你试过xcode-select --install 吗?
  • 我已经尝试过了,但我收到了以下错误can't install the software because it is not currently available from the software update server.。我找到了解决这个问题的方法,并从苹果开发者网站developer.apple.com/downloads/index.action?name=for%20Xcode%20- 单独下载了 xcode 命令行工具。我仍然遇到同样的错误
  • 我认为以下错误:cc1: error: argument to '-O' should be a non-negative integer 指的是-ObjC 标志。我不是 gcc 极客,所以我无法做出任何详细的推测。但是,我确实相信(直觉)这是命令行工具在某种程度上是错误的。抱歉,我不能更具体。

标签: ruby xcode cocoapods rubymotion


【解决方案1】:

我在 Mac OS 10.9、rvm 1.25.22、ruby-1.9.3-p484 上遇到了相同的症状,同时尝试运行 gem install cocoapods;问题是我同时安装了 gcc-4.6 和 gcc-4.2。

RVM 显然决定在我安装 ruby​​ 时自动为我运行 brew install gcc46

$ rvm install 1.9.3-p484
Checking requirements for osx.
Error: No available formula for gcc46 
Installing requirements for osx.
Updating system....
Installing required custom packages: homebrew/versions.
Installing required packages: gcc46...

我的 mkmf.log(和你的一样)显示编译使用 gcc-4.6 并且失败。我的解决方法是 brew uninstall gcc46rvm uninstall 1.9.3-p484,然后是 brew install apple-gcc42rvm install 1.9.3-p484

使用从 apple-gcc42 构建的新 ruby​​,并且在我的系统上没有留下任何 gcc46 痕迹,gem install cocoapods 工作。无需其他卸载或重新安装。

【讨论】:

    猜你喜欢
    • 2014-04-18
    • 1970-01-01
    • 1970-01-01
    • 2020-09-10
    • 2017-06-16
    • 2021-03-24
    • 1970-01-01
    • 2014-04-20
    • 2014-10-05
    相关资源
    最近更新 更多