Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Differences between C++ Cython wrapper and C++ program

Received: by 10.204.145.80 with SMTP id c16mr164391bkv.2.1324406350907;
        Tue, 20 Dec 2011 10:39:10 -0800 (PST)
X-BeenThere: cython-users@googlegroups.com
Received: by 10.204.200.144 with SMTP id ew16ls23012572bkb.2.gmail; Tue, 20
 Dec 2011 10:39:09 -0800 (PST)
Received: by 10.204.10.72 with SMTP id o8mr165409bko.1.1324406349427;
        Tue, 20 Dec 2011 10:39:09 -0800 (PST)
Received: by 10.204.10.72 with SMTP id o8mr165408bko.1.1324406349415;
        Tue, 20 Dec 2011 10:39:09 -0800 (PST)
Return-Path: <d.s.seljeb...@astro.uio.no>
Received: from mail-out2.uio.no (mail-out2.uio.no. [129.240.10.58])
        by gmr-mx.google.com with ESMTPS id e4si2317647bkv.1.2011.12.20.10.39.09
        (version=TLSv1/SSLv3 cipher=OTHER);
        Tue, 20 Dec 2011 10:39:09 -0800 (PST)
Received-SPF: pass (google.com: domain of d.s.seljeb...@astro.uio.no designates 129.240.10.58 as permitted sender) client-ip=129.240.10.58;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of d.s.seljeb...@astro.uio.no designates 129.240.10.58 as permitted sender) smtp.mail=d.s.seljeb...@astro.uio.no
Received: from mail-mx2.uio.no ([129.240.10.30])
	by mail-out2.uio.no with esmtp (Exim 4.75)
	(envelope-from <d.s.seljeb...@astro.uio.no>)
	id 1Rd4aj-0002fV-1n
	for cython-users@googlegroups.com; Tue, 20 Dec 2011 19:39:09 +0100
Received: from 213-64-141-15-no46.business.telia.com ([213.64.141.15] helo=[192.168.1.126])
	by mail-mx2.uio.no with esmtpsa (TLSv1:CAMELLIA256-SHA:256)
	user dagss (Exim 4.76)
	(envelope-from <d.s.seljeb...@astro.uio.no>)
	id 1Rd4ai-00006R-KC
	for cython-users@googlegroups.com; Tue, 20 Dec 2011 19:39:09 +0100
Message-ID: <4EF0D64A.6000809@astro.uio.no>
Date: Tue, 20 Dec 2011 19:39:06 +0100
From: Dag Sverre Seljebotn <d.s.seljeb...@astro.uio.no>
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110617 Thunderbird/3.1.11
MIME-Version: 1.0
To: cython-users@googlegroups.com
Subject: Differences between C++ Cython wrapper and C++ program
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-UiO-Ratelimit-Test: rcpts/h 2 msgs/h 2 sum rcpts/h 4 sum msgs/h 3 total rcpts 3227 max rcpts/h 27 ratelimit 0
X-UiO-Spam-info: not spam, SpamAssassin (score=-5.0, required=5.0, autolearn=disabled, UIO_MAIL_IS_INTERNAL=-5, uiobl=NO, uiouri=NO)
X-UiO-Scanned: 7DA1DEAEE871306A0C8A926137658494375D708C
X-UiO-SPAM-Test: remote_host: 213.64.141.15 spam_score: -49 maxlevel 80 minaction 2 bait 0 mail/h: 2 total 21 max/h 3 blacklist 0 greylist 0 ratelimit 0

Hi list,

I'm trying to wrap a proprietary, closed-source C++ library using 
Cython. The library essentially fails to work when used through a Cython 
wrapper, but works when compiling as a standalone executable with the 
same compiler flags.

I.e., I have a function "foomain" with some C++ code which attempts to 
make a certain network connection. If I call foomain() from main() in a 
C++ program, things work. If I call foomain() from Cython, compiled in 
C++ mode, then things don't work (no connection is made).

So what are the possible differences in the runtime environment you can 
think of?

The first thing I had to do was this:

import sys, ctypes
sys.setdlopenflags(sys.getdlopenflags()|ctypes.RTLD_GLOBAL)

This fixed something else (a function mysteriously returning a NULL 
pointer when it shouldn't -- as I don't have the sources I don't know 
why, really). But apparently it didn't fix everything.

I've tried both with and without creating a thread using the threading 
module (so that a GIL is set up), and both with and without "with nogil" 
around the call to foomain().


Dag Sverre