sasikalar / gamekit

Automatically exported from code.google.com/p/gamekit
0 stars 0 forks source link

Can't compile as a Python module with Cython. #127

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I tried converting the Cpp Example into a python module with Cython.

It throws errors like this:
/usr/bin/ld: ../../lib/libOgreMain.a(OgreArchiveManager.cpp.o): relocation 
R_X86_64_32 against `.rodata' can not be used when making a shared object; 
recompile with -fPIC
../../lib/libOgreMain.a: could not read symbols: Bad value

I tried compiling with -fPIC everything it still fails. Is there a way to 
compile a .so without having to -fPIC everything? Or what is the proper way of 
setting all with -fPIC?

Original issue reported on code.google.com by kungfoobar@gmail.com on 10 Jan 2011 at 1:00

GoogleCodeExporter commented 9 years ago
I successfully compiled it in a 32 bit chroot. So I'm going to develop it in 32 
bit mode. I hope I'll make an useful contribution to the project. Meanwhile I 
would like to have this issue resolved so I can compile it for 64 bit platforms 
as well.

Original comment by kungfoobar@gmail.com on 11 Jan 2011 at 2:46

GoogleCodeExporter commented 9 years ago
I found two ways to solve the problem:

a) Compiling everything with -fPIC this way:
cmake -DCMAKE_C_FLAGS="-fPIC" DCMAKE_CXX_FLAGS="-fPIC" .
make -j8

b) Making the python module an executable instead of a shared library, adding 
this code:

int main(int argc, char *argv[]){
  Py_Initialize();
  #if PY_MAJOR_VERSION < 3
    initFOO();
  #else
    PyInit_FOO(void);
  #endif
  PyRun_SimpleString("import FOO\n"); // you can run any python script
  Py_Finalize();
  return 0;
}

(where FOO is the name of the module).

Original comment by kungfoobar@gmail.com on 1 Feb 2011 at 10:32

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
are you doing a python wrapper? that would be awesome! i prefer python over lua.
or do you try to directly use cython as the language for your application? that 
would be kind of interesting too.

Original comment by horac...@gmail.com on 4 Feb 2011 at 5:59

GoogleCodeExporter commented 9 years ago
Can this be closed? This was solved looong ago! Also I retook this work and 
it's almost done. I will open the hg repository soon :)

Original comment by kungfoobar@gmail.com on 19 Oct 2011 at 7:50

GoogleCodeExporter commented 9 years ago
Okay, it is closed.

Original comment by harkon...@gmail.com on 22 Oct 2011 at 11:51