![](https://secure.gravatar.com/avatar/788e9f211717fff4949bef64aa7d3318.jpg?s=120&d=mm&r=g)
I compile and link Python extension modules using the script gcc -fPIC -g -I/usr/local/include/python2.3 \ -Wall -Wstrict-prototypes -c mymodule.c g++ -shared mymodule.o -L/usr/local/lib -o mymodule.so It works for me but it isn't pretty. Is there a better way to write it? Gcc finds all the libraries that need to be linked in. For example, "/usr/local/lib/python2.3/site-packages/numarray/libnumarray.so". How does gcc do this? I created a .so file "utilities.so" that contains some C functions that are called in mymodule.c but are not visible from Python. Both "utilities.c" and "mymodule.c" use numarray. What changes do I make in the script above? Must I use the nasty "libnumarray_UNIQUE_SYMBOL" trick? What is a script for creating "utilities.a" using gcc? How do I change the script above to include "utilities.a"?
![](https://secure.gravatar.com/avatar/a53ea657e812241a1162060860f698c4.jpg?s=120&d=mm&r=g)
On Saturday 01 November 2003 03:12, Edward C. Jones wrote:
Yes, the distutils module. It's part of the Python standard library and documented there.
It doesn't :-) And it doesn't have to. You are not creating a stand-alone executable, but a shared library for use in Python. Everything is linked together dynamically at runtime when Python imports all the modules.
I don't know enough about numarray to answer that question, but that is certainly one option. Alternatively you could include utilities.c into mymodule.c.
What is a script for creating "utilities.a" using gcc? How do I change the script above to include "utilities.a"?
To create the archive: gcc -c utilities.c ar r libutilities.a utilies.o You might have to add some libraries or library paths to the compilation step. To use the archive, just add -lutilities to the gcc command line, plus eventually the path with -L. Konrad. -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hinsen@cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.56.24 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais -------------------------------------------------------------------------------
![](https://secure.gravatar.com/avatar/a53ea657e812241a1162060860f698c4.jpg?s=120&d=mm&r=g)
On Saturday 01 November 2003 03:12, Edward C. Jones wrote:
Yes, the distutils module. It's part of the Python standard library and documented there.
It doesn't :-) And it doesn't have to. You are not creating a stand-alone executable, but a shared library for use in Python. Everything is linked together dynamically at runtime when Python imports all the modules.
I don't know enough about numarray to answer that question, but that is certainly one option. Alternatively you could include utilities.c into mymodule.c.
What is a script for creating "utilities.a" using gcc? How do I change the script above to include "utilities.a"?
To create the archive: gcc -c utilities.c ar r libutilities.a utilies.o You might have to add some libraries or library paths to the compilation step. To use the archive, just add -lutilities to the gcc command line, plus eventually the path with -L. Konrad. -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hinsen@cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.56.24 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais -------------------------------------------------------------------------------
participants (2)
-
Edward C. Jones
-
Konrad Hinsen