Beta

×

Welcome to the Slashdot Beta site -- learn more here. Use the link in the footer or click here to return to the Classic version of Slashdot.

Thank you!

Before you choose to head back to the Classic look of the site, we'd appreciate it if you share your thoughts on the Beta; your feedback is what drives our ongoing development.

Beta is different and we value you taking the time to try it out. Please take a look at the changes we've made in Beta and  learn more about it. Thanks for reading, and for making the site better!

Platform Independent C++ OS Library?

timothy posted more than 4 years ago | from the one-to-rule-them-all dept.

Programming 310

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?"

cancel ×

310 comments

Sorry! There are no comments related to the filter you selected.

JAVA (3, Insightful)

Anonymous Coward | more than 4 years ago | (#29712573)

This platform independent lib you are looking for is called JAVA.

Re:JAVA (3, Interesting)

HiThere (15173) | more than 4 years ago | (#29712903)

That's not really a bad suggestion. Ruby, Python, even some dialects of Basic would work.

Also consider Pascal. There are dialects of Pascal that have strongly attempted to be identical across platform boundaries.

Additionally, anything that's running on a virtual machine would be a reasonable consideration. That includes qemu and xen, not just Java, Python, etc.

What's at question are "What are the requirements??". Without knowing that, there's no way to know which, if any, of these suggestions are reasonable. Given that the initial language is C++, I'd expect that Pascal is the best replacement, with Java a close second. But if speed isn't a limiting factor than the other suggestions should be given consideration.

Of course, what he's asking it probably more readily answered by something like FLTK, but it's hard to know, since we don't know exactly which features he needs to be handled by his library. FLTK is platform independent, and callable from C++, but pretty much only handles the graphic interface. If that's all he needs, then it's a good answer, but we don't know what his needs are.

C++ is so old school... (-1, Redundant)

A.C.H. ter Naam (1324497) | more than 4 years ago | (#29712583)

Try Java!

Re:C++ is so old school... (0, Offtopic)

homey of my owney (975234) | more than 4 years ago | (#29712769)

Really? These are moded trolls for expressing an opinion? I thought that's in essence what the poster was looking for. ./ is getting increasingly tedious.

Re:C++ is so old school... (1)

zebrilo (1652077) | more than 4 years ago | (#29712863)

yeah, Qt is made for C++ (despite there are plugins for Java and Python)

Re:C++ is so old school... (3, Informative)

cbhacking (979169) | more than 4 years ago | (#29712923)

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 [wikipedia.org] 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 [hhtp] 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++).

Re:C++ is so old school... (0)

Anonymous Coward | more than 4 years ago | (#29713009)

Not sure how I managed to break the link so badly, sorry.

http://mono-project.org/ [mono-project.org]

Time to go eat something.

Re:C++ is so old school... (5, Informative)

Profane MuthaFucka (574406) | more than 4 years ago | (#29713025)

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.

Qt (5, Insightful)

Anonymous Coward | more than 4 years ago | (#29712587)

Nokia QT rocks...

Re:Qt (1, Informative)

Anonymous Coward | more than 4 years ago | (#29712615)

I agree. I was responsible for maintaining a cross platform application (Windows, Linux, and MacOS) and it was built on Qt. Why the OP did not simply do a google search on the subject confounds me. Cross platform UI tools have been around for as long as there have been 2 or more UI platforms.

Re:Qt (2, Informative)

HeronBlademaster (1079477) | more than 4 years ago | (#29712729)

OP didn't say anything about UI, as you'd surely know if you had bothered to read the summary:

What I actually need is a platform independent lib covering Windows and Linux variants to handle sockets, IPC and threads abstractions

I wrote my own little socket class in C++ that does the Windows/Linux abstraction for me; they're mostly the same anyway, unless you want to get into epoll and such. I had planned to write a similar class for threads, but the idea is not exactly appetizing. I'm told boost has a thread class that might do the trick.

Re:Qt (4, Informative)

rtfa-troll (1340807) | more than 4 years ago | (#29712753)

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.

Re:Qt (1)

zach_the_lizard (1317619) | more than 4 years ago | (#29712783)

Qt is a framework, not just a GUI library. The QtCore classes can be used without any dependencies on the QtGui classes. And yes, Boost does have a threading class or two. I think it is even being adopted for the next C++ standard.

Re:Qt (1)

Tacvek (948259) | more than 4 years ago | (#29712889)

Correct. C++0x will have native support for threads, based largely on Boost threading libraries, but with some differences, and the potential for better support of some features, by adding support to the language core.

Re:Qt (5, Informative)

KirstuNael (467915) | more than 4 years ago | (#29712647)

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.

Re:Qt (1)

FreezeS (1024527) | more than 4 years ago | (#29712967)

How did you get the list of network adapters ?

Re:Qt (0, Offtopic)

dbialac (320955) | more than 4 years ago | (#29712705)

QT is a good platform but don't turn past Mono/.Net either. .Net isn't OSS but Mono most certainly is.

Re:Qt (0)

Anonymous Coward | more than 4 years ago | (#29712873)

And J2ME naturally...

Re:Qt (0)

Anonymous Coward | more than 4 years ago | (#29712893)

Err... He asked for C/C++. Otherwise, why settle for crappy mono when you can get full-featured and supported Java?

Re:Qt (4, Informative)

Anonymous Coward | more than 4 years ago | (#29712735)

Point for point:

- sockets [nokia.com]
- IPC [nokia.com]
- threads abstractions [nokia.com]
- Database [nokia.com] . Well, not quite so simple, but Sqlite3 as backend is available.

Re:Qt (2, Informative)

morgan_greywolf (835522) | more than 4 years ago | (#29712739)

Or GTK. Or specifically, gtkmm. Recent builds of GTKmm and Glibmm include stuff for handling sockets (Gtk::Socket). threads (Gtk::Thread, Gtk::Mutex, etc.) and IPC (GTK::Plug). Don't forget the GIO stuff, too.

Re:Qt (1)

NoYob (1630681) | more than 4 years ago | (#29712921)

GTK doesn't have the well written documentation that Qt has.
The build environment is overly complicated. It took me a few hours hunting down dependencies to get a damn hello world gui program to work.. They have the includes all over the place. And there was a bunch more. Glade isn't intuitive at all. A gui is loaded real time from an xml file - I'm not so sure I like that implementation.
I gave up on Gtk.
And, isn't it really a C framework with a C++ front end?

Re:Qt (1)

morgan_greywolf (835522) | more than 4 years ago | (#29712999)

GTK didn't used to have the well written documentation that Qt has.

TFTY. See the GtkMM Documentation [gtkmm.org] as well as the mainline GTK [gtk.org] documentation. The newer documentation, including that for the PyGTK Python bindings, is some of the best-written API documentation I've ever seen.

Re:Qt (4, Interesting)

jmv (93421) | more than 4 years ago | (#29712941)

I've once attempted to use Gtkmm for a new project. While the API is generally well designed, I found that the documentation for many features was totally inexistant. Even more annoying was the fact that some components were either buggy or not wrapped (from C Gtk) at all. Combined with the fact that components get created and deprecated at a huge rate, you don't even know what you should be using. Overall, I've had a really bad experience with Gtk (and especially gnome) development. I've only tried using Qt a little bit and so far I like it a lot. I've never done GUI with it though. I've used the "platform independent system library" part for things like threads, sockets and the like. The only thing I found a bit annoying was that it didn't integrate well with the STL.

Re:Qt (1)

zach_the_lizard (1317619) | more than 4 years ago | (#29712755)

I was about to recommend this, too. It has SQL plugins. The framework can handle networking, graphics, GUIs, scripting, and even threading. And if you write your application well enough, it is possible to compile it for multiple platforms with no or little changes. I've got a cross-compiler set up on my Linux box, and I use it to compile the Windows versions of some of my apps. WINE can also be used for basic testing, though I would always test in on a real Windows machine (or several).

Boost? (2, Informative)

piojo (995934) | more than 4 years ago | (#29712595)

I know Boost has threading support, but I'm not sure how much. Have you looked at that? (It also has a bunch of other useful libraries, perhaps Filesystem being pretty useful for cross-platform work.)

Re:Boost? (4, Informative)

Homburg (213427) | more than 4 years ago | (#29712645)

Boost has pretty strong threading support [boost.org] , which is the basis for the threading capabilities in the forthcoming revision of the C++ standard. Boost also has cross-platform IPC [boost.org] and socket [boost.org] libraries. It would be a good choice for the OP, I think.

Re:Boost? (0, Troll)

Anonymous Coward | more than 4 years ago | (#29712907)

Avoid Boost. Cross Platform: no. Well Tested: absolutely not.

Re:Boost? (1)

QuoteMstr (55051) | more than 4 years ago | (#29712931)

[citation needed]

Re:Boost? (0)

Anonymous Coward | more than 4 years ago | (#29712955)

There are certainly bits and pieces of Boost that are a total mess, style/syntax wise (*cough* Boost.Exception *cough*). I'm unaware of any that don't *function* well, though.

Re:Boost? (1)

mwvdlee (775178) | more than 4 years ago | (#29713127)

I was under the impression that Boost didn't even accept libraries that weren't coded according to Boost's style?

Re:Boost? (2, Funny)

Profane MuthaFucka (574406) | more than 4 years ago | (#29713087)

No, USE Boost for exactly those reasons. It's an extremely advanced library, and working with it will quickly make you a much better C++ programmer.

Re:Boost? (1)

incripshin (580256) | more than 4 years ago | (#29713219)

Boost ... is the basis for the threading capabilities in the forthcoming revision of the C++ standard.

It's probably the other way around, see the Boost thread documentation [boost.org] . In any case, it's much easier than using pthreads' C API, and I think the feature set is approximately the same as pthreads.

many choices (2, Interesting)

Anonymous Coward | more than 4 years ago | (#29712597)

NSPR [mozilla.org] , APR [apache.org] , boost [boost.org] system, threads

Qt (5, Informative)

Anonymous Coward | more than 4 years ago | (#29712599)

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).

Re:Qt (1, Interesting)

Anonymous Coward | more than 4 years ago | (#29712657)

Remember one thing about LGPL. It requires that that user can replace the LGPL binary. So Qt released under LGPL must be a separate dll, no static linking.

Although, I cannot understand how iPhone and its apps get by this license requirement.

Re:Qt (2, Informative)

d235j (1434583) | more than 4 years ago | (#29712671)

Simple: They post source code at opensource.apple.com and since they keep away from LGPL 3, they can use signing to, in effect, do "tivoization." And the iPhone and apps have dynamically linked libraries.

Re:Qt (1)

noidentity (188756) | more than 4 years ago | (#29712675)

Remember one thing about LGPL. It requires that that user can replace the LGPL binary. So Qt released under LGPL must be a separate dll, no static linking.

Or you could provide the source code for your program, or perhaps the .o files (if you like angering your users).

Re:Qt (1, Informative)

Anonymous Coward | more than 4 years ago | (#29712703)

I hate replying to myself, but forgot one thing:

If you want to know what Qt has to offer without downloading it, you can check out their documentation online:
http://doc.trolltech.com/4.5/

Take a look at the list of classes as well.
Don't worry, you can disable the modules you don't need (including the GUI) to reduce the overhead.

Re:Qt (1)

ultrabot (200914) | more than 4 years ago | (#29712717)

Use Qt.

Seconded.

Note: you can also use just QtCore, without QtGui, if you don't need the gui parts.

Re:Qt (3, Informative)

Lord Kano (13027) | more than 4 years ago | (#29712767)

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

JUCE (0)

Anonymous Coward | more than 4 years ago | (#29712609)

JUCE (www.rawmaterialsoftware.com) can handle IPC and threads, don't know about sockets. No integrated DB though, and it's primarily a GUI and media thing. Lots of integrated real time audio stuff etc. so it might be too heavy weight for your purposes.

Pthreads (3, Informative)

SoftwareArtist (1472499) | more than 4 years ago | (#29712613)

I've used Pthreads successfully as a cross-platform threading library. http://sourceware.org/pthreads-win32 [sourceware.org] 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).

Re:Pthreads (2, Interesting)

QuoteMstr (55051) | more than 4 years ago | (#29712723)

pthreads-win32 is excellent, but regrettably, LGPL licensed. It's interesting to note how complex it has to be to give you POSIX semantics [wustl.edu] --- pre-Vista win32 threading primitives are fundamentally flawed [msdn.com] .

Vista, on the other hand, gives us brand-new innovative 21st-century Microsoft technologies like condition variables [microsoft.com] .

c++0x (0)

Anonymous Coward | more than 4 years ago | (#29712621)

a *lot* has happened in C++ recently. you might want to check out TR1, c++0x, boost::thread and (boost::)asio

Qt or GLib (2, Informative)

ciroknight (601098) | more than 4 years ago | (#29712623)

Qt's "Core" library is a pretty solid platform shim. Plain GLib is also (somewhat easier to port due to no C++ ABI differences, but no native C++ api makes it less attractive to you).

Either one is an exceptional choice.

TBB works wonders for threading (5, Interesting)

Wrath0fb0b (302444) | more than 4 years ago | (#29712625)

Intel Thread Building Blocks (http://www.threadingbuildingblocks.org/ [threadingb...blocks.org] is (are?) fantastic. Open source (GPL), works on any ISO-compliant C++ compiler and is fairly intuitive. It allows both high-level (parallel_for) and low level (task-based) parallelism. Particularly useful are the concurrent containers, since it saves you from reimplementing these basic structures.

Re:TBB works wonders for threading (1)

non-e-moose (994576) | more than 4 years ago | (#29712835)

"You Lie!" They are NOT GPL-ed. The License is explicitly ANTI-GPL. Read it.

Re:TBB works wonders for threading (3, Informative)

Wrath0fb0b (302444) | more than 4 years ago | (#29712891)

From the FAQ - http://www.threadingbuildingblocks.org/wiki/index.php?title=Licensing [threadingb...blocks.org] :

TBB is available under the common OSS license GPL v2 with the libstdC++ Runtime Exception. This is the same license used for a variety of well-known OSS applications including MySQL, NetBeans, and the Linux kernel.

Re:TBB works wonders for threading (1)

non-e-moose (994576) | more than 4 years ago | (#29713195)

RTF License, not the FAQ. Explicitly: An "Excluded License" is one that requires, as a condition of use, modification, or distribution, that (a) the code be disclosed or distributed in source code form; or (b) others have the right to modify it; or (xi) include the Redistributables in malicious, deceptive, or unlawful programs.

Re:TBB works wonders for threading (3, Informative)

PCM2 (4486) | more than 4 years ago | (#29713225)

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.

Boost (4, Informative)

aePrime (469226) | more than 4 years ago | (#29712633)

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.

Re:Boost (4, Informative)

mls (97121) | more than 4 years ago | (#29712743)

SQLite databases are small, powerful and platform independent and might be a good choice to fit your database needs. The code is public domain.

boost (0)

Anonymous Coward | more than 4 years ago | (#29712639)

boost

APR (0)

Anonymous Coward | more than 4 years ago | (#29712667)

IANA C guru but maybe Apache Portable Runtime? Seems to be more lightweight than QT.

ACE is great! (1)

Arakageeta (671142) | more than 4 years ago | (#29712685)

I've had great experiences with ACE. I found ACE to be dependable and extensive. You don't even have to use the higher level design patterns to get the platform independence.

If you're targeting *only* Windows and Linux, then Qt may also be a good option. I'm not sure if you can strip out the GUI stuff if you don't need it.

Re:ACE is great! (3, Interesting)

mallan (37663) | more than 4 years ago | (#29712801)

Qt has been modular since ver 4, so you don't have to include the GUI components if you don't want to. The API is clean, elegant and consistent, plus the documentation is great. I don't have anything bad to say about ACE or Boost - they're both high quality toolkits - but if I had to choose just one toolkit to use for the rest of my life, it'd be Qt, hands down.

Re:ACE is great! (1, Interesting)

Anonymous Coward | more than 4 years ago | (#29712881)

Avoid ACE, it is really poor. Have you every tried to compile and build it on modern systems? It just does not build. It looks like the project has been abandoned to me.
I tried to build it on 5 modern UNIX OSs recently and they all failed. The main reason is that the C++ code is poor written and C++ is not very portable because the C++ compilers only implement parts of the standard.

Re:ACE is great! (1)

cbhacking (979169) | more than 4 years ago | (#29712951)

QT allows use of just the core libraries, so that's not a concern. Why do you talk about "only" targeting Windows or Linux, though? QT runs on OS X, WinCE, and other platforms as well. For example, if Skype runs on it, you can bet QT does too.

Apache Portable Runtime (1)

boilednut (1245008) | more than 4 years ago | (#29712687)

APR

Re:Apache Portable Runtime (3, Informative)

boilednut (1245008) | more than 4 years ago | (#29712721)

Re:Apache Portable Runtime (5, Informative)

boilednut (1245008) | more than 4 years ago | (#29712763)

From the wikipedia articel:

APR was originally a part of Apache HTTP Server, but has now been spun off into a separate project of the Apache Software Foundation, and is used by other applications to achieve platform independence. The range of platform-independent functionality provided by APR includes:
* Memory allocation and memory pool functionality
* Atomic operations
* Dynamic library handling
* File I/O
* Command argument parsing
* Locking
* Hash tables and arrays
* Mmap functionality
* Network sockets and protocols
* Thread, process and mutex functionality
* Shared memory functionality
* Time routines
* User and group ID services

As someone working on a massive project... (4, Informative)

QuoteMstr (55051) | more than 4 years ago | (#29712689)

I'm working on a rather large cross-platform C++ project at the moment. Here are a few tips:
  1. Use Boost [boost.org] . It's a very liberally-licensed, high-quality library from the people who created the C++ language itself. It contains a ton of cross-platform libraries that do lots of useful things, from threads to regular expressions to writing testsuites and parsing command-line options. If Boost provides a piece of functionality, there's very little reason not to use its version.
  2. See rule #1.
  3. If you need cross-platform code that isn't in Boost, at least use the following approach:
    • Create a common interface definition
    • In separate files, implement the interface in terms of various platforms' primitives
    • Keep platform-specific code out of the rest of your program; if you can help it, don't even include platform headers in most of your program
  4. Use autoconf to handle platform idiosyncrasies. There are a ton [nongnu.org] of available macros to help detect things about a build platform.
  5. Write testcases. You should write tests for all your programs, but it's especially important to do it for cross-platform code because it's easy to break something and not notice.

Re:As someone working on a massive project... (3, Insightful)

Anonymous Coward | more than 4 years ago | (#29712745)

Use autoconf to handle platform idiosyncrasies.

Ugh. Autoconf & automake are the most horrible things I've tried to use in recent times. These tools are far from simple and what works with newer versions of the tools isn't even compatible with older versions. The syntax is antiquated and there are multiple ways to achieve the same thing each with different pitfalls.

Somewhere there is a meteorite set to strike autoconf. I hope it gets here soon since it's about 20 years late...

Re:As someone working on a massive project... (5, Funny)

Anonymous Coward | more than 4 years ago | (#29712765)

it is all well and good, but he cannot even read options 3,4 and 5 because of your recursion!

Re:As someone working on a massive project... (0)

Anonymous Coward | more than 4 years ago | (#29712927)

#$@$@#$@#, I meant to mod your post "funny" but the stupid moderation system doesn't let you recover from clicking the wrong one! Thus, I am posting a reply to undo my accidental "troll" moderation.

Moderators, please feel free to mod this post down to oblivion, just to get those negative emotions out of your system. ;-)

Boost? (0)

alex4u2nv (869827) | more than 4 years ago | (#29712741)

Last time I did c++ i used Boost.

Unfortunately probably not worth it (0)

Anonymous Coward | more than 4 years ago | (#29712747)

You can come up with your own runtime system that runs on all platforms and has its own library and primitives. However, you'd have to throw away the powerful system programming concepts of linux/unix that simply don't have anything equivalent on the Windows side. For example, fork() is not available, which is a shame since fork() is essential for starting background processes in a controlled fashion (have the parent initialize, fork and exit).

Python and Java have the same problem and are reduced to lame multithreading where native asynchronous programming would do the trick in a clearer and more natural way.

Boost and POCO (1)

Adam Hazzlebank (970369) | more than 4 years ago | (#29712773)

Boost ( http://www.boost.org/ [boost.org] ) is good I also hear nice things about POCO http://pocoproject.org/ [pocoproject.org]

Re:Boost and POCO (2, Informative)

Profane MuthaFucka (574406) | more than 4 years ago | (#29713059)

No, POCO is not very good. The documentation is poor, and it's buggy.

wxWidgets might work (2, Informative)

Beached (52204) | more than 4 years ago | (#29712785)

wxWidgets (aka wxWindows) does windowing, sockets, thread. I am not sure about DB, but I think it does. I haven't used it for DB yet.

Re:wxWidgets might work (1)

Profane MuthaFucka (574406) | more than 4 years ago | (#29713117)

It also does infuriating bugs. Programs that work fine with small amounts of data explode when you get them into production. Doom!

--BOOST --ACE (1)

sribe (304414) | more than 4 years ago | (#29712789)

As others have said BOOST is good. Also, I really didn't care for ACE and eventually gave up on it.

Re:--BOOST --ACE (1)

sribe (304414) | more than 4 years ago | (#29712793)

Ack phooey, that was supposed to be ++BOOST...

Poco C++ Libraries is an excellent option (0)

Anonymous Coward | more than 4 years ago | (#29712791)

I use Poco C++ Libraries and highly recommend it. It offers conceptual integrity throughout the component libraries, with a very generous open source license.

It doesn't include a GUI library. Poco is more of a platform abstraction API. I cross-built Poco C++ Libraries for ARM9 and have experienced very good results the last 1.5 years. Zero Poco issues. Using the Poco abstractions for threads, mutexes, and network operations (both UDP and TCP).

Poco includes SQLite integration and Expat XML parser integration. I experimented with both successfully, although they are not used in my commercial product that uses Poco.

If Qt had been free when I began, I would have considered it. Poco was already free so it was an easy choice once I became familiar with it. Poco is actively maintained, and commercial support is available if wanted.

Poco C++ Libraries. Highly recommended.

You probably do not want ACE (1, Interesting)

Anonymous Coward | more than 4 years ago | (#29712803)

ACE introduced a lot of neat concepts into the mainstream as far as I/O goes (the Reactor pattern came from ACE) but it's really quite crufty and showing its age. It's probably the best thing there is for wrangling heavily-threaded apps, but you'll have to deal with threads more than you'll care for. You'll find the APIs in Boost and QT to be a lot nicer.

As for Berkeley DB, it's very nice, battle-tested, and perfectly suited for the type of task you're looking at.

Re:You probably do not want ACE (1)

quench (187533) | more than 4 years ago | (#29712899)

great summary, thanks!

Cross platform? USE JAVA, duh! (0)

Anonymous Coward | more than 4 years ago | (#29712813)

TFA - Whats the best hack for c++ to let it be cross platform?

Everyone - Use this mish-mash of open source libraries and/or reinvent the wheel when you have to with interfaces and separate code files for OS specifics.

Me - Use a language and SDK that is MADE FOR CROSS PLATFORM COMPATIBILITY. JAVA JAVA JAVA

JAVA has cross platform sockets
JAVA has cross platform threads
JAVA has cross platform gui

C++ has header files... F**K HEADER FILES
C++ has pointers to pointers... F**K MEMORY MANAGEMENT
C++ makes you feel smart when you get something to actually work correctly... F**K YOUR EGO

Re:Cross platform? USE JAVA, duh! (1)

ultrabot (200914) | more than 4 years ago | (#29712875)

Everyone - Use this mish-mash of open source libraries and/or reinvent the wheel when you have to with interfaces and separate code files for OS specifics.

You don't need "mish mash" if libs if you use Qt.

Get with the program. Java isn't "special" anymore.

Re:Cross platform? USE JAVA, duh! (0)

Anonymous Coward | more than 4 years ago | (#29713151)

Java is perfect if you want a crummy looking, slow, dependent-on-Sun, huge-runtime, library-version-dependent application. No doubt about it.

Has anyone ever created a single Java application that doesn't suck yet? (And, yes, Eclipse is slow and has a really crummy UI)

JNetLib (1)

darkain (749283) | more than 4 years ago | (#29712817)

http://www.nullsoft.com/free/jnetlib/ [nullsoft.com] From the guy who initially made Winamp, he also made a lib called JNetLib which is a piss easy to use cross-platform C++ socket library. It also has pre-made classes for things like HTTP/HTTPS, to help speed things up, or to simply give you an idea of how to use the library. It is licensed under the BSD license, so you are basically free to use it for whatever you would like, commercial or otherwise.

Cygwin or UWIN (4, Interesting)

jdb2 (800046) | more than 4 years ago | (#29712831)

If you want "close to the metal" POSIX API compatibility then there's Cygwin [cygwin.com] which is easier to use IMO and more actively developed but doesn't support the *full* POSIX spec or there is UWIN [att.com] which supports most of the POSIX spec.

Combine this with OpenGL [opengl.org] , OpenAL [creativelabs.com] , the SDL [libsdl.org] and Cygwin/X [cygwin.com] , QT [nokia.com] , a Java layer using the SWT [eclipse.org] from Eclipse, *shudder* GLUT [opengl.org] *shudder* ;) or IMNSHO preferably wxWindows/wxWidgets [wxwidgets.org] and you've got yourself a full cross-platform programming toolkit that can do just about anything.

jdb2

You might want to look at Zoolib (2, Informative)

Orion Blastar (457579) | more than 4 years ago | (#29712833)

Zoolib at Source Force [sourceforge.net] under the MIT open source license. It has a flat file database format, exists for multiple platforms, has platform-independent thread and mutex classes, graphical user interface toolbox, thread-safe reference counted smart pointers, file access, TCP networking. You can ask the main developers Andy Green or Michael Crawford to port it to a new platform that isn't supported yet, but it supports all of the platforms listed on the source forge page.

The Zoolib Cookbook can help you get started. [goingware.com]

The flat file database support is designed in Zoolib so that you can email someone the database file and they can click on it and open it up as an email attachment.

Re:You might want to look at Zoolib (0)

Anonymous Coward | more than 4 years ago | (#29712919)

cool! I'm planning on writing a cross-platform gui front end for libogg. Zoolib looks like a great fit!

Poco C++ Libraries is an excellent option (0)

Anonymous Coward | more than 4 years ago | (#29712837)

I use Poco C++ Libraries and highly recommend it. It offers conceptual integrity throughout the component libraries, with a very generous open source license.

It doesn't include a GUI library. Poco is more of a platform abstraction API. I cross-built Poco C++ Libraries for ARM9 and have experienced very good results the last 1.5 years. Zero Poco issues. Using the Poco abstractions for threads, mutexes, and network operations (both UDP and TCP).

Poco includes SQLite integration and Expat XML parser integration. I experimented with both successfully, although they are not used in my commercial product that uses Poco.

If Qt had been free when I began, I would have considered it. Poco was already free so it was an easy choice once I became familiar with it. Poco is actively maintained, and commercial support is available if wanted.

Poco C++ Libraries. Highly recommended.

If you use Berkeley-DB, watch out for the Oracle licensing.

Sorry, C variants aren't trendy... (5, Funny)

CptNerd (455084) | more than 4 years ago | (#29712849)

Unfortunately all the trendy cool kids are using Java these days, and only web-based applications are worth working on if you want to keep up with the times. The days of small, simple client-server apps are over, old hat, out of date, archaic. Nowadays you need to implement a web application using AJAX, web services, Struts and Spring and Hibernate, and you have to do it using Agile methodology. If you aren't linking in at least 100 Java class libraries, you don't have a "real" application.

C++? Too simple.

Re:Sorry, C variants aren't trendy... (1)

quench (187533) | more than 4 years ago | (#29712911)

:)))

Qt, Wx, pain (0)

jipn4 (1367823) | more than 4 years ago | (#29712851)

Qt and Wx are both open-source cross-platform libraries. However, doing anything cross-platform in C++ is a pain. You're probably better off using Python, Mono, or Java.

Yu left out one #ifdef (2, Insightful)

tomhudson (43916) | more than 4 years ago | (#29712853)

#ifdef __BSD__

BSD and linux are different in some aspects when it comes to sockets. Made it a real PITA to code on linux, runs perfectly, then won't compile on BSD without a few more includes and some extra code.

Re:Yu left out one #ifdef (1)

alexott (799171) | more than 4 years ago | (#29712943)

boost::asio hides many low level details of networking, and provide pretty good high level interface to networking on almost all platforms... P.S. forgot about database and XML - for database you can use soci (from soci.sf.net), and for XML - arabica XML libraries, that supports different XML libraries - expat, libxml2, xerces, etc.

Just use JAVA (0)

Anonymous Coward | more than 4 years ago | (#29712867)

and get off my damn lawn!

QQ I need cross platform development but I'm stubborn and have to use C++.
Well you just need a combination of 80 different libraries and ass loads of useless header files and layers of abstraction.

OR OR OR you can just use JAVA and have a tested working product out faster.

Re:Just use JAVA (1, Funny)

Anonymous Coward | more than 4 years ago | (#29712993)

Got yer polarity wrong. He's the oldster, you are the whippersnapper. You should be saying, "I'll get off YOUR lawn". Otherwise, your advice is sound.

try boost... (1)

alexott (799171) | more than 4 years ago | (#29712901)

boost::asio for networking + events, boost::treads for threading, and boost::interprocess for shared memory & other stuff...

Just use POSIX (2, Insightful)

Anonymous Coward | more than 4 years ago | (#29712949)

That handles all the things you mentioned, and you can compile pretty much all the same code natively on Linux or using Cygwin on Windows without having to bother with #ifdeffery at all.

Boost and sqlite (3, Interesting)

rudedog (7339) | more than 4 years ago | (#29712963)

For most cross-platform stuff, boost will do what you need. boost::thread will handle all of your threading needs.

boost::filesystem for manipulating pathnames; boost::datetime for date and time operations; boost::format for typesafe printf style I/O.

It also has boost::asio for sockets and boost::interprocess for IPC. I know nothing about them, but to judge from the quality of the rest of the boost library, they are probably very good.

For database, use Sqlite. It's a solid relational database stored in a single file, and you can even access the database from the command line for ad-hoc queries/debugging/whatever.

Apache Portable Runtime (3, Informative)

Jester99 (23135) | more than 4 years ago | (#29712985)

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.

SQLite for database (2, Interesting)

PizzaFace (593587) | more than 4 years ago | (#29713061)

SQLite [sqlite.org] dominates discussions of embedded databases these days, but Berkeley DB [oracle.com] still has fans who don't need SQL. There are a lot of comparisons on the web.

C++ Sockets Library (alhem.net) (0)

Anonymous Coward | more than 4 years ago | (#29713115)

Check out C++ Sockets Library. Does Sockets and Threads.

http://www.alhem.net/Sockets

MONO (1)

Vahokif (1292866) | more than 4 years ago | (#29713207)

*ducks*

Simple Direct Media Library (SDL) (0)

Anonymous Coward | more than 4 years ago | (#29713211)

If you are looking to do a gui like project, SDL does windowing, input, imaging, audio, threading, all in its own little abstraction. It works on Windows, Linux, and Mac all the same.

Load More Comments
Slashdot Login

Need an Account?

Forgot your password?
or Connect with...

Don't worry, we never post anything without your permission.

Submission Text Formatting Tips

We support a small subset of HTML, namely these tags:

  • b
  • i
  • p
  • br
  • a
  • ol
  • ul
  • li
  • dl
  • dt
  • dd
  • em
  • strong
  • tt
  • blockquote
  • div
  • quote
  • ecode

"ecode" can be used for code snippets, for example:

<ecode>    while(1) { do_something(); } </ecode>