簡體   English   中英

如何在Mac OS X上安裝ruby-filemagic?

[英]How do I install ruby-filemagic on Mac OS X?

我發現了一些現存的問題,但這些問題中沒有一個起作用。

嘗試使用brew而非端口在Snow Leopard上安裝ruby-filemagic

在新的RHEL6服務器上安裝ruby-filemagic gem遇到困難

他們都指向此頁面作為答案

https://gist.github.com/eparreno/1845561

除了那也不起作用。 我仍然收到以下錯誤。

Building native extensions with: '--with-magic-include=/usr/local/include --with-magic-lib=/usr/local/lib/'
This could take a while...
ERROR:  Error installing ruby-filemagic:
    ERROR: Failed to build gem native extension.

    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb --with-magic-include=/usr/local/include --with-magic-lib=/usr/local/lib/
checking for main() in -lgnurx... no
checking for magic_open() in -lmagic... no
*** ERROR: missing required library to compile this module
*** 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.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
    --with-magic-dir
    --without-magic-dir
    --with-magic-include=${magic-dir}/include
    --with-magic-lib=${magic-dir}/
    --with-gnurx-dir
    --without-gnurx-dir
    --with-gnurx-include
    --without-gnurx-include=${gnurx-dir}/include
    --with-gnurx-lib
    --without-gnurx-lib=${gnurx-dir}/
    --with-gnurxlib
    --without-gnurxlib
    --with-magiclib
    --without-magiclib


Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/ruby-filemagic-0.7.0 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/gems/ruby-filemagic-0.7.0/ext/filemagic/gem_make.out

那么,什么改變了? 在提到mkmf.log的錯誤中,我在日志文件中看到很多編譯內容,因此我不知道錯誤的確切位置。 看起來如下:

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

"xcrun clang -o conftest -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/universal-darwin14 -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/backward -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0 -I. -I/usr/local/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT    -g -Os -pipe -DHAVE_GCC_SYNC_BUILTINS conftest.c  -L. -L/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib -L/usr/local/lib/ -L. -L/usr/local/lib   -arch x86_64 -arch i386   -lruby.2.0.0  -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 */

"xcrun clang -o conftest -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/universal-darwin14 -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/backward -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0 -I. -I/usr/local/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT    -g -Os -pipe -DHAVE_GCC_SYNC_BUILTINS conftest.c  -L. -L/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib -L/usr/local/lib/ -L. -L/usr/local/lib   -arch x86_64 -arch i386   -lruby.2.0.0 -lgnurx  -lpthread -ldl -lobjc "
conftest.c:5:57: error: use of undeclared identifier 'main'
int t(void) { void ((*volatile p)()); p = (void ((*)()))main; return 0; }
                                                        ^
1 error generated.
checked program was:
/* begin */
 1: #include "ruby.h"
 2: 
 3: /*top*/
 4: extern int t(void);
 5: int t(void) { void ((*volatile p)()); p = (void ((*)()))main; return 0; }
 6: int main(int argc, char **argv)
 7: {
 8:   if (argc > 1000000) {
 9:     printf("%p", &t);
10:   }
11: 
12:   return 0;
13: }
/* end */

"xcrun clang -o conftest -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/universal-darwin14 -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/backward -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0 -I. -I/usr/local/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT    -g -Os -pipe -DHAVE_GCC_SYNC_BUILTINS conftest.c  -L. -L/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib -L/usr/local/lib/ -L. -L/usr/local/lib   -arch x86_64 -arch i386   -lruby.2.0.0 -lgnurx  -lpthread -ldl -lobjc "
conftest.c:5:15: warning: implicit declaration of function 'main' is invalid in C99 [-Wimplicit-function-declaration]
int t(void) { main(); return 0; }
              ^
1 warning generated.
ld: library not found for -lgnurx
conftest.c:5:15: warning: implicit declaration of function 'main' is invalid in C99 [-Wimplicit-function-declaration]
int t(void) { main(); return 0; }
              ^
1 warning generated.
clang: error: linker command failed with exit code 1 (use -v to see invocation)
checked program was:
/* begin */
 1: #include "ruby.h"
 2: 
 3: /*top*/
 4: extern int t(void);
 5: int t(void) { main(); return 0; }
 6: int main(int argc, char **argv)
 7: {
 8:   if (argc > 1000000) {
 9:     printf("%p", &t);
10:   }
11: 
12:   return 0;
13: }
/* end */

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

have_library: checking for magic_open() in -lmagic... -------------------- no

"xcrun clang -o conftest -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/universal-darwin14 -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/backward -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0 -I. -I/usr/local/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT    -g -Os -pipe -DHAVE_GCC_SYNC_BUILTINS conftest.c  -L. -L/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib -L/usr/local/lib/ -L. -L/usr/local/lib   -arch x86_64 -arch i386   -lruby.2.0.0 -lmagic  -lpthread -ldl -lobjc "
conftest.c:5:57: error: use of undeclared identifier 'magic_open'
int t(void) { void ((*volatile p)()); p = (void ((*)()))magic_open; return 0; }
                                                        ^
1 error generated.
checked program was:
/* begin */
 1: #include "ruby.h"
 2: 
 3: /*top*/
 4: extern int t(void);
 5: int t(void) { void ((*volatile p)()); p = (void ((*)()))magic_open; return 0; }
 6: int main(int argc, char **argv)
 7: {
 8:   if (argc > 1000000) {
 9:     printf("%p", &t);
10:   }
11: 
12:   return 0;
13: }
/* end */

"xcrun clang -o conftest -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/universal-darwin14 -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/backward -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0 -I. -I/usr/local/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT    -g -Os -pipe -DHAVE_GCC_SYNC_BUILTINS conftest.c  -L. -L/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib -L/usr/local/lib/ -L. -L/usr/local/lib   -arch x86_64 -arch i386   -lruby.2.0.0 -lmagic  -lpthread -ldl -lobjc "
conftest.c:5:15: warning: implicit declaration of function 'magic_open' is invalid in C99 [-Wimplicit-function-declaration]
int t(void) { magic_open(); return 0; }
              ^
1 warning generated.
conftest.c:5:15: warning: implicit declaration of function 'magic_open' is invalid in C99 [-Wimplicit-function-declaration]
int t(void) { magic_open(); return 0; }
              ^
1 warning generated.
ld: warning: ignoring file /usr/local/lib//libmagic.dylib, file was built for x86_64 which is not the architecture being linked (i386): /usr/local/lib//libmagic.dylib
Undefined symbols for architecture i386:
  "_magic_open", referenced from:
      _t in conftest-d6cdee.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
checked program was:
/* begin */
 1: #include "ruby.h"
 2: 
 3: /*top*/
 4: extern int t(void);
 5: int t(void) { magic_open(); return 0; }
 6: int main(int argc, char **argv)
 7: {
 8:   if (argc > 1000000) {
 9:     printf("%p", &t);
10:   }
11: 
12:   return 0;
13: }
/* end */

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

主要問題似乎是這樣

conftest.c:5:57: error: use of undeclared identifier 'magic_open'
int t(void) { void ((*volatile p)()); p = (void ((*)()))magic_open; return 0; }

我不了解C ++,所以我不知道magic_open的問題是什么

有任何想法嗎?

幾年后...😬在Mac上嘗試。

brew install libmagic

希望這可以幫助其他遇到問題的人。

我認為您需要接受xcode許可證,例如,鍵入sudo clang並按照顯示的過程操作

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM