tags:

views:

123

answers:

2

I've been working on getting my library c++ Lavish working with ruby using swig. The issue is that only some of the classes I've included in the interface file can be used and I get no errors during compilation of the bundle or loading in ruby. My swig interface file can be viewed here.

An example of what works and what doesn't.

sean$ irb
>> require "lavish"
=> true
>> v1 = Lavish::Vector2.new(1,2)
=> #<Lavish::Vector2:0x1011a25a0>
>> puts v1.x
1.0
=> nil
>> display = Lavish::Display.new
dyld: lazy symbol binding failed: Symbol not found: __ZN6lavish7DisplayC1Ev
  Referenced from: /Users/seanc/Desktop/Lavish/samples/ruby/Tutorial 2 - Displaying A Triangle/lavish.bundle
  Expected in: flat namespace

dyld: Symbol not found: __ZN6lavish7DisplayC1Ev
  Referenced from: /Users/seanc/Desktop/Lavish/samples/ruby/Tutorial 2 - Displaying A Triangle/lavish.bundle
  Expected in: flat namespace

Trace/BPT trap

I can create the Display object in C++ and I have included the header in the swig interface file so I don't know where to look for what is wrong.

Any ideas?

A: 

Are the library compiled really compiled ? (And not just the interface SWIG wrapper)

dynamic linker problem ??? The program dont know where is located the library for you program. Try to set LD_LIBRARY_PATH with your library directory.

Phong
I know it can't find the symbol but if it was a linker issue then either ruby would fail to load the library or trying to create another class from the same dll would not work properly.
seoushi
Just for clarity this is on osx, snow leopard. I have build the C++ lib with xcode and copied the resulting framework to /Libraries/Frameworks. When compiling the swig library it finds the library and links against it without issue. I can post logs if needed.
seoushi
A: 

Turns out it was a few issues, first off the extconf.rb file which generates the makefile for the swig wrapper wasn't trying to link in the framework (swig needs updated docs for os x). The second issue I had was that ruby seems to be a universal binary on snow leopard but wants to load x86_64 and not the i386 version (go figure). Now I have to recompile all my dependencies in universal frameworks x86_64. I'm sure there is a way to force i386 but I'd rather have 64bit support where available.

seoushi