Linux API?

BlitzMax Forums/BlitzMax Programming/Linux API?

Vertex(Posted 2005) [#1]
Hi!
Is there a Linux API like WinAPI?
Extern "Os"
	Function s_accept:Int(iSocket:Int, tAddr:Byte Ptr, ipAddrLen:Int Ptr) = "accept@12"
End Extern


/opt/blitzmax/mod/pub.mod/bnet.mod/bnet.d.a(bnet.bmx.d.o)(code+0x
ion `_pub_bnet_TTCPServer_AcceptTCPStream':
: undefined reference to `accept@12'


But Windows AND Linux have this command oO

In the socket.h from Linux there is:
/* Await a connection on socket FD.
   When a connection arrives, open a new socket to communicate with it,
   set *ADDR (which is *ADDR_LEN bytes long) to the address of the connecting
   peer and *ADDR_LEN to the address's actual length, and return the
   new socket's descriptor, or -1 for errors.

   This function is a cancellation point and therefore not marked with
   __THROW.  */
extern int accept (int __fd, __SOCKADDR_ARG __addr,
		   socklen_t *__restrict __addr_len);


Only is declared as extern. I don't know how Linux work :(

cu olli


SurreaL(Posted 2005) [#2]
Yes there is a Linux API just like there is a Windows one. However neither API is directly included in BlitzMax. (IE you can't just call the functions like they were already imported)

This means you will have to manually do it.. check out how the stdc module does it. There is a .c source which is imported into the module, and that c source has include directives to include the relevant API header files. You would have to do something similar, I would imagine.


Vertex(Posted 2005) [#3]
Thank you! The problem was, in Windows I must use "accept@12" but in Linux only "accept". Now it works fine :)

Is there a API docu like MSDN? Whats with GUI? Use all desktopstuff like KDE or GNOME the same functions to create a window, a button etc.?
cu olli


Ole JR(Posted 2005) [#4]
No there's no one-place API doc for Linux, like msdn..
And KDE and GNOME don't use the same functions.

Here are some links to different things Linux, but there are many more around..
This one is a must, GNU C library (glibc): http://www.gnu.org/software/libc/manual/
And the rest is GUI stuff.
GTK(gnome?): http://www.gtk.org/api/
KDE: http://developer.kde.org/
X (Xorg): http://www.x.org/X11R6.8.2/doc/


Richard B(Posted 2005) [#5]
Hi Guys,
Does anyone know how to hook in to the corresponding API in OSX.

thanks,
Richard.


Todd(Posted 2005) [#6]
Hi,

Windows and Linux are very different platforms. This is mainly because there is no one person or organization that creates Linux. It's created by thousands of people all over the world. This also means that there's no "built-in" GUI library like there is in Windows.

However, almost every Linux GUI app is based on the X Window System, or X11 for short. There are a few others, but they aren't very common. You could program all of your GUI stuff directly in the X Windows API, but you would most likely find it extremely challenging. Because programming directly in X isn't a very easy thing to do, people have developed GUI libraries to do the hard part for you.

One of them is called GTK+, which was developed specifically for the GIMP project, but is now widely used in Linux apps. It's also the foundation of the GNOME desktop. It's API's should be accessible from within BlitzMax, provided you import them correctly, and find a way to define all of the constants that are used. Also, you'll find GTK+ in almost every Linux desktop. RedHat/Fedora, Mandrake and SuSE install them by default, and they are very easy to install on Debian, Gentoo and others.

Another graphics system that was developed for Linux is QT. This library is most commonly known for it's use in the KDE desktop, altough KDE also has it's own set of API's that extends QT's. I'm not sure if it's possible to develop QT-based apps in BlitzMax due to the fact that the library is C++ only.

There are also other, less well-known GUI's like FLTK and wxWidgets. I think you're best bet, however, is to learn GTK. I've written several apps in GTK (in C, ASM, and Python) and it's pretty easy to learn and to use. GTK is available for Mac and Windows, too, so it would also allow you to port your apps to the other platforms without having to come up with a GUI module for each platform.

Does anyone know how to hook in to the corresponding API in OSX.
Assuming you mean OS X's native graphics API's, you should take a look at the Carbon API's. They're designed for C/C++ of course, but they should work in BlitzMax as well. I haven't tested it, though. You can find the documentation on Apple's developer site.