Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.swapon.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Veek M Newsgroups: comp.lang.python Subject: Python extension using a C library with one 'hello' function Followup-To: comp.lang.python Date: Tue, 04 Nov 2014 16:22:52 +0630 Organization: Home Lines: 50 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit Injection-Date: Tue, 4 Nov 2014 10:52:41 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="f68a2336b1bb3a5b9be9c6035d2d5633"; logging-data="21464"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+22X6+C4gTaVjj2tYGzUm4" User-Agent: KNode/4.4.11 Cancel-Lock: sha1:tm8m1WmwcESlGK6zZTNMq2n6mrM= Xref: csiph.com comp.lang.python:80170 https://github.com/Veek/Python/tree/master/junk/hello doesn't work. I have: hello.c which contains: int hello(void); hello.h To wrap that up, i have: hello.py -> _hello (c extension) -> pyhello.c -> method py_hello() People using this will do: python3.2>> import hello python3.2>> hello.hello() It doesn't compile/work. deathstar> python setup.py build_ext --inplace running build_ext building '_hello' extension creating build creating build/temp.linux-x86_64-3.2 gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes - D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat - Werror=format-security -fPIC -I/usr/include/python3.2mu -c pyhello.c -o build/temp.linux-x86_64-3.2/pyhello.o pyhello.c:15:6: warning: character constant too long for its type [enabled by default] pyhello.c:15:5: warning: initialization makes pointer from integer without a cast [enabled by default] pyhello.c:15:5: warning: (near initialization for 'hellomethods[0].ml_name') [enabled by default] pyhello.c:15:5: warning: initialization from incompatible pointer type [enabled by default] pyhello.c:15:5: warning: (near initialization for 'hellomethods[0].ml_meth') [enabled by default] pyhello.c:15:5: warning: initialization makes integer from pointer without a cast [enabled by default] pyhello.c:15:5: warning: (near initialization for 'hellomethods[0].ml_flags') [enabled by default] gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro build/temp.linux-x86_64-3.2/pyhello.o -o /root/github/junk/hello/_hello.cpython-32mu.so >>> import hello Traceback (most recent call last): File "", line 1, in File "hello.py", line 1, in from _hello import * ImportError: ./_hello.cpython-32mu.so: undefined symbol: hello >>>