Domanda

I'm trying to call external C program. The same code already works on linux and windows, but not on solaris.
Can somebody take a look?
Original example is taken from http://csl.name/C-functions-from-Python/
C code (myModule.c)

#include <Python.h>

static PyObject* py_myFunction(PyObject* self, PyObject* args)
{
    char *s = "Hello from C!";
    return Py_BuildValue("s", s);
}

static PyObject* py_myOtherFunction(PyObject* self, PyObject* args)
{
    double x, y;
    PyArg_ParseTuple(args, "dd", &x, &y);
    return Py_BuildValue("d", x*y);
}

static PyMethodDef myModule_methods[] = {
    {"myFunction", py_myFunction, METH_VARARGS},
    {"myOtherFunction", py_myOtherFunction, METH_VARARGS},
    {NULL, NULL}
};

void initmyModule()
{
    (void) Py_InitModule("myModule", myModule_methods);
}

Python calling it

from myModule import *

print "Result from myFunction:", myFunction()
print "Result from myOtherFunction(4.0, 5.0):", myOtherFunction(4.0, 5.0)

Compiling on Linux (tested on RHEL)

gcc -fPIC -shared -I/usr/include/python2.6 -lpython2.6 -o myModule.so myModule.c

Compiling on Windows XP under MinGW

gcc -Ic:/Python27/include -Lc:/Python27/libs myModule.c -lpython27 -shared -o myModule.pyd

But I can't get it to work on solaris. I can compile it with

gcc -fPIC -I/usr/include/python2.4 -L/usr/lib/python2.4 myModule.c -lpython2.4 -shared -o myModule.so

but it fails with an error

from myModule import *
ImportError: ld.so.1: python2.4: fatal: libgcc_s.so.1: open failed: No such file or directory

Can someone help me figure it out?

gcc is 3.4.6
Python is 2.4.6
solaris 10 on x86 machine 

È stato utile?

Soluzione

This should hook you up

 pfexec rm /usr/lib/libgcc_s.so.1
 pfexec ln -s /opt/ts/gcc/3.4/lib/libgcc_s.so.1 /usr/lib/libgcc_s.so.1
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top