Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 12 Feb 2015 16:12:17 -0800
From:      Craig Rodrigues <rodrigc@FreeBSD.org>
To:        freebsd-python@freebsd.org
Subject:   ctypes problem loading libc.so on FreeBSD current
Message-ID:  <CAG=rPVehh4ZBBKdmJb8tVy_H=CgbALwUqcC7yofwrJHPVC-1zQ@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
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@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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAG=rPVehh4ZBBKdmJb8tVy_H=CgbALwUqcC7yofwrJHPVC-1zQ>