2012-09-25 47 views
0

我試圖安裝如何安裝filemagic在Windows 7

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?

+0

你看到了什麼,當你遵循指令'檢查更detail'的mkmf.lgo文件? –

+0

這是它的一部分 conftest.c:在函數't'中: conftest.c:8:1:warning:隱式聲明函數'magic_open' c:/ ruby​​193/mingw/bin /../ lib /gcc/mingw32/4.5.2/../../../../mingw32/bin/ld.exe:找不到-lmagic – wnoveno

回答

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

首先它檢查是否在magic庫中存在magic_open功能,並沒有找到它,這表明你缺少魔法庫。

libmagic不是Windows的一部分,所以您需要自行獲取或編譯它。

您可以使用使用RubyInstaller編譯C項目的補充DevKit,但您需要熟悉libmagic和GCC。

0

對Ruby 1.9.3

ftp://ftp.astron.com/pub/file/下載file-5.21.tar.gz並解壓到一個目錄。

sourceforge下載libgnurx 2.5.1 bin + dev並提取兩個目錄。

運行的devkit MSYS殼

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殼

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