serialhex | 1 Jun 03:36 2011
Picon

ruby extension not loading

so i'm working on a project for google summer of code trying to get some swig bindings to ruby working for the machine learning toolkit shogun working.  for some reason i can get the sample ruby bindings working fine but when i try to load *any* of the ones from shogun i get this error:


Welcome to IRB. You are using ruby 1.8.7 (2011-02-18 patchlevel 334) [i686-linux]. Have fun ;)
>> require './Evaluation'
LoadError: libshogun.so.10: cannot open shared object file: No such file or directory - ./Evaluation.so
        from ./Evaluation.so                                                                                                                                            
        from /home/serialhex/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'                                              
        from (irb):1

it doesn't matter which one i try to load it gives me the same error.  i also thought it was a case error, so i made a sample library named "Foo.rb" with some simple methods and tried "require './Foo'" and it worked fine.  so right now i'm kind of stuck and not sure where to look for help on this.  googling it didn't come up with anything useful either unfortunately.

if anyone could help me out i would greatly appreciate it
hex

btw: the full code is at:

--
> > Other than the fact Linux has a cool name, could someone explain why I > > should use Linux over BSD? > > No. That's it. The cool name, that is. We worked very hard on > creating a name that would appeal to the majority of people, and it > certainly paid off: thousands of people are using linux just to be able > to say "OS/2? Hah. I've got Linux. What a cool name". 386BSD made the > mistake of putting a lot of numbers and weird abbreviations into the > name, and is scaring away a lot of people just because it sounds too > technical. -- Linus Torvalds' follow-up to a question about Linux
------------------------------------------------------------------------------
Simplify data backup and recovery for your virtual environment with vRanger. 
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Data protection magic?
Nope - It's vRanger. Get your free trial download today. 
http://p.sf.net/sfu/quest-sfdev2dev
_______________________________________________
Swig-user mailing list
Swig-user <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/swig-user
Klaus Kaempf | 1 Jun 08:37 2011
Picon

Re: ruby extension not loading

* serialhex <serialhex <at> gmail.com> [Jun 01. 2011 03:37]:
> so i'm working on a project for google summer of code trying to get some
> swig bindings to ruby working for the machine learning toolkit shogun
> working.  for some reason i can get the sample ruby bindings working fine
> but when i try to load *any* of the ones from shogun i get this error:
> 
> Welcome to IRB. You are using ruby 1.8.7 (2011-02-18 patchlevel 334)
> [i686-linux]. Have fun ;)
> >> require './Evaluation'
> LoadError: libshogun.so.10: cannot open shared object file: No such file or
> directory - ./Evaluation.so
>         from ./Evaluation.so

Don't put a path into the 'require' string. Add the path to Rubys
search array (global variable '$:') instead via

 $:.unshift "."

(unshift puts the path to the front so the current directory gets
searched first)
Then do a normal

  require 'Evaluation'

Hth,

Klaus
---
SUSE LINUX Products GmbH, GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer, HRB 16746 (AG Nürnberg)
Maxfeldstraße 5, 90409 Nürnberg, Germany

------------------------------------------------------------------------------
Simplify data backup and recovery for your virtual environment with vRanger. 
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Data protection magic?
Nope - It's vRanger. Get your free trial download today. 
http://p.sf.net/sfu/quest-sfdev2dev
_______________________________________________
Swig-user mailing list
Swig-user <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/swig-user
Benjamin Ruard | 1 Jun 11:24 2011

[SWIG and Java] cast of lvalue used by swig is deprecated

Hi everybody!
I have a problem of wrapping when I want use my wrapping generated by
SWIG from C++ to Java.
First I use a program in c++ to check if the code is good:

//file.cpp
#include <stdio.h>
#include "GModel.h" 
#include "GModelFactory.h"
#include "GVertex.h"

int main(int argc, char** argv)
{
	double x=1.0;
	double y=0.0;
	double z=0.0;
	double lc=0.1;  

	GModel *m = new GModel();
	GeoFactory *gFact=new GeoFactory();
	GVertex *v=gFact->addVertex(m, x, y, z, lc);
}

I check this code works.
Then I wrap with SWIG the code of c++ to java.
The execution of wrapping works and there is no error.
After I write an equivalent code in Java to do the same thing, and a
problem appears:

