On Wed, Oct 3, 2012 at 7:21 AM, Brad Buran <
bbu...@gmail.com> wrote:
> I'm trying to write a Cython wrapper around a library for reading from a
> (proprietary) binary file format. The vendor has released versions of the
> library (called "MCStream" on Linux and "MC_StreamAnsiLib" on Windows)
> compiled for Linux and Windows. I've been able to successfully get the
> Cython wrapper working under Linux; however, the version of the vendor's
> library for Windows is linked against the boost C++ library. Hence, I need
> to compile the boost library on Windows for linking.
Wow! this is pretty painful for a binary-only proprietary library (I'm
assuming you do not get the source code so that you could re-compile
the lib yourself?)
> I was able to successfully do this and compile/link a test C++ file with the
> MCStream library and the boost libraries, but only when using Microsoft
> Visual Studio 10. Based on what I understand from various newsgroups, the
> boost library must be compiled/linked using the same version of MS Visual
> Studio that MCStream was compiled under.
that does seem likely but probaly not your issue anyway...
> However, I understand that Cython uses Visual Studio 9 (at least that's the
> default executable used when I run "python setup.py build_ext --inplace").
To be clear, it is not Cython that uses an particular version of a
compiler, it is distutils, which is designed to compile Python
extensions with the same compiler that python itself was built with.
The Python binaries distributed by
python.org were built with
particular versions (usually a bit old) 2.7 was built with VS2008, for
instance (is that the same as 9? -- the dula naming conversion drives
me crazy!)
> Consequently, I get a lot of "unresolved external symbol" errors that are
> associated with the failure to properly link the boost libraries with the
> MCStream executable.
HMM -- if I have this right: MCStream uses Boost (or some of it,
anyway). But that should be independent of your Cython code -- it
should be calling the MCStream API directly (or are there data types,
etc, provided by Boost that you need to use to call MCStream?)
Anyway -- while distutils, by default, uses the compiler PYthon was
built with, as I understand nit, it isn't absolutely required that
that be the case -- the issues are less with the compiler than with
the the stdlib that is used by the compiler -- and only SOME of the
stdlib functions require compatibility (I think file handles is a
common issue, for instance) but if the two versions of the compiler
have a compatible ABI (which I"d guess they do?) then you *might* be
able to compile your extension with the newer compiler.
I'm not sure how to force distutils to use a different one, but I'd
start by compiling an extension by hand to test whether it will work.
You may also be abel to make a little layer: put the boost stuff in a
C++ layer that calls the dll, and have your Cyton code call this layer
(free of Boost types).
A final option is to re-compile Python itself with VS 9 -- then it'll
all the the same.
> below, actual error is at the bottom). As you can see, the error relates to
> it being unable to find the references defined in the MCStream library;
I don't know if minGW is ABI-compatible with MS VS for C++ (it does
work for C, but there is no standard ABI for C++)
HTH,
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R
(206) 526-6959 voice
7600 Sand Point Way NE
(206) 526-6329 fax
Seattle, WA 98115
(206) 526-6317 main reception
Chris....@noaa.gov