Building PROJ.4 Library in Windows

First thing to do is to make sure all libraries are there. This is actually part of pre-application puzzle challenge. But then, the libraries are already in the github repo. This time, I would like to build it myself. just in case there will be another release during this project. I will only cover building under windows.

Using Visual Studio 2010
PROJ.4 usually come with autotools (autoconf and automake) but for VS, PROJ.4 comes with custom makefile (although no solution or VS project file). In order to build this library using visual studio, one can follow these steps:

  1. run cmd.exe as Administrator (this is important since my OS is 64-bit, otherwise it will generate errors with the debug informations)
  2. execute vcvars32.bat from visual studio directory (in my case it’s in VC\bin\vcvars32.bat)
  3. execute “nmake /f”
  4. if you want to install it then execute “nmake /f install-all”. It will then create a PROJ directory at C:\

Using MinGW/MSYS
I tried to build PROJ.4 by calling sh.exe from cmd but it was not seems to work and then I had to run from msys shell (by running msys.bat). BTW, I use latest MinGW distribution (using mingw-get). I guess these steps are similar with the steps to build a package in linux-based systems.

  1. open msys shell
  2. execute “./configure” from proj-x.y.z directory
  3. execute “./make”
  4. execute “./make install”

The whole building process is faster when using VS than MinGW even when configuring time is ignored. There is an issue though. At first, I was using “mingw32-make” command in which the build cannot be done. When i checked, the version of ‘mingw32-make’ is different with ‘make’. mingw32-make was mapped to later version (3.82.90 i686-pc-mingw32) while ‘make’ command was mapped to earlier version (3.81 i686-pc-msys).

Programmatically set core affinity in multicore environment

Prosesor multicore sudah tidak asing tetapi aplikasi yang umumnya dikembangkan biasanya hanya terdiri dari satu thread. Sejak dahulu ternyata sudah ada Win32 API untuk menentukan afinitas proses/thread ke prosesor tertentu. Kode di bawah menggunakan delphi 7.

Mendapatkan Jumlah core/Prosesor

  sinfo : TSystemInfo;
  { jumlah prosesor ada di field dwNumberOfProcessors } 

Menentukan Afinitas ke core tertentu
Afinitas ke core menggunakan bit vector. Tiap 1 bit diasosiasikan ke core tertentu mulai dari LSB. karena tipe data yang dilemparkan ke fungsi tsb adalah 32 bit unsigned integer maka mungkin maksimum prosesor yang bisa diakses sejumlah 32.

berikut ini contoh kode agar aplikasi yang sedang berjalan hanya menggunakan core pertama (cpu0) saja.

SetProcessAffinityMask(GetCurrentProcess, 1);

berikut ini contoh kode agar aplikasi yang sedang berjalan hanya menggunakan core pertama (cpu0) dan kedua (cpu1).

SetProcessAffinityMask(GetCurrentProcess, 3);

sedangkan berikut ini contoh kode agar aplikasi yang sedang berjalan hanya menggunakan core kedua (cpu0) saja.

SetProcessAffinityMask(GetCurrentProcess, 2);