//Try.java
public class Try{
	static {
		try {
			System.loadLibrary("Wrap");
		} catch (UnsatisfiedLinkError e) {
	 		System.err.println("Native code library failed to load. See the
chapter on Dynamic Linking Problems in the SWIG Java documentation for
help.\n" + e);
	 		System.exit(1);
	 	}

	}
		
	public static void main(final String[] args) {
	
	double x=1.0;
	double y=0.0;
	double z=0.0;
	double lc=0.1;	

	GModel m = new GModel();
	GeoFactory gFact=new GeoFactory();
	GVertex v1=gFact.addVertex(m, x, y, z, lc);//the problem appears here
	}
}

This java code does not work. The error is:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007f8814922724, pid=2064, tid=140222536300288
#
# JRE version: 6.0_24-b07
# Java VM: Java HotSpot(TM) 64-Bit Server VM (19.1-b02 mixed mode
linux-amd64 compressed oops)
# Problematic frame:
# C  [libWrap.so+0x1e724]  Java_WrapJNI_GeoFactory_1addVertex+0x4
#
# An error report file with more information is saved as:
# /home/benjamin/wrap_v1.2/wrap_v1.2/hs_err_pid2064.log
#
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
Abandon

To finish, I search the problem. I discover in cxx file generated by
SWIG an interesting behavior. Indeed, we have:

SWIGEXPORT jlong JNICALL Java_WrapJNI_new_1GeoFactory(JNIEnv *jenv,
jclass jcls) {
  jlong jresult = 0 ;
  GeoFactory *result = 0 ;

  (void)jenv;
  (void)jcls;
  result = (GeoFactory *)new GeoFactory();
  *(GeoFactory **)&jresult = result; 
  return jresult;
}

The cast at the left of equal sign is deprecated and not recommended
since gcc 3.5. If I modify this auto-generated file with:

SWIGEXPORT jlong JNICALL Java_WrapJNI_new_1GeoFactory(JNIEnv *jenv,
jclass jcls) {
  jlong jresult = 0 ;
  GeoFactory *result = 0 ;

  (void)jenv;
  (void)jcls;
  result = (GeoFactory *)new GeoFactory();
  jresult = (jlong)result; 		//The only modification is here
  return jresult;
}

With this modification, the java program works.

Does somebody know this problem?

My OS is Ubuntu10.10
I use the SWIG 1.3.40, gcc 4.4

Thanks for your answers

Benjamin JEANTY-RUARD

------------------------------------------------------------------------------
Simplify data backup and recovery for your virtual environment with vRanger. 
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Data protection magic?
Nope - It's vRanger. Get your free trial download today. 
http://p.sf.net/sfu/quest-sfdev2dev
Karl Wette | 1 Jun 12:08 2011
Picon

Re: convert numpy array to custom C++ array

Hi Karl,

I think you need to write a "typecheck" typemap for your MDArray type
- SWIG uses this in overloaded methods to determine whether an input
argument is of a particular type. The default "typecheck" typemaps
(i.e. for SWIGTYPE* and SWIGTYPE&) are in Lib/typemaps/swigtype.swg -
you could extend these to check for a numpy array as well as a
SWIG-wrapped type.

Cheers,
Karl

On 1 June 2011 00:15, Karl Merkley <karl <at> elemtech.com> wrote:
>
> I have some C++ methods that I am trying to wrap with swig.   The current overloaded method looks something like
>
> MDArray MyClass::solve(MDArray& in, double time = 0.0);
>
> where MDArray is up to a five dimensional array.   I have typemaps written that look like they should work.
  However, in the dynamic dispatch function, swig does the following
>
> int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_MDArray, 0);
> _v = SWIG_CheckState(res);
>
> The SWIG_ConvertPtr always fails because swig does not know how to convert the numpy array into my
MDArray.   It looks like the code to do the conversion gets included later but this check happens before
the typemap is inserted.  Does anyone have any clues about how to fix this?
>
>   Karl
>
>
>
>
>
>
>
>
> ------------------------------------------------------------------------------
> Simplify data backup and recovery for your virtual environment with vRanger.
> Installation's a snap, and flexible recovery options mean your data is safe,
> secure and there when you need it. Data protection magic?
> Nope - It's vRanger. Get your free trial download today.
> http://p.sf.net/sfu/quest-sfdev2dev
> _______________________________________________
> Swig-user mailing list
> Swig-user <at> lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/swig-user
>

