Difference between revisions of "YARP and Python"

From Wiki for iCub and Friends
Jump to: navigation, search
m (fix spelling Linux)
(Linux)
Line 14: Line 14:
 
On 64 bit machine, you need to compile YARP as dynamic/shared library (CREATE_SHARED_LIBRARY), otherwise you get the error:  
 
On 64 bit machine, you need to compile YARP as dynamic/shared library (CREATE_SHARED_LIBRARY), otherwise you get the error:  
  
relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
+
  relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
 +
 
 +
To compile YARP as a dynamic/shared library, run the cmake GUI (see [[CMake icub]] for tips on how to do this) and toggle the "CREATE_SHARED_LIBRARY" switch to on.  On UNIX, in ccmake, press the spacebar to toggle a switch.

Revision as of 21:04, 11 January 2011

The current supported method for using YARP from Python is via SWIG. See:

 $YARP_ROOT/example/swig

Read the README in that directory.

If you go in there and run CMake ("ccmake ." on linux) you'll be presented with a bunch of language options (Java, Python, Perl, ...). Switch "CREATE_PYTHON" on, and then finish configuring. Then run "make". There may be lots of warnings from swig about language features that don't match exactly; it is usually safe to ignore these. Then hopefully the example in "example.py" will work for you.

Linux

Simple but important, don't forget to install python and python sources:

  sudo apt-get install python-dev python

On 64 bit machine, you need to compile YARP as dynamic/shared library (CREATE_SHARED_LIBRARY), otherwise you get the error:

 relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC

To compile YARP as a dynamic/shared library, run the cmake GUI (see CMake icub for tips on how to do this) and toggle the "CREATE_SHARED_LIBRARY" switch to on. On UNIX, in ccmake, press the spacebar to toggle a switch.