如何在Windows 7中安装filemagic

时间:2012-09-25 01:08:13

标签: ruby gem

我正在尝试安装

gem install ruby-filemagic

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.   

如何在Windows 7上修复此错误?

2 个答案:

答案 0 :(得分:1)

checking for magic_open() in -lmagic... no                 
*** ERROR: missing required library to compile this module  

首先检查magic_open库中是否存在magic函数,但它找不到它,这表明你缺少魔法库。

libmagic不属于Windows,因此您需要自己获取或编译它。

您可以使用使用RubyInstaller编译C项目的补充DevKit,但您需要熟悉libmagic和GCC。

答案 1 :(得分:0)

对于Ruby 1.9.3

file-5.21.tar.gz下载ftp://ftp.astron.com/pub/file/并摘录到目录。

bin下载libgnurx 2.5.1 dev + sourceforge并将其解压缩到另一个目录。

运行DevKit msys shell

 c:\path\to\devkit-4.5.2\msys.bat -mintty

从您解压缩到的目录中构建file

 cd /the/path/to/extracted/file-5.21
 LDFLAGS=-L/the/path/to/libgnurx-2.5.1/lib
 CFLAGS=-I/the/path/to/libgnurx-2.5.1/include
 ./configure --prefix=/a/path/for/file-2.21
 make install

从DevKit msys shell内部

 gem install ruby-filemagic -- --with-magic-dir=/a/path/for/file-2.21