Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What should I use instead of windows.h in Linux? [closed]

Tags:

c++

linux

porting

I am trying to port a Windows program to Linux. I have never programmed in Linux and have very little idea what I am doing. I have managed to eliminate a lot of the errors I got in the G++ compiler on Linux and have traced most of the remaining ones to non existent variable types.

I took out the windows.h file but I do know know what to do with the CALLBACK, HANDLE, DWORD and HHOOK variables. Apparently there is no equivalent to HANDLE in Linux so I think I may have to rewrite some of the structure.

Can anyone explain what I should be doing or point me to some tutorials that teach me how to do these things in Linux?

My program runs a polling loop on an RS-485 network if that helps.

like image 278
Skeith Avatar asked Sep 06 '11 09:09

Skeith


1 Answers

The missing typedefs (HANDLE etc.) aren’t your problem. Your problem is that Linux and Windows have completely different APIs, you cannot simply hope to port one to the other by replacing a few type definitions.

The complete platform-dependent portion of your code has to be replaced. Your first step is therefore to learn the Linux API. The best way of doing this is getting a book on Linux programming.

Furthermore, Linux doesn’t provide a default API for window management as does Windows so if you are programming a graphical application then you need to choose a windowing library as well.

like image 154
Konrad Rudolph Avatar answered Sep 21 '22 00:09

Konrad Rudolph