外部の C プログラムを呼び出そうとしています。Linux と Windows では同じコードが既に動作しますが、solaris では動作しません。
誰か見てもらえませんか?
元の例は、http://csl.name/C-functions-from-Python/ C コード (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
from myModule import *
print "Result from myFunction:", myFunction()
print "Result from myOtherFunction(4.0, 5.0):", myOtherFunction(4.0, 5.0)
Linux でのコンパイル (RHEL でテスト済み)
gcc -fPIC -shared -I/usr/include/python2.6 -lpython2.6 -o myModule.so myModule.c
MinGW の下で Windows XP でコンパイルする
gcc -Ic:/Python27/include -Lc:/Python27/libs myModule.c -lpython27 -shared -o myModule.pyd
しかし、私はそれをsolarisで動作させることができません。私はそれをコンパイルすることができます
gcc -fPIC -I/usr/include/python2.4 -L/usr/lib/python2.4 myModule.c -lpython2.4 -shared -o myModule.so
しかし、それはエラーで失敗します
from myModule import *
ImportError: ld.so.1: python2.4: fatal: libgcc_s.so.1: open failed: No such file or directory
誰かがそれを理解するのを手伝ってくれますか?
gcc は 3.4.6 です Python は 2.4.6 です x86マシン上のsolaris 10