------------------------------------------------------------------------------
Simplify data backup and recovery for your virtual environment with vRanger. 
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Data protection magic?
Nope - It's vRanger. Get your free trial download today. 
http://p.sf.net/sfu/quest-sfdev2dev
Rémi LACROIX | 1 Jun 14:39 2011

[Swig 2.0.4 / Python] Reusing exceptions from another module

Hello,

I have two modules module1 and module2. module1 defines some exceptions I want to reuse in module2.

To convert exceptions in module1 I use the way described in the example "Examples\python\exceptproxy".
The conversion is done at a C++ level with something similar to :

%exception {
   try {
      $action
   } catch(Error& e) {
     Error *ecopy = new Error(e);
     PyObject *err = SWIG_NewPointerObj(ecopy, SWIGTYPE_p_Error, 1);
     PyErr_SetObject(SWIG_Python_ExceptionType(SWIGTYPE_p_Error), err);
     SWIG_fail;
   }
}

My problem comes from the fact I cannot do that for module2 since there is no SWIGTYPE_p_Error defined.

What would be the correct way to deal with that ?

Thanks in advance !

RL

------------------------------------------------------------------------------
Simplify data backup and recovery for your virtual environment with vRanger. 
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Data protection magic?
Nope - It's vRanger. Get your free trial download today. 
http://p.sf.net/sfu/quest-sfdev2dev
serialhex | 1 Jun 18:53 2011
Picon

Re: ruby extension not loading

klaus, thanks for the reply, but i still get the same error:


serialhex <at> arch-hex ~/src/shogun/shogun/src/ruby_modular (master) 
$ irb
Welcome to IRB. You are using ruby 1.8.7 (2011-02-18 patchlevel 334) [i686-linux]. Have fun ;)
>> $:.unshift "."
=> [".", ...*stuff*... ]
>> require 'Evaluation'
LoadError: libshogun.so.10: cannot open shared object file: No such file or directory - ./Evaluation.so
        from ./Evaluation.so                                                                                                 
        from /home/serialhex/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'   
        from (irb):2

i'm able to compile it for 1.9.2 also, and it gives me the same error.  any other ideas on where to look?
thanks again!
hex



On Wed, Jun 1, 2011 at 2:37 AM, Klaus Kaempf <kkaempf <at> suse.de> wrote:
* serialhex <serialhex <at> gmail.com> [Jun 01. 2011 03:37]:
> so i'm working on a project for google summer of code trying to get some
> swig bindings to ruby working for the machine learning toolkit shogun
> working.  for some reason i can get the sample ruby bindings working fine
> but when i try to load *any* of the ones from shogun i get this error:
>
> Welcome to IRB. You are using ruby 1.8.7 (2011-02-18 patchlevel 334)
> [i686-linux]. Have fun ;)
> >> require './Evaluation'
> LoadError: libshogun.so.10: cannot open shared object file: No such file or
> directory - ./Evaluation.so
>         from ./Evaluation.so

Don't put a path into the 'require' string. Add the path to Rubys
search array (global variable '$:') instead via

 $:.unshift "."

(unshift puts the path to the front so the current directory gets
searched first)
Then do a normal

 require 'Evaluation'

Hth,

Klaus
---
SUSE LINUX Products GmbH, GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer, HRB 16746 (AG Nürnberg)
Maxfeldstraße 5, 90409 Nürnberg, Germany



--
> > Other than the fact Linux has a cool name, could someone explain why I > > should use Linux over BSD? > > No. That's it. The cool name, that is. We worked very hard on > creating a name that would appeal to the majority of people, and it > certainly paid off: thousands of people are using linux just to be able > to say "OS/2? Hah. I've got Linux. What a cool name". 386BSD made the > mistake of putting a lot of numbers and weird abbreviations into the > name, and is scaring away a lot of people just because it sounds too > technical. -- Linus Torvalds' follow-up to a question about Linux
------------------------------------------------------------------------------
Simplify data backup and recovery for your virtual environment with vRanger. 
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Data protection magic?
Nope - It's vRanger. Get your free trial download today. 
http://p.sf.net/sfu/quest-sfdev2dev
_______________________________________________
Swig-user mailing list
Swig-user <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/swig-user
William S Fulton | 1 Jun 20:01 2011
Picon

Re: [SWIG and Java] cast of lvalue used by swig is deprecated

