ctypes problem loading libc.so on FreeBSD current
Craig Rodrigues
rodrigc at FreeBSD.org
Fri Feb 13 00:12:20 UTC 2015
Hi,
I am looking at this blog post for loading libc with ctypes:
http://blogs.freebsdish.org/rpaulo/2008/11/30/sysctlbyname3-and-others-from-python/
I am using this version of python from ports:
Name : python
Version : 2.7_2,2
Installed on : Mon Jan 12 22:10:27 PST 2015
Origin : lang/python
Architecture : freebsd:11:x86:64
Prefix : /usr/local
Categories : python lang ipv6
Licenses :
Maintainer : python at FreeBSD.org
WWW : http://www.python.org/
Comment : The "meta-port" for the default version of Python
interpreter
Annotations :
repo_type : binary
repository : FreeBSD
Flat size : 38.0B
Description :
Python is an interpreted object-oriented programming language, and is
often compared to Tcl, Perl or Scheme.
This is a meta port to the Python interpreter and provides symbolic links
to bin/python, bin/pydoc, bin/idle and so on to allow compatibility with
version agnostic python scripts.
WWW: http://www.python.org/
I have this test program
import ctypes
mylib = ctypes.CDLL("libc.so")
print(mylib)
On FreeBSD 9, this program works, and I get a handle to libc.so.
On FreeBSD-CURRENT, I get this:
File "a.py", line 3, in <module>
mylib = ctypes.CDLL("libc.so")
File "/usr/local/lib/python2.7/ctypes/__init__.py", line 365, in __init__
self._handle = _dlopen(self._name, mode)
OSError: /usr/lib/libc.so: invalid file format
The problem seems to be that on FreeBSD 9,
/usr/lib/libc.so is a symlink to /lib/libc.so.7, while
on FreeBSD-CURRENT, /usr/lib/libc.so contains this:
/* $FreeBSD: head/lib/libc/libc.ldscript 258283 2013-11-17 22:52:17Z peter
$ */
GROUP ( /lib/libc.so.7 /usr/lib/libc_nonshared.a
/usr/lib/libssp_nonshared.a )
Any ideas what the problem is?
--
Craig
More information about the freebsd-python
mailing list