无法在小牛上安装cocoapods

时间:2014-03-31 23:03:19

标签: ruby xcode cocoapods rubymotion

我在小牛队安装宝石动作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&amp;指向它

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"

1 个答案:

答案 0 :(得分:1)

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

当我安装ruby时,RVM显然决定自动为我运行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制作的新鲜红宝石,并且我的系统上没有留下gcc46的痕迹,gem install cocoapods起作用。不需要其他卸载或重新安装。