Compiling/Linking external Functions (setup.py, distutils, gcc?)

Hello all,
I would like to use an existing C-Function from python. Therfore I made up an wrapper (wrap.c), where all the variable transformations from Python to C are done. That works. Now I would like to call the external fuction, which is placed in lets say ext_foo.a with a corresponding ext_foo.h and can be used as a library from plain C.
I am assuming, that I do have to include the ext_foo.h in my wrap.c with #include "ext_foo.h"
that I have to introduce the function in my C-Code:
extern int foo(int);
that I have to tell the setup.py using the distutils stuff where the library can be found...
when compiling a C-Code which is not for python usage I do type
gcc -o test.o ./test.c ./ext_foo.a -I./foo_h_file_path/
and everything is fine, where within these setup.py files do I have to mention the ./ext_foo.a ? When I do place it in the sources-tag, setup procedure complains that it doesn't know any .a files... if I don't mention it explicitly, just giving the include_dirs, compilation works fine, but when importing from python 'import wrap' I do get the message: Symbol not found: _foo
Any help is very much appreciated! Thanks Philipp

On Wed, Nov 19, 2008 at 12:00 PM, Philipp Heuser <philipp@achtziger.de>wrote:
The "sources" parameter lists source files that need to be compiled. Your ext_foo.a doesn't need to be compiled; it just needs to be linked. Try adding a parameter link_objects=['ext_foo.a'] to the Extension(...) definition.
HTH,
-- Carsten Haese http://informixdb.sourceforge.net

On 2008-11-19 18:00, Philipp Heuser wrote:
The .a file is a library, so you have use the libraries parameter to have distutils link against this library.
http://docs.python.org/extending/building.html
-- Marc-Andre Lemburg eGenix.com
Professional Python Services directly from the Source (#1, Nov 19 2008)
2008-11-12: Released mxODBC.Connect 0.9.3 http://python.egenix.com/
:::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! ::::
eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611

On Wed, Nov 19, 2008 at 12:00 PM, Philipp Heuser <philipp@achtziger.de>wrote:
The "sources" parameter lists source files that need to be compiled. Your ext_foo.a doesn't need to be compiled; it just needs to be linked. Try adding a parameter link_objects=['ext_foo.a'] to the Extension(...) definition.
HTH,
-- Carsten Haese http://informixdb.sourceforge.net

On 2008-11-19 18:00, Philipp Heuser wrote:
The .a file is a library, so you have use the libraries parameter to have distutils link against this library.
http://docs.python.org/extending/building.html
-- Marc-Andre Lemburg eGenix.com
Professional Python Services directly from the Source (#1, Nov 19 2008)
2008-11-12: Released mxODBC.Connect 0.9.3 http://python.egenix.com/
:::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! ::::
eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611
participants (3)
-
Carsten Haese
-
M.-A. Lemburg
-
Philipp Heuser