Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'api.': 0.05; 'classes,': 0.05; 'compiler': 0.07; 'scheme.': 0.09; 'subject:trying': 0.09; 'to:addr:pobox.com': 0.09; 'to:addr:skip': 0.09; 'cc:addr:python- list': 0.11; 'python': 0.11; 'changes': 0.15; 'compiler.': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'written': 0.21; 'aug': 0.22; 'cc:addr:gmail.com': 0.22; 'handles': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**1': 0.23; 'accommodate': 0.24; 'dll': 0.24; 'library,': 0.24; 'skip': 0.24; 'subject: .': 0.24; 'second': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'chris': 0.29; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; 'easier': 0.31; '(possibly': 0.31; 'ctypes': 0.31; 'minor': 0.31; 'interface': 0.32; 'maybe': 0.34; 'received:74.125.82': 0.34; 'received:google.com': 0.35; 'c++': 0.36; 'should': 0.36; 'little': 0.38; 'received:74.125': 0.39; '12,': 0.39; 'how': 0.40; 'new': 0.61; 'name': 0.63; 'different': 0.65; 'typically,': 0.84; 'directly.': 0.95 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=GBWdAE5tlceTTDJETYj2ActlqvAkBeHyghNA5PTUiPk=; b=Z2SjM5bVtOBmTfDwtHqa41a1job2WHIz24MNhQWxoE8lC1aN3ekpF0r5FCyVrAmpKa FWq7M+Wm6xCCykINxYJFSWvOCLW6ww72GvPX6337N9Vtvp/VZLOuglh35DZSY9OBn4Jv Oh3MyKkcH97RXpmtdE8KiD+wLRt9c+Pxm3p1MdCL1LzTFzndVRdhBkGBw7PiY1Ejez4v J/vW4PI39iRAGmqkhrQHJy3fFlYjZoreklYZZHH9D1QLxB4cKLZ6+1H9wegCWEclUbnR UbW/zoI5ZF0PMscmamKzuefaSVKWmwV/0JbU5E4u+I4d8dECXKZtPbSHVsrVfnq2lZd9 Vx1A== X-Gm-Message-State: ALoCoQkJQ+Ke9w8S92YSqm/6bLEEAgL3N/ql+dDebJv/6HAm8CMN/TwFl90L/DkZTaJG2d1/tvSX X-Received: by 10.180.205.168 with SMTP id lh8mr411649wic.33.1407869734741; Tue, 12 Aug 2014 11:55:34 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <3dade0aa-55ca-4e52-af08-8104e9edf4c3@googlegroups.com> From: Chris Kaynor Date: Tue, 12 Aug 2014 11:55:14 -0700 Subject: Re: Begginer in python trying to load a .dll To: Skip Montanaro Content-Type: multipart/alternative; boundary=001a11c38ace6dfd9205007337d8 Cc: c1223 , Python X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 55 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1407869744 news.xs4all.nl 2922 [2001:888:2000:d::a6]:44209 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:76137 --001a11c38ace6dfd9205007337d8 Content-Type: text/plain; charset=UTF-8 On Tue, Aug 12, 2014 at 11:48 AM, Skip Montanaro wrote: > Just as the off-chance your DLL was written in C++... I don't think > you can interface with ctypes directly. I think you would have to > write a little shim DLL which exposes a C-compatible API. > You should be able to use ctypes with a C++ library, you'd just need to know how your C++ compiler handles name mangling. Typically, changes are made to accommodate classes, namespaces, and function overloads. Of course, if you were to change to a different compiler (possibly including a different version) or made minor tweaks to the functions, you'd have to update all the Python code to use the new name mangling scheme. Hmm...On second thought, maybe just only using functions exports with "extern C" would be easier - or just using a C compiler. Chris --001a11c38ace6dfd9205007337d8 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
On T= ue, Aug 12, 2014 at 11:48 AM, Skip Montanaro <skip@pobox.com> = wrote:
Just as the off-chance your DLL was written in C++... I don= 9;t think
you can interface with ctypes directly. I think you would have to
write a little shim DLL which exposes a C-compatible API.

You should be able to use ctypes with a C++ library, you'd j= ust need to know how your C++ compiler handles name mangling. Typically, ch= anges are made to accommodate classes, namespaces, and function overloads. = Of course, if you were to change to a different compiler (possibly includin= g a different version) or made minor tweaks to the functions, you'd hav= e to update all the Python code to use the new name mangling scheme.

Hmm...On se= cond thought, maybe just only using functions exports with "extern C&q= uot; would be easier - or just using a C compiler.

Chris
--001a11c38ace6dfd9205007337d8--