Note that there are some explanatory texts on larger screens.

plurals
  1. POpython calling external C program in solaris
    primarykey
    data
    text
    <p>I'm trying to call external C program. The same code already works on linux and windows, but not on solaris.<br> Can somebody take a look?<br> Original example is taken from <a href="http://csl.name/C-functions-from-Python/" rel="nofollow">http://csl.name/C-functions-from-Python/</a><br> C code (myModule.c)</p> <pre><code>#include &lt;Python.h&gt; 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", &amp;x, &amp;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); } </code></pre> <p>Python calling it</p> <pre><code>from myModule import * print "Result from myFunction:", myFunction() print "Result from myOtherFunction(4.0, 5.0):", myOtherFunction(4.0, 5.0) </code></pre> <p>Compiling on Linux (tested on RHEL)</p> <pre><code>gcc -fPIC -shared -I/usr/include/python2.6 -lpython2.6 -o myModule.so myModule.c </code></pre> <p>Compiling on Windows XP under MinGW</p> <pre><code>gcc -Ic:/Python27/include -Lc:/Python27/libs myModule.c -lpython27 -shared -o myModule.pyd </code></pre> <p>But I can't get it to work on solaris. I can compile it with</p> <pre><code>gcc -fPIC -I/usr/include/python2.4 -L/usr/lib/python2.4 myModule.c -lpython2.4 -shared -o myModule.so </code></pre> <p>but it fails with an error</p> <pre><code>from myModule import * ImportError: ld.so.1: python2.4: fatal: libgcc_s.so.1: open failed: No such file or directory </code></pre> <p>Can someone help me figure it out? <pre> gcc is 3.4.6 Python is 2.4.6 solaris 10 on x86 machine </pre></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload