FLTK or not to FLTK... that is the question

Ok various other C++ support personnel,

Getting into GUI programming and was advised that there are tons of GUI libraries..... one I have been made aware of is FLTK -"FullTick"??. Don't know anything about it.... is it good? Are there betters? I will be interfacing with VS 2015 if that helps with this overall general question??

Since I have never done GUI programming (and I am starting with the absolute basics) I don't know enough about it to be "wary" of anything or know what to watch out for with regards to the various 3rd party GUI libraries out there.

Opinions? Ideas? Tales of woe or caution? Praises?

Xanadu
try to get to something since 2017 so you have those language changes enabled.
visual studio has a perfectly good build in GUI building library. Is there a reason to use another (there are reasons, including portable to unix etc).
two that come to mind immediately are wx platform and QT.

The best thing I can tell you as a new gui programmer is to always, always, always keep your gui code and your actual code distinct. They have to talk to each other, but do that by having the gui call the real code via function calls, eg
onbutton1press()
{
myrealcode(editbox2.gettext(), something, somethingelse);
}

if you start doing LOGIC and WORK in that button call, you will create a gigantic mess that will be difficult to move to another gui system or reuse the code etc. the temptation is always there and hard to resist, but fight it!
Last edited on
Jonnin,

Does the VS 2015 have a built in one? I will use the built in one if it does BUT how do you access the built in one? I suppose there is some #include statement I have to state in the header to access this?? Are there other actions I must take to make sure this is available?

(Yes, I am THAT ignorant of all of this so far! LOL!) The book I'm using gives detailed instructions on how to install and use FLTK and I assume that they (the keepers of FLTK) would have updated the version for contemporary rules [Yes, assuming is dangerous and I think I'm going to find out due to Murphy's law that it probably is NOT updated and I'll have the ancient version??]

Thank you for your advice and I am going to heed it completely!!

Would it make sense to put all GUI programming into its own .cpp file and have all the "regular" logic in the other .cpp files and make sure I don't use any of the graphics calls (like your example above) for anything except access to those objects??

What says you Jonnin? Good with VS2015 built-in GUI (if it exists?) or explore the other options you gave me?

Xanadu

I don't know what is meant by "built-in GUI building library". Presumably jonnin is referring to Win32 API or MFC, but I'd hate for you to have to code in that.

Choosing a GUI framework comes down to opinion... I'd say try out FLTK, see if it feels nice. If you're having trouble, try out another one.

One really quick and easy thing you can do is to simply search the name of the GUI framework of interest, and look at google images or wherever to see examples of GUI windows. This can give you a general impression about what the average application will look like.

• FLTK, to my knowledge, does not use "native" widgets, so you won't get a "native look-and-feel" on the systems you build and run it on. Maybe this isn't important to you. My opinion is that this is ugly, and requires much more dedication and work to make it look good. That being said, I have only ever looked at FLTK, and I have not actually programmed it it, so take what I say with a grain of salt. Maybe it's really easy to program basic things in, and great for a beginner!
• wxWidgets is kinda ugly to program in at times, but it's better than MFC. It's not too bad, I'd say it's worth checking out. It's cross-platform as well, but some minor features of it are "MSW-only" (Microsoft Windows-only).
• Qt is probably the most highly regarded cross-platform framework that can work in C++, based on most things I've heard.

If you're willing to code in C#, WPF is very flexible, and I prefer it over C#'s WinForms. You could also take the route of having the GUI be in C#/WPF, but use C++ w/ .NET or call certain C++ DLLs, inter-op stuff. Interop could make things more complex than necessary, though.

Also, once you have experience in one GUI framework, you kind of get a feel for how things have to be done, and it will be easier to transition to another GUI framework anyway. At least a little.
Last edited on
Genado,

Being totally ignorant on the subject, I am not 100% sure what Jonnin means by the "built in" option. Perhaps it is as you are referring to and it is Win32 API or MFC - I'll take your word that it is abysmal for now! ;-)

I will definitely do some FLTK research and since I am starting out it probably will work ok for a while until I get enough knowledge to help me migrate to a better GUI system.

Thanks for the heads up on wx & Qt. I will also investigate those and check out what is going on with them as well as a "general" search to see what is out there and the prevailing opinions on what the particular packages are best for etc.

