What Would Be the Equivalent of Win32 API in Linux

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.

What is the equivalent to WinAPI in Linux and macOS?

Every operating system has its own API. Linux API for Linux and Cocoa (API) for Apple's operating systems. Also see Portable Operating System Interface for POSIX compatible operating systems.

using win32 api in linux?

You're looking for Winelib.

Is there a Core Linux API analogous to Windows WINAPI, in particular for creating GUI applications?

I think you're looking for something that doesn't exactly exist. Unlike the Win32 API, there is no "Linux API" for doing GUI applications. The closest you can get is the X protocol itself, which is a pretty low level way of doing GUI (it's much more detailed and archaic than Win32 GDI, for example). This is why there exist wrappers such as GTK and Qt that hide the details of the X protocol.

The X protocol is available to C programs using XLib.

WinAPI equivalent for Linux/POSIX pthread_wait/pthread_post

sem_wait() -> WaitForSingleObject() on a Semaphore object

pthread_join() -> WaitForSingleObject() on a Thread object

sem_post()-> ReleaseSemaphore() on a Semaphore object

See Using Semaphore Objects in MSDN's documentation.

Equivalent of lseek on Linux in Windows API?

It seems you're looking for SetFilePointer(), or SetFilePointerEx() if you require large file support.

In linux (or POSIX) function similar to win32 mem api

Read Advanced Linux Programming. Don't seek an exact equivalent in Linux for each functionality of Win32 that you know or want. Learn to natively think in Linux terms. Study free software similar to yours (see freecode or sourceforge to find some).

And yes, Posix or Linux vs Windows is very different, notably for their notion of processes, etc...

You probably want mmap(2) and mprotect(2); I don't know at all Windows (so I have no idea of what HeapCreate does).

Maybe using the lower layer of cross-platform toolkits like Qt (i.e. QtCore...) or Glib (from Gtk ...) might help you.

Linux C standard library is often GNU libc (but you could use some other, e.g. MUSL libc, which is very readable IMHO). It use syscalls listed in syscalls(2) and implemented by the Linux kernel (in particular, malloc(3) is generally built above mmap(2)...).

Take the habit of studying the source code of free software if that helps you.

BTW, for an interpreter, you could consider using Boehm's conservative garbage collector...



Related Topics



Leave a reply



Submit