[Pythonmac-SIG] Swig_for_Mac

Keith Jackson krjackson at lbl.gov
Sat Feb 7 22:05:46 EST 2004


Hi,
First off, swig 1.3.11 is really old and buggy. Personally I'd just 
build swig by hand, and run it from the command line. then you can get 
swig-1.3.20. If you really have to have a gui, a quick google search 
shows the current version of Swig for Mac is 1.3.19. You should at 
least upgrade to that.

More comments inline.

On Feb 7, 2004, at 9:14 AM, Christopher Smith wrote:

> Hello,
>
> I'm trying to use an extension I've downloaded (APSE, a "Python port 
> of the String::Approx module written for perl by Jarkko Hietaniemi."). 
> I downloaded Swig_for_Mac 1.3.11 and am trying to figure out how to 
> make one of the examples work before I try to process the apse.c file.
>
> I start up Swig_for_Mac and set the source to be the example.i file 
> and press run. A wrapper file is produced, example_wrap.c.
>
> Now I don't know what to do from here. I am having a hard time sifting 
> out what can/should be done with the Swig_for_Mac and what must be 
> done at the command line with gcc.  One of the pages that I've 
> consulted says to issue a gcc compile of the example.c and 
> example_wrap.c files. When I do that I get the following output:
>

Yes, Swig just generates C code from the .i file. You must still 
compile it.

> csmith% gcc -c example.c example_wrap.c -I/usr/local/include/python2.2 
> -I/usr/local/include/python2.2
> example_wrap.c:27: header file 'string.h' not found
> example_wrap.c:203: header file 'stdlib.h' not found
>

kjackson at krjnote(5)>ls /usr/include/string.h
    8 /usr/include/string.h
kjackson at krjnote(6)>ls /usr/include/stdlib.h
    8 /usr/include/stdlib.h
kjackson at krjnote(7)>

Those should all be in /usr/include. gcc adds /usr/include to the 
include search path, so I'm not sure what's going on. Do you have these 
  files in /usr/include?

> [and  a whole lot more!]
>
> I don't have anything related to python in the usr/local/include 
> directory so I'm not surprised I get a lot of error messages--there is 
> only a 'dlfcn.h' file in that directory. On the other hand, I don't 
> know which path I should be specifying.
>
> I am using version 2.2 of python:
> csmith% python
> Python 2.2 (#1, 07/14/02, 23:25:09)
> [GCC Apple cpp-precomp 6.14] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
>
> Being a bit unix-unsavvy, I almost never run it from the command line; 
> I always run it through the IDE.
>
> My objective is to be able to use the APSE.c file's functions. I 
> assume that I have to use SWIG in some manner to do that. If you can 
> help me get it running (or suggest another way to be able to access 
> the apse.c function) I would appreciate it.
>

You can certainly use Swig to enable access to a function in C, but 
you're going to need to become a little more unix-savy. :) Once you get 
the example working, you'll have to write a .i file that tells swig 
what you want to wrap. I've never looked at APSE, so I can't give you a 
feel for how difficult that will be. It could be as simple as just 
including it in the .i file in the right section, or it could require a 
more complex interface file.
--keith


> /c
>
>
> _______________________________________________
> Pythonmac-SIG maillist  -  Pythonmac-SIG at python.org
> http://mail.python.org/mailman/listinfo/pythonmac-sig




More information about the Pythonmac-SIG mailing list