Platform Independent C++ OS Library?
quench writes "Hello! I have been away from Windows and Linux application software for 5 years or so, doing mainly C-like embedded C++ programming. Now, I am about to start a project emulating embedded hardware on Windows. Been there, doing #ifdef WIN32 and #ifdef LINUX stuff, don't really want to go there any more. What I actually need is a platform independent lib covering Windows and Linux variants to handle sockets, IPC and threads abstractions. And a rock solid but simple embedded database to emulate flash memory. My reflex said, go for ACE and Berkeley-DB. Tell me, am I out of time? Am I missing something new and trendy, easier to use and better? Did time stand still?"
Use Qt. It's LGPL (So it's free for commercial projects as well), is well documented and offers a ton of abstractions (including sqlite).
http://qt.nokia.com/
And tool support is excellent as well (Visual Studio Add-In, Eclipse Plugin and a standalone IDE called QtCreator).
I've used Pthreads successfully as a cross-platform threading library. http://sourceware.org/pthreads-win32 is a quite good implementation for Windows, and it's built into Linux (and all other POSIX compatible OS's, such as OS X, as well).
"I'm too busy to research this and form an educated opinion, but I do have time to tell everyone my uninformed opinion."
Boost has libraries for each of these three: sockets through the ASIO library, IPC through the Interprocess library, and threads through the threads library.
http://www.boost.org
The only thing that Boost is lacking for which you asked is a database library.
Boost has pretty strong threading support, which is the basis for the threading capabilities in the forthcoming revision of the C++ standard. Boost also has cross-platform IPC and socket libraries. It would be a good choice for the OP, I think.
I concur. My Qt-powered multithreaded and networked (TCP&UDP) application is compiling and working nicely in linux, osx and win32 without any os-specifc #ifdefs.
APR:
http://apr.apache.org/ http://en.wikipedia.org/wiki/Apache_Portable_Runtime
Point for point:
- sockets
- IPC
- threads abstractions
- Database. Well, not quite so simple, but Sqlite3 as backend is available.
OP didn't say anything about UI, as you'd surely know if you had bothered to read the summary:
QtCore has more or less nothing to do with UI.
=~ s,(.*),<sarcasm>$1</sarcasm>,g if any_point_you_wish();
It's LGPL (So it's free for commercial projects as well)
I'm sorry to nitpick, but this is an important distinction. You can use GPL code in a commercial project. I don't think that there's any dispute that RHEL is a commercial product. LGPL allows you do use code in proprietary projects.
LK
"Hi. This is my friend, Jack Shit, and you don't know him." - Lord Kano
From the FAQ - http://www.threadingbuildingblocks.org/wiki/index.php?title=Licensing:
It's mostly because they aren't answering the OP's question, and aren't contributing any useful information to the discussion. Compare the posts above with the following:
From what I've heard, one of the best cross-platform libraries for C++ is QT, (originally developed by Trolltech, now by Nokia). It's available either open source (LGPL) or commercially, and while best known for its UI toolkit also provides an extensive library of other functions. Wikipedia has a long list of things it has been used for, and other information.
On the other hand, if you're not too wedded to C++ specifically, Java, C#, or Python might be good alternatives. Syntax-wise, C# and Java are extremely similar to C++, and all three have extensive libraries (built in) that provide the functionality you're looking for. They're also cross-platform (with C# you'd need to stick with stuff Mono can do, but that's still pretty extensive) and you don't even need to re-compile. Speed-wise, both Java and C# are nearly as fast as native code for most applications today, as are certain Python run-time environments. If you need explicit memory management for something, you can even do that with C# (although at that point it may be better to stick with C++).
There's no place I could be, since I've found Serenity...
You say that you're writing a lot of "C-like" embedded C++. Are you doing fully OOP style coding and using 'new' and 'delete'? Or are you mostly taking advantage of conveniences like namespaces, scoped variable declarations, etc?
If your code is really more C-ish, you could take a look at the Apache Portable Runtime (http://apr.apache.org/). The APR is the library that Apache httpd is based on; they cover most system-level utilities (sockets, files, etc) you could need in a portable way. The APR is more 'C-like' in that a file descriptor is an opaque handle which you pass in to functions like apr_file_puts(), etc., rather than doing the C++ thing of file->puts()..
But if you're ok with the syntax, it's Apache licensed (corporation friendly), well tested (httpd is pretty ubiquitous after all) and actively maintained.
Yes, QT is really excellent, but it's worth it to look at Boost as well.
Want a database? Why use Berkeley when there's SQLite?
Portable sockets? QT and Boost both have them.
Portable file ops? QT and Boost both have them.
Data structures? QT has a bunch, but STL is what you should learn.
Windowing lib? QT works on both Windows and Linux. You may be tempted to use WXWidgets, but don't. Despite the fan boyz, you'll find that library to be buggy as shit, and impossible to debug. Sorry, that'll probably get me marked as a troll, but it's true.
And QT on Windows comes WITH the MinGW compiler for Windows package. You don't need to use any other tool than gcc on Linux, Mac, or Windows.
Fascism trolls keeping me up every night. When I starts a preachin', he HITS ME WITH HIS REICH!
You're quoting from the commercial license. TBB is quite explicitly dual-licensed. If you don't like the terms of the commercial license, you have the option to use it under the terms of the GPL v2.
Breakfast served all day!
If you want "close to the metal" POSIX API compatibility then there's Cygwin
Ok, but this is borderline 1990s thinking or a bit insane...
You would be better off telling the person to just use the SUA of NT and develop a full *nix OSS solution and ignore Win32. As this is effectively what you are getting with Cygwin, except the SUA of NT is a full BSD subsystem that DOES RUN AT METAL 'so to speak' and doesn't have all the horrible 'kludges' of Cygwin.
I mean seriously, I think people forget that NT does a very good V5 and BSD Unix already, that is far beyond POSIX compliance and yes even beyond Cygwin crap.
----
To give a good answer to the OP, it would help to know what they are doing a bit more, as just knowing if they ware writing GUI or non-GUI code makes a BIG difference in picking a common or easily portable library. Also performance, what kind of performance do they need? Depending on what they are doing I could recommended truly using the SUA or Java or *gasp* .NET via Mono or QT or a ton of other solutions that do work and work well. Hell they might be doing an application can should be shoved into something like Silverlight.