From owner-freebsd-python@FreeBSD.ORG Fri Feb 13 00:12:20 2015 Return-Path: Delivered-To: freebsd-python@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 4EA557E6 for ; Fri, 13 Feb 2015 00:12:20 +0000 (UTC) Received: from mail-lb0-x231.google.com (mail-lb0-x231.google.com [IPv6:2a00:1450:4010:c04::231]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C25F6232 for ; Fri, 13 Feb 2015 00:12:19 +0000 (UTC) Received: by mail-lb0-f177.google.com with SMTP id z11so12595726lbi.8 for ; Thu, 12 Feb 2015 16:12:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:date:message-id:subject:from:to:content-type; bh=XoZIK7YHa1oZc/sRgT2NAFxDO8tsp7vJGq6OhVSSTj0=; b=DZwZXRGaGUQanCVOOBBcmTFpVBWGjOw7yh2zUpOeJDnyriCYgioeLFCnChvZ2QWjKp 5L3LhBSHMJVzv/Os7mXIakcQ5iU5HV/rp9/DeFeT+LFaXVq7h0dfOLvFF1E3KQrPi8+n LY3szvxF2/UgaqIvVA0WfTk377W2NvZkuYcUOcly2rxyn+voWksjdkxr+I0gkusgKXpo i/g9jr5R7V8kEFjh9l2GUJypB6bR68o98cXyUwQ3E7LAeZ9CKDZrVpAEtrlJ9CKq94Hw ORUANKdE6INvwdRtUOLYlHHJzyvzLZjrM/NlUtMVi7/0iOshyv/vM8Tg6PyFCxvFjShj 6oGA== MIME-Version: 1.0 X-Received: by 10.152.87.84 with SMTP id v20mr5464541laz.81.1423786337414; Thu, 12 Feb 2015 16:12:17 -0800 (PST) Sender: crodr001@gmail.com Received: by 10.112.28.40 with HTTP; Thu, 12 Feb 2015 16:12:17 -0800 (PST) Date: Thu, 12 Feb 2015 16:12:17 -0800 X-Google-Sender-Auth: NB1cyWMijVCsNmSDmdAUlVm9Q0Q Message-ID: Subject: ctypes problem loading libc.so on FreeBSD current From: Craig Rodrigues To: freebsd-python@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.18-1 X-BeenThere: freebsd-python@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: FreeBSD-specific Python issues List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Feb 2015 00:12:20 -0000 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 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