Cython dan mingw32

Sekedar catatan supaya ngga lupa dan supaya blog ini ada isi barunya xD

Kalau make Cython, kita bisa menambahkan perintah berikut di awal skrip Python agar setiap skrip Cython langsung dikompilasi secara otomatis.

import pyximport
pyximport.install()

Namun proses kompilasi bisa berakhir dengan gagal dengan pesan berikut.

Unable to find vcvarsall.bat

Oh iya, ini saya ngejalanin skripnya di atas Windows..

Saya ngga tau apa penyebabnya, mungkin ada hubungannya dengan Visual Studio dan mingw32 yang tidak begitu akur atau bagaimanalah itu. Yang jelas, salah satu solusinya adalah dengan menambahkan parameter pada pemanggilan pyximport.install() seperti berikut.

mingw_setup_args={'options': {'build_ext': {'compiler': 'mingw32'}}}
import pyximport; pyximport.install(setup_args=mingw_setup_args)

Sumber: Stack Overflow

Compiling OpenSceneGraph on Windows

.. now, I’m using MinGW/MSYS (what’s the difference btw?) instead of Visual Studio. Apparently, those two can’t cope each other and since I’m gonna use Eclipse with MinGW/MSYS, I have to compile the OpenSceneGraph (OSG) with MinGW/MSYS too.

The good news is, OSG uses CMake. It helps a lot when dealing with many build system on many platforms (as long as it supports of course).

  1. First, prepare the ammunition. Download CMake, MinGW/MSYS, OSG, and also OSG’s required 3rdParty libraries. Installing CMake should be straight forward. But maybe not the case for MinGW and MSYS. I already forgot how to install it, so just ask Google for this one =D

  2. Extract the OSG somewhere, for example C:OpenSceneGraph-2.6.1OpenSceneGraph-2.6.1. I have it extracted there already, so I just use it. Also don’t forget to extract the 3rdParty bundle into C:OpenSceneGraph-2.6.13rdParty.

  3. Open CMake, point the source code directory to that directory, and also set the build directory if you don’t want to mess the source directory like me.

  4. Click the configure button and select MSYS Makefiles for the generator.

  5. CMake will then do the initial configuration. Adjust some configurations to fit your needs, such as CMAKE_INSTALL_PREFIX if you want to change the OSG installation directory.

    In my case, I also have to turn off the BUILD_OSG_PLUGINS option because it needs some other libraries which I don’t know. Since I just want to get the OSG compiled, it is easier for me to turn this one off rather than finding the libraries.

  6. Click the configure button again.. and maybe again.. until the OK button can get clicked.

  7. Finish the CMake by clicking the OK button. It will generate the requested build system.

  8. Open the MSYS console. Go to the OSG build directory and let the two left “magic commands” do their job. The “configure” part is already done by CMake.

    $ make
    

    and finally..

    $ make install
    
  9. Let your fingers crossed, grab some tea or coffee, and wait until the compilation ends (hopefully).

Then.. let the coding continues.. =)

Find the source code at http://gist.github.com/55138

Compiling OpenSceneGraph on Windows

.. now, I’m using MinGW/MSYS (what’s the difference btw?) instead of Visual Studio. Apparently, those two can’t cope each other and since I’m gonna use Eclipse with MinGW/MSYS, I have to compile the OpenSceneGraph (OSG) with MinGW/MSYS too.

The good news is, OSG uses CMake. It helps a lot when dealing with many build system on many platforms (as long as it supports of course).

  1. First, prepare the ammunition. Download CMake, MinGW/MSYS, OSG, and also OSG’s required 3rdParty libraries. Installing CMake should be straight forward. But maybe not the case for MinGW and MSYS. I already forgot how to install it, so just ask Google for this one =D

  2. Extract the OSG somewhere, for example C:OpenSceneGraph-2.6.1OpenSceneGraph-2.6.1. I have it extracted there already, so I just use it. Also don’t forget to extract the 3rdParty bundle into C:OpenSceneGraph-2.6.13rdParty.

  3. Open CMake, point the source code directory to that directory, and also set the build directory if you don’t want to mess the source directory like me.

  4. Click the configure button and select MSYS Makefiles for the generator.

  5. CMake will then do the initial configuration. Adjust some configurations to fit your needs, such as CMAKE_INSTALL_PREFIX if you want to change the OSG installation directory.

    In my case, I also have to turn off the BUILD_OSG_PLUGINS option because it needs some other libraries which I don’t know. Since I just want to get the OSG compiled, it is easier for me to turn this one off rather than finding the libraries.

  6. Click the configure button again.. and maybe again.. until the OK button can get clicked.

  7. Finish the CMake by clicking the OK button. It will generate the requested build system.

  8. Open the MSYS console. Go to the OSG build directory and let the two left “magic commands” do their job. The “configure” part is already done by CMake.

    $ make
    

    and finally..

    $ make install
    
  9. Let your fingers crossed, grab some tea or coffee, and wait until the compilation ends (hopefully).

Then.. let the coding continues.. =)

Find the source code at http://gist.github.com/55138