Home - Forums - Documentation - Gallery - Bugs


Compiling Python bindings with MSVC

What you need

This tutorial explains you, how you can build cspython, _cspace, and CEL blpython plugins with MSVC. First, I assume, you succeslfully compiled CS (and optionally CEL). You can find the comlete guide to do this in the manual. Get python packages from the official site, and download a Windows binary package. Install it. Finally, download the correct cs_pyth.cpp from here. Extract the zip file, and copy int your CS/plugins/cscript/csypthon directory. Yes, rewrite the original file. Preparation finished.

Setting up MSVC IDE

1. Run MSVC IDE. 2. Go to the Tools->Options->Projects and Solutions->VC++ Directories Select Include files above. Click to New Line icon, and type or select your Python"2X/Include directory. 3. Select Library files Click to New Line icon, and type or select your Python"2X/libs directory.

From now MSVC will find Python related headers and directories.

Creating the solution

Click to the File->New->Project... and select Win32 console application template. Add a name to your solution (csypthon is ideal), select the location of your project.

Click to the ok. Now click to the Application settings. Set as DLL project and check the Empty project box. Now click to the finish button.

Now click to the Solution explorer, right click to the Headers->Add existing item.... Add the following headers to your project from your CS/plugins/cscript/cspython directory:

Noe right click to the source files, Add existing item, then add the following source files to your project from your CS/plugins/cscript/cspython directory:


Now right click to the Resource files, add existing item. Navigate to your CS/mk/msvc directroy, and add cspython.rc to your project.

Press F7 to build the solution.

| Article | Discussion | View source | History |