Saturday, February 7, 2009

Port over from Windows to Linux

My first experience to port from Windows to Linux. It is not an easy job although I have done the port over before in my previous project. That is port from a web base program (done in Java) into Windows base program (done using C++). To be more precisely, I am re-writing the whole code from ground up using MFC and C++. It is not port over.

My definition of port over means to make use of the same code to support multiple platform. For example, from a program done in MFC/C++ running on Windows platform into a program done using generic library running on Linux platform. Then this is defined as "Port over". Whereas from a program done in Java into a program done in C++ is as "Re-writing".

(That is my definition. Please leave your comment if you have other definition.)

Why is that difficult?

Because in LINUX are POSIX standard whereas Windows not. Thus if your code include some other library then you have to change it manually. Below are the sample:

Change from:

#include "MyDir\MyHeader.h"


#include "MyDir/MyHeader.h"

Imaging if you are support the legacy code, the work could be tedious.

Looking for library to replace the wn32 code. Simple example will be . There are many more like seriel code, multithreading code, and time. The most frequent type of library use in daily basis.

Never do you port over on Windows. I was using Cygwin and MinGW at initial stage, but now I have to redo almost everything from the beginning. Because the header specification in Cygwin, MinGW, and a real LINUX environment are different. Strict do your code in LINUX.

No comments: