views:

225

answers:

6

Hi SO-followers,

does sombebody know a C++ library for accessing different operating system APIs? I'm thinking about a wrapper to access OS specific functions.

Something like:

osAPI.MessageBox(); // calls MessageBox() in Win32, equivalent in Mac OS Linux etc...

Since I think it's hard to realize this for different OSes for now it would be also ok to have a nice C++ wrapper class for WinAPI.

+8  A: 

I think you're looking for Trolltech's Qt C++ framework.

It's a cross platform C++ library for GUI and just about everything else cross platform.

And as of the latest version it is free to use for commercial use.

Brian R. Bondy
Does QT also handle non-GUI OS API stuff like getting a list of running processes, for example?
Inno
Apparently getting the process list is not covered by QT. ( http://lists.trolltech.com/qt-interest/2006-10/msg01222.html )Maybe they've added a solution in a newer release? I can't find a way to get it in wxWidgets either.
Kieveli
You could always fall back on #ifdef _WIN32 when needed
Brian R. Bondy
+1  A: 

MFC sort of does this on Windows but is not the easiest to use. For a cross platform C++ library take a look at QT. It's best known as a GUI toolkit, but it contains portable APIs to support many system services such as threading, database connectivity and I/O.

ConcernedOfTunbridgeWells
+3  A: 

wxWidgets comes highly recommended by a few friends who've used it.

Kieveli
A: 

Yet another cross-platform C++ library is Mozilla's XPCOM. It's the cross-platform library used by Firefox and a number of other projects.

Laurence Gonsalves
A: 

Nokia's QT would be your best bet if you need a wide range of cross platform functionality. The downside though is that you need to learn its Signal/Slot mechanism, you need to use it's own qmake tool, and it is not too friendly with the STL(you need to learn to use all of QT's containers).

If you are looking for something simpler for GUI development, then wxWidgets would be a much better choice.

Ramon Zarazua
it works fine with STL. all of the Qt containers have STL style iterators available. In addition, every Qt container has to/from methods for converting to/from STL containers.
Evan Teran
+1  A: 

Boost offers libraries for networking (Boost.Asio), threads (Boost.Thread), time, dates, file system traversal, shared memory, memory mapped files, etc.

ACE also has abstractions for networking, threads, time, file system stuff, shared memory, etc.

AFAIK, neither has GUI abstractions or DB abstractions either.

Others have mentioned Qt, wxWidgets and so forth.

coryan