What would be the equivalent of Win32 API in linux?

You need to understand what syscalls are. On Linux, they are the lowest possible user land API (in contrast Win32 API probably mixes real kernel syscalls with some libraries functions. libc also does such mix on Linux). fork(2), execve(2), open(2), pipe(2), mmap(2), read(2), poll(2), close(2), dup2(2), sigaction(2) are important syscalls (but there are about 300 of them, see syscalls(2) for a list, which depends upon your precise Linux kernel).

Don't expect each Windows functionality to be available on Linux (and vice versa).

Don't even think of such an equivalent.

Get a different mindset on Linux.

(In particular, processes are very different on Linux and on Windows).

Don't forget that Linux is free software, and you can dive into the source code of every function you are using on Linux. Read it, search it, improve it.....

Read the intro(2) man page first, and several other man pages (notably syscalls(2), intro(3) etc...). Read also e.g. Advanced Linux Programming and Advanced Unix Programming.

Some libraries try to factor out and provide a common abstraction for both Posix (e.g. Linux) and Windows. In particular Qt (and also Gtk or FLTK or POCO, and Wt for web applications, and sqlite for databases).

Some open source server software (e.g. lighttpd, exim, postgresql, etc...) can run on both Linux and Windows (of course, after recompilation)

If you are interested about graphical interface, understand the important role of X11 (notice that the X11 server is nearest to screen & keyboard; most graphical applications are X11 clients). In 2016 or 2020, X11 tend to be superseded by Wayland (but you won't notice that implementation "detail" - a really major one - if you code against Qt or GTK)

If you write an application using only Qt and/or POCO calls (those not documented as being specific to Linux or Windows) in addition of standard C++ functions, it should be source portable from Linux to Windows and vice versa.


If you want to port an application that uses Win32 calls, your best bet might be to use WineLib. This uses the libraries underpinning Wine, but it's not the same as just running an application using Wine -- you re-compile your application as a Linux application, just using the WineLib shared libraries. It will still look like a Windows application though, unless you then modify the UI layer.

As has been said elsewhere in the answers, there's no real direct equivalent to Win32 in Linux -- different bits of Win32 are provided by different components, and sometimes you've got a choice of components. This is possible because some equivalents of parts of Win32 are implemented natively at a lower level -- for example, Win32 provides UI components, equivalents to which are available in either GTK, Qt or any number of other toolkits (like WineLib), which themselves interact with X. Just as you would usually use components from Win32 rather than drawing your own using lower-level API calls, so you'd normally use components from your high-level UI toolkit rather than using X directly.

Tags:

Linux

Winapi

Api