Installing pymatbridge on Windows

后端 未结 3 1505
醉话见心
醉话见心 2021-01-14 08:22

In version 0.3 of pymatbridge, an additional dependency was added for ZMQ. To install this version, you might therefore need to compile a messenger mex extensio

相关标签:
3条回答
  • 2021-01-14 08:53

    Some of the other answers are a little bit outdated, and this can be done much more easily now (still won't be as easy on a Linux system :/). First of all, pymatbridge now includes a binary mex on Windows which is statically linked to libzmq, so you shouldn't actually have to compile anything to get it to work.

    However, if you still want to do compile it from source, the process isn't too bad for a dynamically linked library.

    1) Install zeromq from the website: http://zeromq.org/distro:microsoft-windows

    2) Rename one of the lib/libzmq-*.lib files to libzmq.lib in the ZeroMQ installation directory

    3) Add the ZeroMQ bin directory to your path.

    4) Edit the messenger/mexw64/local.cfg file in messenger to point to the zeromq install directory (you will need to update both ZMQ_INC and ZMQ_LIB). Also ensure the MATLAB directory is correct.

    5) Run make.py matlab in the messenger directory. This should build messenger.mexw64

    A statically linked library is simple in practice, but because zeromq (as of now) does not provide a .lib for static linking with the windows installer, you will need to compile this yourself. After you have a static .lib, build messenger.mexw64 with make matlab --static

    0 讨论(0)
  • 2021-01-14 08:59

    Here's my setup and build instructions; apologies for the verbosity -- this is from a write-up I did for my lab notebook.

    Specifications:

    Windows 8.1 (64 bit)
    Anaconda 1.9.1
    python 2.7.6
    MinGW
    TDM GCC 4.8.1
    

    First I installed MS Visual C++ & SDK 7.1. Possible reason for the install to fail quite early on is the presence of other Visual C++ compiler versions and/or SDKs -- before successfully installing SDK 7.1 I had to uninstall quite a few of them.

    First, using the Windows SDK 7.1 Command Prompt, I

    mex -setup
    

    and selected the newly installed compiler. In my case

    Select a compiler:
    [1] Microsoft Software Development Kit (SDK) 7.1 in 
    C:\Program Files (x86)\Microsoft Visual Studio 10.0
    
    [0] None
    
    Compiler:
    

    I elected to pick number 1. Next I downloaded and installed a prebuilt 64 bit ZMQ 3.2.4, and from the ZMQ 3.2.4 install location, C:\Program Files\ZeroMQ 3.2.4\lib, I copied libzmq-v90-mt_3_2_4.lib, and libzmq-v90-mt_3_2_4.dll from C:\Program Files\ZeroMQ 3.2.4\bin to the messenger build directory, ~\python-matlab-bridge\messenger\src. I also put zmq.h and zmq_utils.h into that directory but as of now am unsure if they are really necessary.

    Then, in the Windows SDK 7.1 Command Prompt, I cded into the messenger\src directory and issued

    mex messenger.c libzmq-v90-mt-3_2_4.lib -O -output messenger
    

    to obtain a messenger.mexw64. Finally, in the ~\python-matlab-bridge directory, using MinGW, I just

    python setup.py install
    

    This automatically put the built package into my Anaconda\Lib\site-packages along with an egg info. In Anaconda\Lib\site-packages\pymatbridge\matlab there is the messenger.mexw64 that was built earlier -- from ~\python-matlab-bridge\messenger\src. I also copied to Anaconda\Lib\site-packages\pymatbridge\matlab all other .dlls, .libs and .hs for good measure. Now in the iPython 2.7 console, or an iPython Notebook, I can

    %load_ext pymatbridge
    

    successfully.

    0 讨论(0)
  • 2021-01-14 09:01

    As I use Visual Studio as my standard IDE I fiddled around and got a working build process. I used:

    VS 2013
    Matlab 2013b x64
    Python 3.3 x64
    ZeroMQ 4.0.4.
    

    If you use different Versions please make sure that you adjust the Path where necessary.

    Build messenger using Visual Studio (2013)

    • First create a new Solution with an empty C++ Project.
    • Set up the configuration, e.g. x64 Release
    • Open up the Project Properties and set up the following:

    Configuartion Properties -> General:

    Target Name: messenger

    Target Extension: .mexw64

    Configuration Type: Dynamic Library (.dll)

    Configuartion Properties -> VC++ Directories -> Include Directories:

    MATLABPATH \extern\include

    ZEROMQ PATH\include

    Configuartion Properties -> VC++ Directories -> Library Directories:

    MATLABPATH \extern\lib\win64\microsoft

    ZEROMQ PATH \lib

    Configuartion Properties -> Linker -> Input -> Additional Dependencies:

    libmx.lib; libmex.lib; libmat.lib; libzmq-v120-mt-4_0_4.dll

    Configuartion Properties -> Linker ->Command Line -> Additional Options:

    /export:mexFunction

    • Add messenger.c as source file
    • Build the library
    • Copy it to: PYTHONPATH \Lib\site-packages\pymatbridge\matlab\

    Please Note:

    I got some incompatible error cause by the function names already present in windows.h. The solution was to rename:

    • initialize
    • listen
    • respond
    • cleanup

    to:

    • initializeMat
    • listenMat
    • respondMat
    • cleanupMat
    0 讨论(0)
提交回复
热议问题