Calling C from Python

Chris Gonnerman chris.gonnerman at usa.net
Wed Feb 21 08:33:01 EST 2001


----- Original Message -----
From: <Rich_Somerfield at tertio.com>
Subject: Re: Calling C from Python


> Thanks for the reply.
>
> My OS is SunOS 5.6.  The message I get from CC (I am using Sun Workshop
> compiler (CC: WorkShop Compilers 5.0 98/12/15 C++ 5.0) is :

Ur.  Not familiar with SunOS anymore...

> CC -o new

new.c -I/opt/Python-2.0/Include -I/opt/Python-2.0 -L/opt/Python-2.0/Modules 
-L/opt/Python-2.0 -L/opt/Python-2.0/Lib -lpython2.0
>
> Undefined                       first referenced
>  symbol                             in file
> socket
/opt/Python-2.0/libpython2.0.a(socketmodule.o)
> getpeername
/opt/Python-2.0/libpython2.0.a(socketmodule.o)
> recv
/opt/Python-2.0/libpython2.0.a(socketmodule.o)
> getprotobyname
/opt/Python-2.0/libpython2.0.a(socketmodule.o)
> accept
/opt/Python-2.0/libpython2.0.a(socketmodule.o)
> gethostbyname_r
/opt/Python-2.0/libpython2.0.a(socketmodule.o)
> send
/opt/Python-2.0/libpython2.0.a(socketmodule.o)
> bind
/opt/Python-2.0/libpython2.0.a(socketmodule.o)
> setsockopt
/opt/Python-2.0/libpython2.0.a(socketmodule.o)
> getservbyname
/opt/Python-2.0/libpython2.0.a(socketmodule.o)
> getsockopt
/opt/Python-2.0/libpython2.0.a(socketmodule.o)
> inet_addr
/opt/Python-2.0/libpython2.0.a(socketmodule.o)
> sendto
/opt/Python-2.0/libpython2.0.a(socketmodule.o)
> inet_ntoa
/opt/Python-2.0/libpython2.0.a(socketmodule.o)
> shutdown
/opt/Python-2.0/libpython2.0.a(socketmodule.o)
> getsockname
/opt/Python-2.0/libpython2.0.a(socketmodule.o)
> gethostbyaddr_r
/opt/Python-2.0/libpython2.0.a(socketmodule.o)

This batch of errors is complaining that socket functionality is missing.  I
find this most puzzling.
On Linux, I don't need to load any additional libraries for socket support,
but I suppose on
SunOS you might need to.

> dlsym
/opt/Python-2.0/libpython2.0.a(dynload_shlib.o)  (symbol belongs to implicit
dependency /usr/lib/libdl.so.1)
> dlopen
/opt/Python-2.0/libpython2.0.a(dynload_shlib.o)  (symbol belongs to implicit
dependency /usr/lib/libdl.so.1)
> __eprintf
/opt/Python-2.0/libpython2.0.a(longobject.o)
> dlerror
/opt/Python-2.0/libpython2.0.a(dynload_shlib.o)  (symbol belongs to implicit
dependency /usr/lib/libdl.so.1)
> recvfrom
/opt/Python-2.0/libpython2.0.a(socketmodule.o)
> listen
/opt/Python-2.0/libpython2.0.a(socketmodule.o)
> connect
/opt/Python-2.0/libpython2.0.a(socketmodule.o)
> ld: fatal: Symbol referencing errors. No output written to new
>
> Do i need to include all of these library files or should the compiler
pick them up from the specified lib directory in the compile command?  Is
these
>  are specific list of libs that I need to include to compile for Python?

I'm not sure you need ALL of those options but they shouldn't hurt.  It
looks like you need an
additional -l... option or two, but I can't say for sure.

I hope there is a SunOS user out there reading this...

> Regards,
> RS.






More information about the Python-list mailing list