Small native cross-platform GUI framework for C++ - c++

I wrote a small program with Boost in c++. It works fine and so I want to give it a graphical interface so that it is easier to use.
In order to do so, I am looking for small cross-platform framework which provides native look and feel. Windows and Linux support would be enough, currently i do not need os x...
I used wxWidgets for some other project, but it was a pain to set everything up and ship this big library with the software.
But I was really amazed by the use of real native controls.
In order to keep the program small I also tried fltk, but it has an awful look.
I just need an simple framework without network support or other gimmicks.
So my question: Is there any framework out there which fits all the requirements? Or if not, which frameworks fits at least some of these needs?
Thanks in advance!

When it has the word "framework" in its name it's almost never small.
Anyway, graphical frameworks/libraries tend to be big, cause they need to handle a lot of stuff.
Qt is probably the best straightforward library for cross-platform GUI, but it definitely doesn't constitute a "small framework". On the other hand, on Linux systems, Qt will be most likely already installed. Plus it definitely pays for its size.

wxwidgets is fairly small as far as gui toolkits go.
And it's cross platform
http://www.wxwidgets.org/
You have mentioned it, but as far as cross platform toolkits go it's one of the smallest I've seen.
The only other suggestion I have is that you could wrap your code up into a C library and link that into another language. e.g. Use .NET on windows and mono for linux or even a java based app (although they don't always look very native to the platform). Then use your library from there.

Ultimate++ might contain what you need. (Although they make it sound in the FAQ as if their library is really big, it doesn't seem that bad to me.)

don't forget to check juce as well

Qt works amazingly, but is not very small. I've found there is a genuine lack of "small" cross-platform GUIs. You either might try to just abstract your GUI with #ifdefs all over the place, or use Qt/wx.

If you want it to be small, just write the GUI twice -- once in MFC and then in X. Your GUI sounds simple enough. Build up your own small abstraction that is just what you need.

There is a long list of both active and dead cross-platform C++ UI libraries here: https://philippegroarke.com/posts/2018/c++_ui_solutions/
Some of them are small and have a native look.

Like others mentioned you cannot mix the "cross platform" and small in size in the same sentence.
More work, smaller in size:
One solution I can suggest is to use native python binding for the UI portion. Since you are already using boost, it should be fairly trivial to have Boost.Python communicate between C++ space and python space. You already have python on Linux and its a 20-40MB package on Windows (can't remember how big the latest release is). But here you will have to use win32 binding on windows and gtk/qt bindings on linux, so more work. Nah, too much work to maintain, scratch this.
Moderate work, smaller in size but with non-native controls:
You can try to get clutter or freeglut to get your UI work done but I personally haven't used them so I don't know if they provide full native looks for your apps. But they are small in size compared to wx or qt.
Less work, bigger in size:
Use WxWidgets if you are already comfortable with it, otherwise I recommend Qt.
You can also have a look at some of the other offerings: http://en.wikipedia.org/wiki/List_of_widget_toolkits
Clutter: http://www.clutter-project.org/about
FreeGLUT: http://freeglut.sourceforge.net

ever heard of QT ???
http://qt.nokia.com/products/
i think it should fits all your your needs

Related

What libraries can I use to make tiny Windows programs?

Perhaps some of you people have heard of http://suckless.org/ and their set of Unix tools. Basically, they're a set of programs that each aim to do one thing but do it well, while still being as simple and resource-light as possible.
I've been trying to find a way to reproduce this style of programming on Windows with C++ but all the libraries I know of would produce binaries that are huge with respect to their function. Even the simplest of anything Qt, for example, is generally several megabytes large. I'm not against packaging dependencies along with distributables but I wouldn't want to do it to that level.
Binary size is not one of my main goals but simplicity is and big libraries like these are, by construction, not simple. If binary size were your primary concern you could use runtime compression just like kkreiger or malware.
A possibility would be to go commando and use only ISO Standard C++ libraries but rebuilding a sockets or networking system for a small single-purpose application is not really something anyone would want to be troubled with.
For some reason I thought there was some general-purpouse library that Windows developers could count on everyone and their grandma having readily accessible but now I don't know if anything like that exists. What can you use to write code that adheres to the Unix Philosophy but for Windows targets?
You should target the Win32 API directly. You can't get much lower level than that. In the Windows world, everything directly or indirectly wraps the SDK functions, including the so-called "standard C++ libraries".
Alternatively, you could use something like MFC or WTL, which are relatively thin C++ wrappers over the Win32 API. Because of the overhead of the class libraries, such programs will be slightly smaller than those created using only the SDK, but nowadays, the actual overhead is completely insignificant.
The desires expressed in your question are precisely why I learned and still use the Win32 API today, so that's definitely what I would go with. Plus, your programs will look and feel native, which is way better than the crap most "cross-platform GUI toolkits" put out. The advantages of this can't be underestimated.
But if you just open up Visual Studio and compile a simple little SDK "Hello World" app, it'll still be awfully large. Kilobytes, to be sure, but that still seems like a lot for about the simplest app imaginable. If you really need to cut things down further, you can try telling Visual Studio not to link to the C runtime libraries and define your own main entrypoint. This does mean that you'll have to implement all of your own startup initialization code, but this can reduce the size of a trivial app substantially.
Matt Pietrek had this same idea some years ago, although you'll probably want to take time to "modernize" his original code significantly if you decide to go this route.
FLTK is a popular cross platform minimal gui toolkit.
Or a popular alternative if you don't need too much detailed interaction is just to fire up a minimal embedded webserver and do all the 'gui' in html in a browser.

Easiest way to add a GUI to C++ app

I am producing a piece numerical software in C++ and want to add a GUI (mainly for Windows). I know how to produce GUIs using comfortable editors in modern languages like Java or .NET. Now my question is what is the easiest and most comfortable way to add a GUI frontend for my program. In the choice of the tools am completely free (open source and portability would be nice), but please also keep in mind how much boilerplate code and interfaces that have to be maintained are required if the GUI is implemented in another language (Like C#).
Please don't suggest switching the whole project from C++! And note that the program does not require not much interaction between the C++ code and the GUI.
The statements about ISO C++ in this answer's comments are poorly edited. None of the solutions presented here would impose on the computational code a requirement of changing to a different dialect of C++. The GUI code itself might be another story.
The answers about using Windows Forms with managed C++ are probably the most practical. A lot of the UI-related code would be in a dialect (extension) of C++ where the .NET-garbage-collected pointers would be living alongside the traditional ISO C++ pointers. I haven't used this method but from what I read it might be better than what I have used.
MFC might be more practical if you don't want to invest in .NET knowledge for this task. It uses standard C++ constructs to wrap the Windows API. The Windows API uses a particular calling convention which C++ doesn't normally use, and it takes an extension to C++ to work with that, but this is no different than having a C++ program that calls some functions that are extern "C". Visual Studio has a GUI layout tool that is really good at layout of dialogs and at interfacing the dialog widgets to variables that reflect the state of the widgets. I've used this. If you can boil your GUI down to a dialog box then this would be a great option, otherwise you'd be using one of MFC's layout-managed windows.
Obviously the above options do not handle other platforms you might have in mind.
There are also various toolkits that were born on other platforms and have been decently ported to Windows. GTK, QT, FLTK, and WxWindows come to mind. I haven't used any of the dialog-layout/application designer tools that work with those, and I haven't used QT at all. When I last reviewed QT it had a special preprocessing pass for the GUI code. Other than that these portable tool kits are pure ISO C++ as far as I know.
As a really-out-there option one could program to the X Window System protocol using "libx". As far as I know this would involve no non-ISO C++ code.
Qt is a decent choice. It's stable, has a wonderful C++ interface (as opposed to MFC) and has a convenient designer tool.
The overhead of learning it from scratch might however be more that what you're willing to invest. It does have a certain learning curve.
wxWidgets would a good choice for a cross platform GUI for C++
As much as I love C++, it's difficult to build a GUI with. I'd build a quick C# WinForms application which would let you use things like Visual Studio's visual designers (Drag and drop buttons and such), and call your C++ application using P/Invoke.
C++ will often produce smoother and nicer GUIs, but it takes a bit more work out of the box.
If it's going to be just a simple GUI consisting mostly of standard controls I would do it with MFC. It may be outdated and was never really good, but it's still useful to get a native Windows GUI up and running quickly.
I have to chuckle at all the ways to skin this cat. Life is good. My response is a product I manage. XVT can do it for you. The easiest way is let us do it for you or give you a template to get there. It's just a matter of if you have more money than time. Then I'd look at us. It would be the fastest and least amount of effort on your part.
MFC Dialog Based application could answer the needs.
Depending on what you need, there's a nice imgui made by Mikko floating around that you can simply plug-in and use fairly quickly. It's done in opengl though so it won't be your standard windows-gui but it's really small and really easy to work with. You can download r'lyeh's version from here: http://code.google.com/p/colony9/source/browse/include/goo/imgui.h.
That's the easiest and most comfortable way I know, it is dependent on SDL though.

Easiest way to build a cross-platform application

I have read a few articles in the cross-platform tag. However, as I'm starting a fresh application (mostly a terminal/console app), I'm wondering about the easiest way to make it cross-platform (i.e. working for Linux, Mac OS X, and Windows). I have thought about the following:
adding various macro/tags in my code to build different binary executables for each operating system
use Qt platform to develop a cross-functional app (although the GUI and platform component would add more development time as I'm not familiar with Qt)
Your thoughts? Thanks in advance for your contribution!
Edit: Sounds like there are a lot of popular responses on Java and Qt. What are the tradeoffs between these two while we're at it?
Do not go the first way. You'll encounter a lot of problems that are already solved for you by numerous tools.
Qt is an excellent choice if you definitely want C++. In fact, it will speed up development even if you aren't familiar with it, as it has excellent documentation and is easy to use. The good part about it is that it isn't just a GUI framework, but also networking, XML, I/O and lots of other stuff you'll probably need.
If not necessary C++, I'd go with Java. C++ is far too low level language for most applications. Debugging memory management and corrupt stacks can be a nightmare.
To your edited question:
The obvious one: Java has garbage collection, C++ doesn't. It means no memory leaks in Java (unless you count possible bugs in JVM), no need to worry about dangling pointers and such.
Another obvious one: it is extremely easy to use platform-dependent code in C++ using #ifdefs. In Java it is a real pain. There is JNI but it isn't easy to use at all.
Java has very extensive support of exceptions. While C++ has exceptions too, Qt doesn't use them, and some things that generate exceptions in Java will leave you with corrupt memory and crashes in C++ (think buffer overflows).
"Write once, run everywhere." Recompiling C++ program for many platforms can be daunting. Java programs don't need to be recompiled.
It is open to debate, but I think Java has more extensive and well-defined library. The abstraction level is generally higher, the interfaces are cleaner. And it supports more useful things, like XML schemas and such. I can't think of a feature that is present in Qt, but absent in Java. Maybe multimedia or something, I'm not sure.
Both languages are very fast nowadays, so performance is usually not an issue, but Java can be a real memory hog. Not extremely important on modern hardware too, but still.
The least obvious one: C++ can be more portable than Java. One example is FreeBSD OS which had very poor support for Java some time ago (don't know if it is still the case). C++/Qt works perfectly there. If you plan on supporting a wide range of Unix systems, C++ may be a better choice.
Use Java. As much bashing as it gets/used to get, it's the best thing to get stuff working across any platform. Sure, you will still need to handle external OS related functions you may be using, but it's much better than using anything else.
Apart from Java, there are a few things you can run on the JVM - JRuby, Jython, Scala come to mind.
You could also write with the scripting languages directly( Ruby, Python, etc ).
C/C++ is best left for applications that demand complete memory control and high controllability.
I'd go with the QT (or some other framework) option. If you went with the first you'd find it considerably harder. After all, you have to know what to put into the various conditionally compiled sections for all the platforms you're targeting.
I would suggest using a technology designed for cross-platform application development. Here are two technologies I know of that -- as long as you read the documentation and use the features properly -- you can build the application to run on all 3 platforms:
Java
XULRunner (Mozilla's Development Platform)
Of course, there is always the web. I mostly use web applications not just for their portability, but also because they run on my Windows PC, my Ubuntu computer, and my Mac.
We mainly build web applications because the web is the future. Local applications are viewed in my organization as mostly outdated, unless there is of course some feature or technology the web doesn't yet support that holds that application back from being fully web-based.
I would also suggest Github's electron which allows to build cross platform desktop applications using NodeJs and the Google's Chromium. The only drawback for this method is that an electron application run much slower than a native C++ application due to the abstraction layers between Javascript and native C++.
If you're making a console app, you should be able to use the same source for all three platforms if you stick to the functions defined in the POSIX libraries. Setting up your build environment is the most complicated part, especially if you want to be able to build for multiple platforms out of the same source tree.
I'd say if you really want to use C++, QT is the easiest way for cross-platform application, I found myself using QT when I need an UI even though QT has a large set of library which makes pretty much everything easier in C++.
If you don't want to use QT then you need a good design and a lot of abstraction to make cross-platfform application.
However I'm using more and more Python bindinq to QT for medium size application.
If you are working on a console application and you know a bit of python, you might find Python scripting much more comfortable than C++. It keeps the time comsuming stuff away to be able to focus on your application.

c++ frameworks yes or no

I am familiar with QT/gtk+ libs under linux. I've just roughly had a look at available c++ frameworks like Reason and Platinum. Does anyone have any experience working with any of them? Are they any good, should I consider learning them? I am not a big fan of frameworks though.
Keep using Qt or gtk+.
They're very good, and you already know them.
I am not a fan of frameworks either, which is maybe why I haven't heard of those you mention. Having said that, check out POCO. Looks much better than Qt or gtk+ to me if you don't need GUI.
I worked on a project that had to run on multiple platforms (Linux, Windows, Windows CE). We used WxWidgets for the UI. The libraries and the tools weren't perfect. But it compiled and ran on all the platforms without any issues.
The platform is completely open source, so you have the benefits therein.
In the end, I was glad we used it as apposed to porting the UI layer multiple times.
boost asio: the framework for those who are not framework fans ;-). (and this question still lacked a boost answer)
I've started working a little bit with Platinum C++. The documentation is really lacking. That said, you can get some things off the ground relatively quickly. What I worry about is investing deeper into it and finding bugs without support or that it gets dropped as a project (or never really adopted) -- it is version 1.0.0.4
I sounds like you are practiced in keeping the general application mechanics independent and abstracted from one another. It may be worth writing your own small 'framework' and plugging in functionality from other projects with a small wrapper - particularly boost, as mentioned above. This is the direction I am going.

Should I use a cross-platform GUI-toolkit or rely on the native ones?

On my side job as programmer, I am to write a program in C++ to convert audio files from/to various formats. Probably, this will involve building a simple GUI.
Will it be a great effort to build seperate GUIs for Mac and Windows using Cocoa and WinForms instead of a cross-platform toolkit like Qt or GTK? (I will have to maintain a seperate Windows-version and Mac-Version anyway)
The GUI will probably be very simple and only need very basic functionality.
I always felt that native GUIs feel far more intuitive than its cross-platform brethren...
If you have the expertise, use native frontends, it'll effectively double the job you have to do for UI but from my experience non-native UI is a little bit clunkier than their native counterparts.
Have you looked at wxWidgets? Cross platform native controls.
I would agree that if possible, native front-ends are the way to go. I've not used wxWidgets recently, and I've heard it's come a long way, but back when it was wxWindows, we built an app with it that was spec'd to be built in X/Motif. When we finished the effort and delivered it, the customer said it did not look enough like X/Motif, and we had to re-work the entire UI at our expense... Joel Spolsky wrote a good article on this, but I can't remember the title. What he did say, IIRC, was the problem with Java and some other cross-platform UI was that "your dog barks at my app" - it's the little inconsistencies that annoy folks.
Cross-platform toolkits, more or less, all make the incorrect assumption that the difference between platforms is a matter of button placement and widget styling. In some cases you can get away with this - a Qt app will feel fairly native on both Windows (where UI conventions are very lax) and on Linux, particularly a KDE environment. In general, you can move between Linux and Windows relatively easily; conventions are similar, and the Windows community is lax about them.
Mac is the hard one. Its UI is built around an entirely different paradigm than either Windows or most Linux environments.
But in general, in a native app it's easier to speak the native language of the platform in more ways than just widget style.
Yes.
But seriously, it depends on your goals. I agree that the native UI libraries, with a bunch of effort put into them, will give vastly better results, but for lots of apps, a very basic UI is sufficient and a lot less effort if you take one of the existing cross platform frameworks.
Maybe starting with the CLI and getting functionality working makes the most sense for an audio conversion application.
I'm going to write my own cross platform application GUI layer for this soon.
Depending on the complexity of your application this can be a fraction of what is required for QT, GTK or FOX.
Reason is that we see a tendency that the platform vendors (Apple first) tries to design there system so that it looks unique. This makes it much harder for QT, GTK, FOX and other platform tools to constantly keep in sync with the latest widgets.
When the underlaying technique becomes more and more the same the OS vendors have no option then branding on look and feel of the platform.
wxWidgets used standard c++ syntax and preprocessor thus make you easily alter from plain C or C++. And will produce very native look where is appear, be it on GTK, X11, MS-Windows or Mac.
It's mature since 20yrs of 1rst release, has complete documentation with easy navigating, and supported by large community arround the world.
Coding in your favorite IDE or use prominent Eclipse-IDE and wxFormBuilder as GUI designer. Build wx library and IDE/Toolchain setup could be found on this link: http://yasriady.blogspot.co.id/2016/01/raspberry-pi-toolchain.html
Develop your application in Linux desktop and also provided compiler for Raspberry Pi2 (target application tested work smootly on Raspbian Jessie) ............