views:

401

answers:

8

I want to learn C++ to work on various platform (primarily, Linux and Windows). I have come across few solutions like the Boost C++ library, Qt toolkit, etc that can be used to write programs which will compile on both the platforms.

I want to know from the community, what type of library would you refer to use and if any of you had experience with this type of multi-platform programming before.

+3  A: 

It depends on what you're going to do. If you need to write a strictly command-line utility to process text, Qt or wxWidgets might be inappropriate. What exactly is your application field?

Scientific computing is my field of expertise. in which these are great multi-platform APIs:

Parallel Programming

Numerical Algorithms

High-performance file I/O

Visualization

Pete
Thanks for your list.
sul4bh
+2  A: 

You didn't specify any partuclar type of library, but if you just want a general recommendation I have to say wxWidgets is an excellent cross platform GUI library.

It has some great features like rendering the GUI in the native look and feel of the operating system it's running on, and is not particularly hard to learn. It offers a single API for GUI writing across Win/Mac/Linux, plus others like WinCE.

I highly recommend it for cross platform GUI work.

Check it out at http://www.wxwidgets.org/

CapBBeard
+1 Look and feel are important and often overlooked by GUI toolkits.
Martin York
+2  A: 

I highly recommend Qt if you are doing any sort of GUI work; it's even quite useful if you aren't, since it has well-thought out networking/database/container/etc APIs also. It's a very well designed API and very easy to use.

Jeremy Friesner
+14  A: 

Use Qt 4.5 and the BOOST C++ Libraries. They are both free and very high quality. Also, at least for me personally, I found Qt to be much more straightforward, easy to learn, and simpler than wxWidgets.

Michael Aaron Safyan
Indeed. I've tried wxWidgets, and it's very ugly :(
GMan
+1. I've switched from wxWidgets to Qt too.
Sergey Skoblikov
+1. Qt is superb.
Rob
+2  A: 

The core C++ standard and the STL are pretty much cross platform already. Its usually only the GUI and hardware access stuff that requires libraries.

I have used GTK+ as a GUI toolkit and it's pretty good too, although you need to install glib and some other stuff on windows.

RtAudio is nice for cross-platform audio I/O.

The low level networking/sockets stuff is largely the same between windows and linux, you could write a very lightweight layer yourself to handle any differences. I don't have any experience with higher-level networking libraries.

I also like the SFML (simple fast media library) for cross-platform 2d graphics type stuff. It's very nice indeed.


I would suggest, however, that if you are just learning c++ then you're probably better off not looking at Boost (or indeed any of these toolkits) until you've got your head around the basics - by writing a couple of basic console applications, for example.

If you want to learn c++ only so you can do multi-platform dev, be aware that there are many other languages and associated toolkits that may be more suitable, depending on the app you're writing.

Without knowing the type of app you're planning on developing, its hard to say whether C++ (or C or Python or whatever) is the best idea. Personally, I generally turn to Python + PyGTK for crossplatform GUI apps and C# for windows-only apps. You can always plug C/C++ in to replace any components that are running too slowly.

kibibu
I actually have just started to learn C++. My target is to be able to write multi-platform app. I am just trying to get knowledge of what tools are available and how people do this stuff. Thanks.
sul4bh
+1  A: 

Like other posters have mentioned, I would recommend Qt and Boost for cross-platform development. I had tried gtkmm which is a thin C++ wrapper around GTK+, but was not satisfied with it partly because it's not a native C++ library and documentation is poor compared to Qt. Besides that, Qt comes with very nice development environment including a easy-to-write make alternative qmake and a gui designer.

tkh
+1  A: 

I for are going to do some cross platform development in C++ an you don't want to maintain different build systems (Makefiles, Visual Studio Projects, etc) there are several tools out there that can help you.

The one I personally use is CMake. It supports Linux and Unix Flavours, Windows and Mac/OS. Actually several open source projects, like KDE, use it. But there are others options like for instance Scons.

fco.javier.sanz
+3  A: 

Standard C++ programs will compile and be portable, i.e. work across a large range of platforms. To be sure that you are keeping code clean, your best bet is to get a few different compiler and check your code with all of them, while enforcing full standard conformance (with options like -std= for g++, for example) and writing warning-free code (with options such as -W -Wall -Werror for g++, which emits errors instead of warnings). The exact choice of compilers is up to you, but if you're mostly learning, I advice using:

  • g++ (free, open source)
  • the Intel compiler (free for noncommercial use on Linux)
  • maybe MSVC++

Also, if you really have to use compiler- or target-specific code in your projects, be sure to abstract it so it's all gathered in one place, and hidden from the rest of your code.

Now, if you want to use more than the STL, then you need to choose your libraries by considering the range of compilers and platforms they're tested against (and, if the documentaiton doesn't state it, it's a bad omen). The detailled choice depends on what exactly you want to do, but Boost (as a robust, wide-ranging library for many common issues) and Qt (a recent version; for GUI programming) are good choices. For numerical, scientific programming, BLAS/LAPACK (and/or their parallel versions, BLACS and Scalapack) are very widely used, directly or through wrapper C++ classes as can be found in Boost (for BLAS); a good FFT library is also often needed (FFTW is good if its GPL licence is not a burden for you).

FX