On 01/06/11 10:24, Benjamin Ruard wrote:
> Hi everybody!
> I have a problem of wrapping when I want use my wrapping generated by
> SWIG from C++ to Java.
> First I use a program in c++ to check if the code is good:
>
> //file.cpp
> #include<stdio.h>
> #include "GModel.h"
> #include "GModelFactory.h"
> #include "GVertex.h"
>
> int main(int argc, char** argv)
> {
> 	double x=1.0;
> 	double y=0.0;
> 	double z=0.0;
> 	double lc=0.1;
>
> 	GModel *m = new GModel();
> 	GeoFactory *gFact=new GeoFactory();
> 	GVertex *v=gFact->addVertex(m, x, y, z, lc);
> }
>
> I check this code works.
> Then I wrap with SWIG the code of c++ to java.
> The execution of wrapping works and there is no error.
> After I write an equivalent code in Java to do the same thing, and a
> problem appears:
>
> //Try.java
> public class Try{
> 	static {
> 		try {
> 			System.loadLibrary("Wrap");
> 		} catch (UnsatisfiedLinkError e) {
> 	 		System.err.println("Native code library failed to load. See the
> chapter on Dynamic Linking Problems in the SWIG Java documentation for
> help.\n" + e);
> 	 		System.exit(1);
> 	 	}
>
> 	}
> 		
> 	public static void main(final String[] args) {
> 	
> 	double x=1.0;
> 	double y=0.0;
> 	double z=0.0;
> 	double lc=0.1;	
>
> 	GModel m = new GModel();
> 	GeoFactory gFact=new GeoFactory();
> 	GVertex v1=gFact.addVertex(m, x, y, z, lc);//the problem appears here
> 	}
> }
>
> This java code does not work. The error is:
>
> #
> # A fatal error has been detected by the Java Runtime Environment:
> #
> #  SIGSEGV (0xb) at pc=0x00007f8814922724, pid=2064, tid=140222536300288
> #
> # JRE version: 6.0_24-b07
> # Java VM: Java HotSpot(TM) 64-Bit Server VM (19.1-b02 mixed mode
> linux-amd64 compressed oops)
> # Problematic frame:
> # C  [libWrap.so+0x1e724]  Java_WrapJNI_GeoFactory_1addVertex+0x4
> #
> # An error report file with more information is saved as:
> # /home/benjamin/wrap_v1.2/wrap_v1.2/hs_err_pid2064.log
> #
> # If you would like to submit a bug report, please visit:
> #   http://java.sun.com/webapps/bugreport/crash.jsp
> # The crash happened outside the Java Virtual Machine in native code.
> # See problematic frame for where to report the bug.
> #
> Abandon
>
> To finish, I search the problem. I discover in cxx file generated by
> SWIG an interesting behavior. Indeed, we have:
>
> SWIGEXPORT jlong JNICALL Java_WrapJNI_new_1GeoFactory(JNIEnv *jenv,
> jclass jcls) {
>    jlong jresult = 0 ;
>    GeoFactory *result = 0 ;
>
>    (void)jenv;
>    (void)jcls;
>    result = (GeoFactory *)new GeoFactory();
>    *(GeoFactory **)&jresult = result;
>    return jresult;
> }
>
> The cast at the left of equal sign is deprecated and not recommended
> since gcc 3.5. If I modify this auto-generated file with:
>
> SWIGEXPORT jlong JNICALL Java_WrapJNI_new_1GeoFactory(JNIEnv *jenv,
> jclass jcls) {
>    jlong jresult = 0 ;
>    GeoFactory *result = 0 ;
>
>    (void)jenv;
>    (void)jcls;
>    result = (GeoFactory *)new GeoFactory();
>    jresult = (jlong)result; 		//The only modification is here
>    return jresult;
> }
>
> With this modification, the java program works.
>
> Does somebody know this problem?
>
> My OS is Ubuntu10.10
> I use the SWIG 1.3.40, gcc 4.4
>
Please read the Java chapter in the documentation about aliasing and use 
the appropriate compiler option switches.

William

------------------------------------------------------------------------------
Simplify data backup and recovery for your virtual environment with vRanger. 
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Data protection magic?
Nope - It's vRanger. Get your free trial download today. 
http://p.sf.net/sfu/quest-sfdev2dev
Klaus Kaempf | 1 Jun 20:16 2011
Picon

