opc0de
opc0de

Reputation: 11768

Porting windows application to linux

I have an application which I need to port on Linux. I was thinking to use Free Pascal the problem is the application uses Windows API's to perform tasks such as serial port communication etc... Is there a msdn for linux users or a book covering how linux works internaly if there are apis.

I am very confused.

Upvotes: 0

Views: 6232

Answers (5)

Menace
Menace

Reputation: 1070

I've had great experiences just using WINE. (https://www.winehq.org/) You don't really port your app at all. You just make sure it doesnt violate some of the basc constraints of WINE and just run it as is. WINE (though is says it is not) is an emulator of the windows API's and will just do the translation for you. It's pretty complete in its coverage of the API's.

Upvotes: 0

abc
abc

Reputation: 1

A useful library for this kind of problems i've found at http://www.adontec.com/windows-to-linux-port-library.htm

Upvotes: 0

sostim
sostim

Reputation: 11

If the program contains GUI code you must use linux libraries like GTK/XLIB in order to create windows, forms, buttons, etc...

Windows specific functions (like EnterCriticalSection, WaitForSingleObject or _beginthreadex) must be replaced with equivalent linux api functions (a nice tutorial can be found here: "www.ibm.com/developerworks/systems/library/es-MigratingWin32toLinux.html") or you can use libraries such as w2lpl or wine

Upvotes: 1

adrianmcmenamin
adrianmcmenamin

Reputation: 1129

Robert Love has a book on Linux Systems Programming - that will cover this area and Love's books are generally good, so it is worth looking at.

It's not entirely clear from your question, but if your concern is that there are specific calls to hardware controlling functions in your Windows application that make it difficult to port I would suggest that is a misplaced fear. Both Windows and Linux operate on the principle that the application level programmer should be kept away from the hardware and that all that should be handled by the operating system kernel and only be accessible to applications via system calls. As the kernels of different operating systems face similar demands from users/applications, they tend to have system calls that do the same sorts of things. It is necessary to match the system calls to one another but I can see no reason why that should be impossible.

What may be more troublesome is that your Windows application may rely heavily on the Windows executive's windowing code/API. Again finding analogues for your code is not impossible but is likely to be a bit more complex e.g. in Linux this stuff is generally not handled in the kernel at all (unlike Windows).

But then again, your code may be written against a portable toolkit/library like Qt which would make things a lot easier.

Good luck in any case.

Upvotes: 4

cezar
cezar

Reputation: 587

Well, it's sad to say but if your code in very Windows-dependend (not VCL depended!) then probably it'll be faster to write the application from the begining rather then porting it.

But if it's only serial port matter then give a try to multiplatform SynaSer library, find it here: http://synapse.ararat.cz.

hope this help :)

Upvotes: 5

Related Questions