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

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.


There's no "equivalent", so to speak, for windows.h in Linux, you need to fix your errors case by case, or better, rewrite your code for linux (if it's not too complicated).

However, if we ignore windows specific APIs, you may be able to fix typedef errors (DWORD, HANDLE, ...):

#ifndef DWORD
#define WINAPI
typedef unsigned long DWORD;
typedef short WCHAR;
typedef void * HANDLE;
#define MAX_PATH    PATH_MAX
typedef unsigned char BYTE;
typedef unsigned short WORD;
typedef unsigned int BOOL;
#endif

typedef source code

Tags:

Linux

C++

Porting