Re: ruby extension not loading

* serialhex <serialhex <at> gmail.com> [Jun 01. 2011 18:53]:
> klaus, thanks for the reply, but i still get the same error:
> 
> serialhex <at> arch-hex ~/src/shogun/shogun/src/ruby_modular (master)
> $ irb
> Welcome to IRB. You are using ruby 1.8.7 (2011-02-18 patchlevel 334)
> [i686-linux]. Have fun ;)
> >> $:.unshift "."
> => [".", ...*stuff*... ]
> >> require 'Evaluation'
> LoadError: libshogun.so.10: cannot open shared object file: No such file or
> directory - ./Evaluation.so
>         from ./Evaluation.so
> 
>         from
> /home/serialhex/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in
> `require'
>         from (irb):2
> 

Ah, Evaluation can be found but it has a dependency on libshogun.so,
which cannot be resolved. (Run 'ldd' on Evaluation.so to see its .so
dependencies).

Since .so dependencies are resolved by glibc, adding its path to the
Ruby search path does not help. You must add it to the LD_LIBRARY_PATH
environment variable.

Hth,

Klaus
---
SUSE LINUX Products GmbH, GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer, HRB 16746 (AG Nürnberg)
Maxfeldstraße 5, 90409 Nürnberg, Germany

------------------------------------------------------------------------------
Simplify data backup and recovery for your virtual environment with vRanger. 
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Data protection magic?
Nope - It's vRanger. Get your free trial download today. 
http://p.sf.net/sfu/quest-sfdev2dev
_______________________________________________
Swig-user mailing list
Swig-user <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/swig-user
William S Fulton | 1 Jun 20:37 2011
Picon

Re: [Swig 2.0.4 / Python] Reusing exceptions from another module

On 01/06/11 13:39, Rémi LACROIX wrote:
> Hello,
>
> I have two modules module1 and module2. module1 defines some exceptions I want to reuse in module2.
>
> To convert exceptions in module1 I use the way described in the example "Examples\python\exceptproxy".
The conversion is done at a C++ level with something similar to :
>
> %exception {
>     try {
>        $action
>     } catch(Error&  e) {
>       Error *ecopy = new Error(e);
>       PyObject *err = SWIG_NewPointerObj(ecopy, SWIGTYPE_p_Error, 1);
>       PyErr_SetObject(SWIG_Python_ExceptionType(SWIGTYPE_p_Error), err);
>       SWIG_fail;
>     }
> }
>
> My problem comes from the fact I cannot do that for module2 since there is no SWIGTYPE_p_Error defined.
>
> What would be the correct way to deal with that ?
>
Probably you are not importing (with %import) the header file that 
contains Error. You need to do this so that SWIG knows about the types 
used in other modules.

William

------------------------------------------------------------------------------
Simplify data backup and recovery for your virtual environment with vRanger. 
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Data protection magic?
Nope - It's vRanger. Get your free trial download today. 
http://p.sf.net/sfu/quest-sfdev2dev
William S Fulton | 1 Jun 20:50 2011
Picon

Re: tcl missing vector of pointers typemaps

On 26/05/11 21:44, Miller, Eric wrote:
> Functions that return a vector of pointers are not getting handled consistently.
> At least in Perl and python the elements are dereferenced automatically, but Tcl returns a pointer (to a
pointer) which messes up the stringified object names.
>
> I think this is because the tcl/std_vector.i does not have a specialized class for vector of pointers.
> I made a half-assed attempt to add them (see std_vector_tcl.i in the attached test case) but while the
output typemap works, I doubt I got the input typemaps correct.
>
> I was going to file a bug but the sourceforge bug tracker is/was down.
>
> Anyways, I slapped together a minimal test case (attached) to demonstrate.  I'd appreciate it if anyone
has time to take a look.
> I'll file a bug as soon as the tracker is back up.
>
Specialization of pointers is required. There isn't much developer 
expertise for Tcl, so the missing 'in' typemaps are a problem. If you 
can tweak the vector<T> versions for vector<T*>, then please post your 
patch to SF bug tracker and I'll test and include in next version.

William

------------------------------------------------------------------------------
Simplify data backup and recovery for your virtual environment with vRanger. 
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Data protection magic?
Nope - It's vRanger. Get your free trial download today. 
http://p.sf.net/sfu/quest-sfdev2dev

Gmane