开发者

Problem installing linkparser on Ubuntu 10

开发者 https://www.devze.com 2023-02-13 12:33 出处:网络
using rvm using ruby 1.9.2 identical gems (and support libs) installed in OS X link-grammar installed (via apt-get)
  • using rvm
  • using ruby 1.9.2
  • identical gems (and support libs) installed in OS X
  • link-grammar installed (via apt-get)
  • pkg-config working as expected.

When I run gem install linkparser I get the following error:

Building native extensions.  This could take a while...
ERROR:  Error installing linkparser:
    ERROR: Failed to build gem native extension.

/home/locallyclient/.rvm/rubies/ruby-1.9.2-p0/bin/ruby extconf.rb
checking for pkg-config... yes
checking for dictionary_create() in -llink-grammar... *** 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.

(plus more including cmd line options and stack trace).

mkmf.log looks like:

"gcc -o conftest -I/~/.rvm/rubies/ruby-1.9.2-p0/include/ruby-1.9.1/i686-linux -I/~/.rvm/rubies/ruby-1.9.2-p0/include/ruby-1.9.1/ruby/backward -I
/~/.rvm/rubies/ruby-1.9.2-p0/include/ruby-1.9.1 -I.  -D_FILE_OFFSET_BITS=64   -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-st
rings -Wno-missing-field-initializers -Wno-long-long  -fPIC-I/usr/local/include   conftest.c  -L. -L/~/.rvm/rubies/ruby-1.9.2-p0/lib -Wl,-R/~/.r
vm/rubies/ruby-1.9.2-p0/lib -L.  -rdynamic -Wl,-export-dynamic-L/usr/local/lib       -Wl,-R -Wl,/~.rvm/rubies/ruby-1.9.2-p0/lib -L/~/.rvm/rubie
s/ruby-1.9.2-p0/lib -lruby-static  -lpthread -lrt -ldl -lcrypt -lm   -lc"
cc1: error: unrecognized command line option "-fPIC-I/us开发者_JAVA百科r/local/include"
checked program was:
/* begin /
1: #include "ruby.h"
2: 
3: int main() {return 0;}
/ end */

( I replace the home path with '~' for easier reading)

Specifically: cc1: error: unrecognized command line option "-fPIC-I/usr/local/include"

Any ideas as to why this paramater would be mangled and where I can fix it?


Here is few steps I tried.

Get ruby source (1.9.2 p180 for now)

$ wget ftp://ftp.ruby-lang.org//pub/ruby/1.9/ruby-1.9.2-p180.tar.gz
$ tar zxvf ruby-1.9.2-p180.tar.gz

export include path of ruby, you may write it in ~/.bashrc, to enable for other native extensions too.

$ export CPATH="`pwd`/ruby-1.9.2-p180/include":$CPATH

and looks like apt-get version of link-grammer is version 4.0 and linkparser complaining too old (>=4.7.0), so get and trunk version as they mentioned the site. v4.7.4 for now

http://www.abisource.com/projects/link-grammar/#download

note: if your ruby is in /usr/local/bin, change --prefix=/usr to --prefix=/usr/local

$ svn co http://svn.abisource.com/link-grammar/trunk link-grammar
$ cd link-grammar
$ ./autogen.sh
$ ./configure --prefix=/usr
$ make
$ sudo make install
$
$ sudo gem install linkparser
Building native extensions.  This could take a while...
Successfully installed linkparser-1.1.0
1 gem installed
Installing ri documentation for linkparser-1.1.0...

Test codes to confirm working properly

ref: http://deveiate.org/code/linkparser/

$ irb
> require 'linkparser'
=> true
> dict = LinkParser::Dictionary.new( :screen_width => 100 )
> sent = dict.parse( "People use Ruby for all kinds of nifty things." )
> puts sent.constituent_tree_string
(S (NP People)
   (VP use
       (NP Ruby)
       (PP for
           (NP (NP all kinds)
               (PP of
                   (NP nifty things)))))
   .)
=> nil
> puts sent.diagram

    +---------------------------------Xp--------------------------------+
    |                +-----MVp----+-----Jp-----+     +------Jp-----+    |
    +----Wd---+--Sp--+--Os--+     |     +--Dmc-+--Mp-+    +----A---+    |
    |         |      |      |     |     |      |     |    |        |    |
LEFT-WALL people.p use.v Ruby.f for.p all.a kinds.n of nifty.a things.n . 

=> nil


I was having the same issue where linkparser could not find ruby/intern.h or some as such. I followed the above instructions and it still did not work. I made a soft-link (ln -s) from /usr/lib/ruby/1.8/x86_64-linux/ruby/* to /usr/lib/ruby/1.8/x86_64-linux/* and when I went to compile linkparser it worked like a champ. I then tried it with 1.9.2 and it also worked on a different box.

I also was having issue with wordnet and this fix worked on that as well.

Chris


There is a bug in the gem source code which is causing the CFLAGS to be concatenated as -fPIC-I/usr/local/include instead of -fPIC -I/usr/local/include

Fix (referring to Gem version 1.1.0):

in ./ext/exconf.rb, find the following lines (should be lines 20 and 21):

$LDFLAGS << read_cmd_output( pkgconfig, '--libs-only-L', 'link-grammar' )
$CFLAGS << read_cmd_output( pkgconfig, '--cflags', 'link-grammar' ) 

and change them to:

$LDFLAGS << ' ' + `#{pkgconfig} --libs-only-L link-grammar`.chomp
$CFLAGS <<  ' ' + `#{pkgconfig} --cflags link-grammar`.chomp

this should allow you to install the gem in an rvm gemset


I've released version 1.1.2 of the gem, which includes the fix from @alexander.

0

精彩评论

暂无评论...
验证码 换一张
取 消