Compiling and running Python code

Hey there,
First post here in the Unix forums, but I have used them a lot for research over the last year. Anyways, to why I'm here now:
I'm working on a project and I'll be using the AIS Parser SDK by Brian C. Lane (can't post the link, but google that and the first 8 links will be relevant) and I'll preferably do it in python. Why python? Mostly because it'll be easier than doing it in C. Problem is, I have no idea how to even get the included python code working. The included readme mentions using a buildit script compile the modules, but I can't seem to get the examples to work. :wall:
If you haven't figured out by now, I'm a python newbie. But as I stated above, doing this project in python would be easier than doing it in C (especially since regardless of which I choose, that's the language I'd be learning for the first time).
The one example I'm trying to get to work is in the sdk, located in the python/linux/examples/last_ais folder. Any help would be appreciated.

What version of python do you use?

Python 2.7.1+

For deb-based linux, you need as root

apt-get install python-dev swig

(Maybe another common build packages like "build-essential" for Ubuntu).
Then run ./buildit from python/linux directory. If everything is ok you should copy 2 files aisparser.py and _aisparser.so to the specific example directory and run an example.

Sorry for my English.

1 Like

Thanks for the reply yazu. When I did as you suggested this happened:

gcc: ../../c/src/: linker input file unused because linking not done
aisparser_wrap.o: In function `SwigPyObject_str':
aisparser_wrap.c:(.text+0x1455): undefined reference to `__stack_chk_fail_local'
aisparser_wrap.o: In function `SwigPyPacked_print':
aisparser_wrap.c:(.text+0x1b0f): undefined reference to `__stack_chk_fail_local'
aisparser_wrap.o: In function `SwigPyPacked_repr':
aisparser_wrap.c:(.text+0x1bd4): undefined reference to `__stack_chk_fail_local'
aisparser_wrap.o: In function `SwigPyPacked_str':
aisparser_wrap.c:(.text+0x1c8f): undefined reference to `__stack_chk_fail_local'
aisparser_wrap.o: In function `SWIG_Python_ArgFail':
aisparser_wrap.c:(.text+0x2e42): undefined reference to `__stack_chk_fail_local'
aisparser_wrap.o:aisparser_wrap.c:(.text+0x44eb): more undefined references to `__stack_chk_fail_local' follow
ld: _aisparser.so: hidden symbol `__stack_chk_fail_local' isn't defined
ld: final link failed: Bad value

With a quick google search I found that I could add -fno-stack-protector as an option to the gcc command to avoid this stack smashing protection and it all worked and the examples worked as well. If there's a more elegant way around that error though, please let me know. Otherwise thanks for your help. :smiley:
Also, your English seems fine.

[edit] Fixed some English of my own.