I have a C# book and can start to mess with it more in the future..... I am not too afraid of learning new stuff in general ..... but I'll have to finish my C++ studies first and then start looking at that. (If I don't focus I'll be all over the dang place before you know it and won't get a damn thing done!)

Hopefully, I will get some scruples about the subject and be able to make a further decision for more advanced features soon...…????

Thanks as always!

Xanadu

I would not recommend FLTK at this time.

The basics are ok for example teaching (Stoustrup refers to it), but it is not exactly up to par with other frameworks.

The code is currently at version 1.3.5, which is stopped (maybe a few bug fixes).

They're moving to version 1.4, but it's not 'released' yet, and it was started in 2016. As described, it was to clear up flaws in 1.3.5.

I'd much prefer WxWidgets to FLTK, but it is an older design. It works very well, is quite robust, and the code is well maintained. New releases come about once a year.

Qt is highly regarded, but it tends to try to do everything, even when it shouldn't. For example (and this is true of WxWidgets, too) - they have their own strings and containers, which duplicate the C++ STL.

Unfortunately it is both a problem and a solution. It's a problem because most library code will expect std::string, while the operating system controls on various GUI's use something specific (UTF-16 or UTF-32), so there's always some conversion required to get data from controls to external libraries and tools, unless you can use the GUI frameworks strings (QString or wxString).

It's not all bad news, though, it works well. It's just that Qt programmers tend to be inside a Qt world. The library was initiated long before the STL matured (as is true for wxWidgets), so the duplicate containers and such were a natural product of legacy.

Qt does have better designer support.

