외부 C 프로그램을 호출하려고합니다. 동일한 코드가 이미 Linux 및 Windows에서 작동하지만 solaris에서는 작동하지 않습니다.
누군가가 살펴볼 수 있습니까?
원래 예 (RHEL 테스트) 리눅스에서 컴파일파이썬은 솔라리스에서 외부 C 프로그램을 호출합니다.
from myModule import *
print "Result from myFunction:", myFunction()
print "Result from myOtherFunction(4.0, 5.0):", myOtherFunction(4.0, 5.0)
를 호출 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);
}
파이썬에서
gcc -fPIC -shared -I/usr/include/python2.6 -lpython2.6 -o myModule.so myModule.c
컴파일을 촬영 Windows XP에서 MinGW 미만
하지만 솔라리스에서 작동하지 않습니다. 내가
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 is 3.4.6 Python is 2.4.6 solaris 10 on x86 machine
당신를 연결해야합니다. libgcc_s.so.1을 찾아서 찾을 수 없습니다. –