2

I bought a new Mac this week and have had big problems getting this gem installed. It was never a problem on my old Mac but seems to be particularly difficult on this one.

I have installed libvirt via Homebrew, Xcode4.4 (with command line tools) and gcc4.2. I have symlinked to make gcc4.2 the default compiler.

gem install ruby-libvirt -v '0.4.0' fails because it cannot find the headers

If I pass in the paths to the headers and libraries, like so:

ruby-libvirt -v '0.4.0' -V -- --with-libvirt-include=/usr/local/Cellar/libvirt/0.9.11.3/include/ --with-libvirt-lib=/usr/local/Cellar/libvirt/0.9.11.3/lib/

, it compiles just fine but fails when linking with the following errors:

linking shared-object _libvirt.bundle ld: library not found for -lruby.1.9.1 collect2: ld returned 1 exit status make: *** [_libvirt.bundle] Error 1

I have installed Ruby 1.9.3 via RVM and haven't had any troubles installing other native extensions, so I cannot see why it fails to find the ruby libraries in this case.

Does anyone have any ideas? Help would be much appreciated.

Johan
  • 554
  • 1
  • 4
  • 10
  • 1
    Do you have other ruby versions installed with RVM? Do `rvm list` to find out in the folder where you have trouble installing. – Jason Kim Aug 25 '12 at 16:25

4 Answers4

1

I built ruby-libvirt-0.4.0/ext/libvirt by proving external libvirt installed using brew.

Here is what I did to successfully install libvirt.

  1. brew install libvirt

  2. ruby extconf.rb --with-libvirt-include=/usr/local/include/libvirt --with-libvirt-lib=/usr/local/lib/libvirt

  3. gem install ruby-libvirt -v '0.4.0' -V -- --with-libvirt-include=/usr/local/Cellar/libvirt/1.1.4/include/libvirt --with-libvirt-lib=/usr/local/Cellar/libvirt/1.1.4/lib

Hope this helps.

Ashwini Agarwal
  • 4,828
  • 2
  • 42
  • 59
1

To install the gem you need to install the libvirt libraries. Using 'Homebrew' (a package manager for mac) :

brew install libvirt
bundle install

The exact error you got might have been:

An error occurred while installing ruby-libvirt (0.4.0)
xxjjnn
  • 14,591
  • 19
  • 61
  • 94
0

I have finally solved this. It turns out that the command line tools were not properly installed. The following line needs to be added to your .zshrc file (or whatever applies to your choice of shell):

export PATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:$PATH

Johan
  • 554
  • 1
  • 4
  • 10
0

You need only to install libvirt, before the bundle install.

brew install libvirt
AlexSh
  • 1,468
  • 15
  • 12