As already pointed out, MFC on Windows is a dead end (it's Windows only). There's no point in making a Windows only application in the 21st century - it just hands more power to Microsoft.

All software should be written in a framework like Qt so it can be targeted to Linux, MAC and Windows with little effort.

That wasn't practical decades ago, but with little thought and intent it is quite practical now, and opens both the target markets and user options while eliminating dependence on proprietary operating systems.



Oh, last point - the "built in" notion you're thinking about is part of QtCreator - Qt obviously is the framework in QtCreator - an IDE/Compiler and tools for designing UI layouts.
Last edited on
Niccolo et al,

I may have already gone down the rabbit hole...… I downloaded FLTK v.1.1.10 like the book said (the "Doc" recommended a v1.1.X when the book was written and I figured - that would do for now.... uh oh!??? Hope I'm not screwed!)

I might be asking advice how to get wx or Qt on this heap before too long if this doesn't pan out correctly.

I followed the instructions in the book and I didn't find a .dsw file like the instructions (in appendix D) state but I DID find a VS studio solution file and ran it. It generated a bunch of up-grades and even a "migration report" telling me things went ok?? (I think that is what it is telling me?? I can post it here if you guys want to look at it?)

Not sure what to say. Should I keep going down this path until my heap catches on fire or what do you recommend??

Xanadu
"DSW" was the extension for the IDE back in .... the 90's?

...hmm, blue pill or red pill.....
Yes Neo,

That is absolutely correct...…

Unfortunately I have this thing installed and I did as it says BUT I'm getting errors when I compile the test code they give. The test code is as follows (from the book mind you!) ==>

1
2
3
4
5
6
7
8
9
10
11
12
13
#include <FL\Fl.H>
#include <FL\Fl_Box.H>
#include <FL\Fl_Window.H>


int main{

Fl_Window window(200,200,"Window Title");
Fl_Box box(0, 0, 200, 200, "Hey, I mean, Hello World!");
window.show();
return Fl::run();

}	//end of main routine 


This SHOULD compile but it don't! The following are the errors that I am getting==>

Severity Code Description Project File Line
Error (active) type name is not allowed
Error C2275 'Fl_Window': illegal use of this type as an expression
Error C2146 syntax error: missing ')' before identifier 'window'
Error (active) expected a ','
Error (active) expected a '}'
Error (active) this declaration has no storage class or type specifier
Error C3927 '->': trailing return type is not allowed after a non-function declarator
Error C3484 syntax error: expected '->' before the return type
Error C3613 missing return type after '->' ('int' assumed)
Error C4430 missing type specifier - int assumed. Note: C++ does not support default-int
Error C2146 syntax error: missing ';' before identifier 'show'
Error (active) expected a ';'
Error (active) expected a declaration
Error C2059 syntax error: 'return'
Error (active) expected a declaration
Error C2059 syntax error: '}'
Error C2143 syntax error: missing ';' before '}'

What is going on if all these syntax errors are being produced? Did I put the libraries in the right place and have them identified correctly?

Me thinks something "fugly" has transpired...… is there anyway to put this into proper order?


Xanadu
Since I can't see line numbers (and, I suspect, file names - I think many of these are from FLTK source code), I can't even hazard much of a guess, but....a few hint to me maybe, maybe .... turn on C++ 17?

...what year is the book published?
Last edited on
Niccolo,

Here are the errors (in full) so you can see them in their entirety!

Sorry, I did some editing before because I thought that would make it more readable..... it worked ….. but it made it unintelligible also I suppose?

So now I copied the errors directly (below!)

The book was published in 2014 (it only covers C++11 & C++14 according to the cover and contents)

The COMPLETE error list is as follows==>

Severity Code Description Project File Line

Error C2275 'Fl_Window': illegal use of this type as an expression FLTK_GUI_test c:\users\*****\documents\visual studio 2015\projects\fltk_gui_test\fltk_gui_test\main_source.cpp 8

Error C2146 syntax error: missing ')' before identifier 'window' FLTK_GUI_test c:\users\*****\documents\visual studio 2015\projects\fltk_gui_test\fltk_gui_test\main_source.cpp 8

Error C3927 '->': trailing return type is not allowed after a non-function declarator FLTK_GUI_test c:\users\*****\documents\visual studio 2015\projects\fltk_gui_test\fltk_gui_test\main_source.cpp 10

Error C3484 syntax error: expected '->' before the return type FLTK_GUI_test c:\users\*****\documents\visual studio 2015\projects\fltk_gui_test\fltk_gui_test\main_source.cpp 10

Error C3613 missing return type after '->' ('int' assumed) FLTK_GUI_test c:\users\*****\documents\visual studio 2015\projects\fltk_gui_test\fltk_gui_test\main_source.cpp 10

Error C4430 missing type specifier - int assumed. Note: C++ does not support default-int FLTK_GUI_test c:\users\*****\documents\visual studio 2015\projects\fltk_gui_test\fltk_gui_test\main_source.cpp 10

Error C2146 syntax error: missing ';' before identifier 'show' FLTK_GUI_test c:\users\*****\documents\visual studio 2015\projects\fltk_gui_test\fltk_gui_test\main_source.cpp 10

Error C2059 syntax error: 'return' FLTK_GUI_test c:\users\*****\documents\visual studio 2015\projects\fltk_gui_test\fltk_gui_test\main_source.cpp 11

Error C2059 syntax error: '}' FLTK_GUI_test c:\users\*****\documents\visual studio 2015\projects\fltk_gui_test\fltk_gui_test\main_source.cpp 13

Error C2143 syntax error: missing ';' before '}' FLTK_GUI_test c:\users\*****\documents\visual studio 2015\projects\fltk_gui_test\fltk_gui_test\main_source.cpp 13

I bolded the line numbers for ease.

Other info you should know==> The book had me ADD some libraries (these: fltkd.lib;wsock32.lib;comctl32.lib;fltkjpegd.lib;fltkimagesd.lib;) in the following location for the project==> Properties->Linker->Input->Additional Dependencies

It also instructed to have the project ignore a specific library as well: libcd.lib.

The runtime library is also default as Multi-threaded Debug DLL with these additions.

Xanadu
Niccolo & everyone who gives a crap (LOL)…

Found the answer...… if we look at line #6 in the original code the problem is very BLATANT and obvious why nothing is working!! (this is called the dumb ass factor!)

Line #6 reads like this above: int main{

And line #6 SHOULD look like this instead: int main(){

When I correct the problem everything is right in the world as we would all expect.

It turns out that attention to small details makes a large impact.

Thank you all for your help and I hope I didn't waste too much of your time! This issue is solved and we'll go back to our regularly scheduled programming (pun intended) of REAL coding issues and not extreme buffoonery on my part!

Xanadu
Registered users can post here. Sign in or register to post.