how are libraries written.

Hey guys,

so I've always wondered this,

how are libraries and frameworks such as SDL,FLTK,OPENGL,QT,SFML etc... written?

obviously they have to be written using existing libraries

my guess would be all these libraries are written using the native operating systems APIs be it Windows.h and it's associates such as winsock , etc and for Linux I'm guessing the Linux API.

thanks

some of those are open-source.... you can look at the code.

graphics libraries have 2 choices: they can call existing libraries (like some of the ones that sit on top of opengl or directx or the like) or they can talk to the os/hardware on their own. The ones that talk to hardware on their own are going to have a non-portable segment that is specific to that os/hardware (really, they talk to the hardware driver, and the code to do that may not be portable, depending on what it is).

QT as another example, I don't know what it does, but it has 2 main choices.. it can reuse the local OS's windowing and translate your code in QT to windows forms or gnome/etc unix windowing behind the scenes, or it can implement its own totally unrelated windowing systems with its own graphics and mouse and all interfaces.

Last edited on
Thanks Jonnin, that makes sense, so they don't fully use the operating systems system libraries such as windows.h etc for windows?
Last edited on
Thanks Jonnin, that makes sense, so they don't fully use the operating systems system libraries such as windows.h etc for windows?

you can't make a blanket statement like this. Some libraries may do just that. Some will not. Most likely, portable libraries will NOT use things like that, but even so, there again, it *could* use compiler flags and smoke and mirrors to use those things on the windows distribution and use unistd.h on the unix version etc.
One example, also in https://github.com/radekp/qt/tree/master/src/corelib/plugin

Look at all the qlibrary*. There is both *_unix.cpp and *_win.cpp. Only one of those two is included, when the Qt-library is built.

They implement class QLibrary https://doc.qt.io/qt-5/qlibrary.html#details
Last edited on
The way Qt handles the otherwise explicit #includes is by generating the relevant automated line
QT += core gui
in the .pro file

The Qt system 'works it all out' depending on the platform.
closed account (E8A4Nwbp)
You also mentioned SFML. SFML and similar libraries such cocos2d-x are founded upon OpenGL. OpenGL is a low-level, widely supported modeling and rendering software package, available across all platforms. If I'm not mistaken it was initially made for 3D modelling. And as 3D environment are by default suitable for 2D environments, libraries such a cocos2d-x and SFML commence their engine in a 2D styled perspective, but are very well suitable for 3D activity, which is why you will find in these libraries you can work with the coordinates abscissa, ordinate and applicate. Sorry that my two-penny worth did not go the very origin, but I just thought I'd mention this
Last edited on
Topic archived. No new replies allowed.