Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I'm moving from windows programming (By windows programming I mean using Windows API) to Linux Programming.

For programming Windows, the option we have is Win32API (MFC is just a C++ wrapper for the same).

I want to know if there is something like Linux API (equivalent to WINAPI) that is exposed directly to the programmer? Where can I find the reference?

With my little knowledge of POSIX library I see that it wraps around part of Linux API. But what about creating GUI applications? POSIX doesn't offer that. I know there are tons of 3rd party Widget toolkits like gtk, Qt etc. But I don't want to use the libraries that encapsulates Linux API. I want to learn using the "Core Linux API".

If there are somethings that I should know, please inform. Any programmer who is familiar with both Windows & Linux programming, please map the terminologies of Linux world so that I can quickly move on.

Any resources (books,tutorials,references) are highly appreciated.

like image 404
claws Avatar asked Feb 17 '10 00:02

claws


People also ask

What is the Linux equivalent of the Win32 API?

all POSIX linux/UNIX systems. The closest counterpart to the Win32 API is probably Xlib, and probably that combined with Xt.

What is Winapi used for?

Using the Windows API, you can develop applications that run successfully on all versions of Windows while taking advantage of the features and capabilities unique to each version. (Note that this was formerly called the Win32 API.

Does Linux have an API?

The Linux API is the kernel–user space API, which allows programs in user space to access system resources and services of the Linux kernel. It is composed out of the System Call Interface of the Linux kernel and the subroutines in the GNU C Library (glibc).

Can I use Win32 in Linux?

There are many ways to port and migrate from the Win32 C/C++ applications to the pSeries platform. You can use freeware or 3rd party tools to port the Win32 application code to move to Linux.


4 Answers

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.

like image 97
Greg Hewgill Avatar answered Oct 13 '22 02:10

Greg Hewgill


What you must understand is that Linux is very bare as to what is contained within it. The "Core" Linux API is POSIX and glibc. Linux is NOT graphical by default, so there is no core graphics library. Really, Windows could be stripped down to not have graphics also and thus not have parts of the win32 API like GDI. This you must understand. Linux is very lightweight compared to Windows.

For Linux there are two main graphical toolkits, GTK and Qt. I myself prefer GTK, but I'd research both. Also note that GTK and Qt exist for Windows to, because they are just wrappers. If you go take a look at the X protocol code for say xterm, you'll see why no one tries to actually creating graphical applications on top of it.

Oh, also SDL is pretty nice, it is pretty bare, but it is nice if your just needing a framebuffer for a window. It is portable between Linux and Windows and very easy to learn. But it will only stretch so far..

like image 43
Earlz Avatar answered Oct 13 '22 02:10

Earlz


Linux and win aren't quite as different as it looks.

On both systems there exists a kernel that is not graphical.

It's just that Microsoft doesn't document this kernel and publishes an API that references various different components.

On Unix, it's more transparent. There really is a (non-GUI) kernel API and it is published. Then, there are services that run on top of this, optionally, and their interfaces are published without an attempt to merge them into an imaginary layer that doesn't really exist.

So, the lowest GUI level is a the X Window System and it has a lowest level library called Xlib. There are various libraries that run on top of this one, as you have noted.

like image 33
DigitalRoss Avatar answered Oct 13 '22 00:10

DigitalRoss


I would highly recommended looking at the QT/C++ UI framework, it's arguably the most comprehensive UI toolkit for any platform.

We're using it at work developing cross platform apps that run on windows, osx and linux.

It also runs on Nokia's smart phone Operating System Maemo which has recently been merged with Intel's Moblin Linux OS, now called MeeGo.

like image 38
mythz Avatar answered Oct 13 '22 02:10

mythz