How to install and use fltk-1.3.4 in Visual Studio 2017 [complete guide]

Last successfully tested: 30.11.2017

Chapter 12 to 16 of Bjarne Stroustrup’s – “Programming Principles and Practice Using C++” uses a GUI library called FLTK (Fast Light Tool Kit, “full tick”). This guide demonstrates how to download, compile from source, build and use the fltk version 1.3.4 with Visual Studio 2017 Community.
As it was quiet frustrating getting everything to run, I thought I would take the extra time to make it extra detailed, I hope it is not confusing or over complicating things for who ever is struggling with this.

(NOTE: Before you start, even though the following path will get you to compile and run fltk projects, and it is the Bjarne Stroustrup’s Programming Principles and Practice way, the fltk.org team recommended to do it like this guide shows. It is to prevent cross contamination and keep your Visual Studio 2017 environment clean and tidy. The original discussion can be found here. I just left this guide on my page in case people persist on doing it the Bjarne Stroustrup way.)

Step 1: Downloading fltk-1.3.4.

Go to: http://www.fltk.org/index.php
Go to the download tab and click on fltk-1.3.4-1-source.tar.gz

The fltk-1.3.4-1-source.tar.gz should be automatically downloaded.

I used winRar to extract fltk-1.3.4-1-source.tar.gz to my documents folder.

Step 2: Compiling and building fltk-1.3.4 from source.

Go to your extracted fltk-1.3.4 folder. In my case C:\Users\Philipp\Documents\dev\fltk-1.3.4-1-source\fltk-1.3.4-1\ide\VisualC2010

Open (double-click) fltk.sln.

Visual Studio 2017 Community will open, and ask you if you want to update the files.

Click OK and wait for a few moments.
Your window will look like this:

Right-click the demo solution file.
Click on Set as StartUp Project.

Now click on Build and Build Solution.

After a couple of moments your Output window shows Build: 79 succeeded…

Make sure to set Debug mode.

Press F5 on your keyboard. Or the playbutton on top of your canvas Local Windows Debugger.

So far so good. You should get two windows, one console window and another one showing the fltk-test layout.

Now change the Debug mode to Release mode on the top left corner of your Visual Studio window.

Again: Press F5 on your keyboard. Or the playbutton on top of your canvas Local Windows Debugger to run your project.
You should now see the fltk-test layout and no console window.

Good job. Done compiling and test-running.

Step 3: Integrating fltk-1.3.4 files into your Visual Stuido 2017 Community folder structure.
Now you need to copy those freshly compiled files (explained in three steps in the next paragraph) into your Visual Studio 2017 Community folder structure so it knows where to find them:

1. Go to: your fltk-1.3.4-1 folder (in my case: C:\Users\Philipp\Documents\dev\fltk-1.3.4-1-source\fltk-1.3.4-1) and copy the Fl folder into your include folder (in my case): C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\include

2. Go to: the lib folder in your fltk source folder (in my case C:\Users\Philipp\Documents\dev\fltk-1.3.4-1-source\fltk-1.3.4-1\lib) and copy all 14 .lib files (Note that there are pairs of 2, one of them named with a “d” for debug in the end). And paste them into your Visual Studio 2017 lib folder (in my case: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\lib\x64). Of course you noticed that in the lib folder there are two more folders: x64 and x86. I just pasted the 14 .lib files into both of them (In case there is someone out there who can tell me if that is wrong or right, please contact me).

fltk-1.3.4-1\lib to VC\Tools\MSVC\14.10.25017\lib\x64

fltk-1.3.4-1\lib to VC\Tools\MSVC\14.10.25017\lib\x86

3. Go to: the fluid folder in your fltk source folder (in my case: C:\Users\Philipp\Documents\dev\fltk-1.3.4-1-source\fltk-1.3.4-1\fluid) and copy fluid.exe and fluidd.exe into your Visual Studio 2017 bin folder (in my case: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\bin).

Excellent, that’s all done. Now lets setup a new project and see if Visual Studio 2017 Community is able to locate and use the files we just copied over.
Let’s open Visual Studio 2017 Community (or any other of course) and under the Visual C++ – Windows Desktop tab create a new Windows Desktop Wizard project.

Tick the box Empty project (very important).

I called it fltk_test.

In your newly created Empty Project right click the Source Files folder and Add a New Item which is going to be a .cpp file.
I called it fltk_test.cpp.

Copy the following code into your .cpp file:

[code language=”cpp”]
#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();
}
[/code]

(NOTE: The following Properties setup needs to be done for every new fltk project you are creating! I will tell you later to come back to this point.)
Then go to your top navigation bar and click Project and in the drop-down menu Properties.

Make sure to set the Configuration to Debug.

On your left hand side go to Linker.

And Input.

Click on the drop-down arrow in the Additional Dependencies tab.

And click on Edit.

A new window will pop up. In the screenshot shown I filled in already the following entries:

fltkd.lib
wsock32.lib
comctl32.lib
fltkjpegd.lib
fltkimagesd.lib

Please do the same.

Click OK to confirm your entry.

Now go to System.
And set the SubSystem to Console (/SUBSYSTEM:CONSOLE) with the help of the drop-down menu.

Click Apply and hit F5 to test-run the project.
If you have done everything I told you so far your project should compile and run and show something like this:

Great, now go back to your PropertiesProject and Properties.
And chose from the Configuration Release.

On the left hand side to Linker and then to Input, just like you did before.

Click on the drop-down arrow to show the Additional Dependencies menu and select Edit.

Copy paste the following entries into the empty field (I filled them out already, Note: Since this is the Release Category there is no d for debug in the .lib names):

fltk.lib
wsock32.lib
comctl32.lib
fltkjpeg.lib
fltkimages.lib

Click OK and go to Sysyem.

Set the SubSystem to Windows (/SUBSYSTEM:WINDOWS), which can be found in the drop-down menu and click OK.

Apply your changes and exit your Properties window with OK.
Now change the Solution Configurations to Release.

And run your project by pressing F5 on your keyboard, or the playbutton on the top of your canvas Local Windows Debugger.
If everything went well you should be able to look at something like this (application window with the fltk-interface and no console window, if this didn’t go as planned please go to the next step):

At this point maybe people experience an error message saying “… cannot open include file ‘x11/xlib.h’ no such file or directory …”. Here is how to fix this:
(If everything works for you just fine, please skip ahead!)

Double click the error message in your errors tab, the x.H file will open in Visual Studio 2017 Community as a new tab, if not go to your External Dependencies folder in your Solution Explorer within Visual Studio and look for the file manually and open it. As you may notice already, the errors will be underlined in curly red.

Now go to line 28, between # include “Enumerations.H” on line 27 and # ifdef WIN32 and include # define WIN32 like this:


# include “Enumerations.H”
# define WIN32
# ifdef WIN32

Safe the file and you should be good to go, now: Hit F5 to test-run the project and it should look like this:

If you got to this point: Congratulations, you made it!
For who ever was interested in just getting the fltk-1.3.4 GUI library running and applying it on a test project, this is the end of your journey and this guide. If you are working through Bjarne Stroustrup’s Programming Principles and Practice Using C++ and you are in Chapter 12 starting to use fltk keep on reading for instructions on how to use it within the “Stroustrup”-environment:

Step 4: Using fltk-1.3.4 with Bjarne Stroustrup’s header and .cpp files.
Safe your fltk test-project and create a new project. Under the Visual C++ – Windows Desktop tab create a new Windows Desktop Wizard project, just like you did before (I will go through this a bit faster as you should be familiar by now).

Tick the box Empty project (very important).

I called mine BS_PPP_Cpp_fltk.

Right-click the Source Files folder in your Solution Explorere and Add a New Item. Create a new .cpp file, I called mine p437_d_1_.cpp.

Copy and paste the following code from Bjarne Stroustrup’s Programming Principles and Practice Using C++, Drill 1 page 437:

[code language=”cpp”]
#include “Graph.h”
#include “Simple_window.h”

int main()
{
using namespace Graph_lib;

Point tl(150, 150);
Simple_window win(tl, 600, 400, “My window”);
win.wait_for_button();
}
[/code]

Go to Project and Properties and setup your project in the exact same way we did with our fltk test-project above.

Now this time, we have to add a couple of header files from Bjarne Stroustrup, and also some additional .cpp files.
Let’s begin with the header files:
Most of the people reading, working through Programming Principles and Practice Using C++ included the std_lib_facilities.h already many times so for who ever does not know where to get it from, this is the link. Download it and copy it in your project folder (in my case: C:\Users\Philipp\Documents\Visual Studio 2017\Projects\BS_PPP Cpp_fltk\BS_PPP_Cpp_fltk\BS_PPP_Cpp_fltk).
As well as the following header files:

std_lib_facilities.h
fltk.h
Graph.h
GUI.h
Point.h
Simple_window.h
Window.h

and while your on it also download and copy the following .cpp files into your project directory (as mentioned above):

Graph.cpp
GUI.cpp
Window.cpp

Right-click the Header Files folder in your project’s solution explorer. Add an Existing Item.

Once you added all your header files the Header Files folder should look like this:

Now also add the .cpp files: Graph.cpp, GUI.cpp and Window.cpp to your Source Files folder. Your Source Files folder should look like this:

Your project directory folder and your Solution Explorer in Visual Studio 2017 should look like this:

Now you are almost there. We just have to make a couple of changes to those Added files.

Open the Point.h header file by double clicking it:

Remove all the notation double forward-slashes:

Open the GUI.cpp file by double clicking it:

Add Graph_lib:: in front of Window& of Button::attach (line 8)

In_box::attach (line 30) and Out_box::attach (line 49).

and remove or notate the constructor Menu::Menu as it is already defined in GUI.h.

Open the Graph.cpp file:

And go to line 313. Change return ff; to return bool(ff);

The last change you have to make is in Graph.h, open and #include “std_lib_facilities.h”:

This is it. Now safe all your files and run your project. I like to just hit F5.
If everything goes right and you were able to follow my instructions you should be able to see the following:

CONGRATULATION, ALL DONE!
If you made it so far and everything worked out I am very happy I could help you. At this point I should mention Benjamin Wuethrich. I followed his tutorial on installing and using fltk on Visual Studio 2015 and with the help of a bunch of other peoples forum posts and other informations I was able to transfer the knowledge to make it happen on Visual Studio 2017 Community. So thanks to Benjamin Wuethrich. His tutorial for Visual Studio 2015 can be found here.

Thank you for going through this with me, if you have any questions I am very happy to help. Also if you have any suggestions for improvement, please let me know.

Title Photo by Elijah Ekdahl on Unsplash

Newsletter Updates

Enter your email address below to subscribe to our newsletter

93 Comments

  1. Thank you for this guide, I couldn’t find any other guides better than this for me. But sadly I failed. I followed your steps and this error occured

    Severity Code Description Project Path File Line Suppression State
    Error C1083 Cannot open include file: ‘X11/Xlib.h’: No such file or directory fltk_test h:\prog\visual studio 2017\vc\tools\msvc\14.11.25503\include\fl h:\prog\visual studio 2017\vc\tools\msvc\14.11.25503\include\fl\x.h 37

    (just copied from Error List of visual studio)

    Can I get some solution about these?

    • Hi Eric,
      I can try to help on this:
      The fl (“h:\prog\visual studio 2017\vc\tools\msvc\14.11.25503\include\fl”) folder in your include directory is capital letters “FL” and it needs to stay that way! I think that should solve all your problems.
      Let me know how it goes.

      Best, P

      PS: There is also a non-destructive-guide: https://bumpyroadtocode.com/2017/08/29/how-to-install-and-use-fltk-1-3-4-in-visual-studio-2017-complete-guide-2-0-no-cross-contamination/ The fltk.org team actually recommended to do it that way, I just kept the other guide (you have been using), because it is the Bjarne Stroustrup described way of installing fltk.

    • Hello,
      Thank you for your guidelines. After failing multiple times, I finally went to the last step of your great tutor, but I could not run the final step of the project. I am using the latest FLTK-1.3.5; I tried the older version, but this version took me to the last step of this tutorial.
      This is actually my first time to program, and I just purchased the Bjarne Stroustrup Book you mentioned.
      Thank you,

    • Γ–mer Feyyaz Γ–zdemir
      Γ–mer Feyyaz Γ–zdemir

      How can we remove the console opened with the window?

  2. Thank you so much for these step-by-step instructions. I was able to rebuild FLTK under VS 2017 and then use the newly generated file with my FLTK project, which I had also upgraded from VS 2015 to 2017.

  3. Hey, I am using 1.3.4 with VS 2013. The 79 files compiled and the demo project ran successfully. However, I failed to integrate FLTK with VS 2013 for my project. I found there were only 7 files in ..\fltk-1.3.4-2\lib folder. Your example shows 14 files. Am I missing something?

    • Hi Iloovatar, yes there must be something odd. In theory there should be 7 for release and 7 .lib files for debug. Note that I did my tutorial with fltk-1.3.4-1 instead of fltk-1.3.4-2, they must have released a new version which I have not reviewed yet. Either you download the fltk-1.3.4-1 and everything should be fine, or you hang tight till I get the chance to look at fltk-1.3.4-2… πŸ™‚

  4. Phil, you saved my life. Thanks a lot. I’ve spent 7 days tearing my hair, trying to make this program to work before I find your site.

  5. Hi! I have installed FLTK library according to your instructions and tested it. All works great. I wrote code from PPP2 and changed all headers and .cpps as you did in your manual. I’ve defined WIN32 before all FLTK includes. But after run of application in debug mode read access violation exception was thrown.
    https://ibb.co/nRi7Nb
    In release mode it wasn’t. In release mode all works great and result is as depicted in Stroustrup’s book.
    Why?

    • Hi vicgor, I am not entirely sure what the exact issues is, but I can have a guess: Did you specifically setup the lib files in your configurations for debug and release as I have described? There are two different types of lib files, fltk.lib, wsock32.lib, comctl32.lib, fltkjpeg.lib, fltkimages.lib for release and fltkd.lib, wsock32.lib, comctl32.lib, fltkjpegd.lib, fltkimagesd.lib for debug, notice the “d” (fltk[d].lib) in the file names.

  6. Yes, you was right. The problem was with my code, not with the library. For my regret I didn’t manage to identify a cause of error. What I did I deleted all headers of Stroustrup, downloaded the new ones and prepared them like you did. Program runs in both (release and debug) modes. It’s a pity that I could not find the error.

  7. You wrote an updated version! Great. I’ll put a link to this one at the top of my old one πŸ™‚ Thanks for the mention!

  8. Hi,

    I think your step-by-step explanation is very helpful. However, I rather have an issue that I am not sure how to solve/approach. Sorry if it is a stupid question but for two days I was not able to find the answer for it and I am still clueless.

    Basically, I downloaded fltk 1.3.4-1, Extracted the files and followed the rest of the instructions. In the process of VS building the solution, I get some sort of glitch. When it goes to the point to compile the fluid files, it freezes. No errors letting me know about an issue or anything, it is just forever compiling the fluid files. Here is some of the of Build Output:

    6>fluid.vcxproj -> C:\Users\Egeni\Documents\fltk-1.3.4-1\ide\VisualC2010\..\..\fluid\fluidd.exe
    68>—— Build started: Project: CubeView, Configuration: Debug Win32 ——
    69>—— Build started: Project: fast_slow, Configuration: Debug Win32 ——
    70>—— Build started: Project: inactive, Configuration: Debug Win32 ——
    71>—— Build started: Project: keyboard, Configuration: Debug Win32 ——
    71>Create .cxx and .h file with fluidd
    70>Create .cxx and .h file with fluidd
    68>Create .cxx and .h file with fluidd
    70>Compiling fluid files …
    71>Compiling fluid files …
    68>Compiling fluid files …
    69>Create .cxx and .h file with fluidd
    69>Compiling fluid files …

    Any help with this would be greatly appreciated.

    Thanks

    • Hi ekolevblog, I’m not quiet sure what the solution to your problem is, but you might be victim of cross contamination. I recommend you to re-install Visual Studio and try this other guide, which ensures there is no cross contamination, the guide you have been using is as Bjarne Stroustrup describes in his book, but is actually not recommended by fltk.org, go here and try this way of installing fltk. Good luck!

      • Hi bumpyroadtocode, apparently the first time I attempted to compile fltk something went wrong. The fluid.exe and fluidd.exe got stuck as processes requesting service in the background.As a result of this, from then on whether I reinstall VS or reboot my PC they would still wait in the background causing my compilation to glitch at compiling fluid files. Anyway, I figured my way around this and followed the rest of your guide. Everything works perfectly now.

        Awesome, thank you!

        • Hi ekolevblog, I’m happy everything went well in the end, but could you take the time and write a quick comment on how you fixed it, just in case someone else would bump into the same issue! Thanks in advance!

      • Hi bumpyroadtocode. The process of fixing the issue I had turned out to not be so complicated, just took time to figure it out…

        Basically, the fluid processes were running in the background, regardless of whether I would turn off and on my PC. To fix this I had to forcefully kill the processes. I did this in the Command Prompt using their PIDs (process ID).

        1. Open cmd.exe

        2. type the “tasklist” command in the Command Prompt

        I used “tasklist” to browse through all of the processes and see if there are any called “fluid” or “fluidd”. Once found on the list, I used their PID numbers to forcefully kill them.

        3. type “taskkill /PID 1234 /f” command in the Command Prompt

        “taskkill” this is the command to kill the process, “/PID” option allows you to use the task’s PID number (in the above case 1234), “/f” option kills the task forcefully.

        Hope this would help should anyone has a similar problem like mine.

        Thanks again.

  9. […] folder structure, the include and library paths are propperly (I hope so!) added to the project. How to compile FLTK – [following the instruction of Principles and Practice using […]

  10. […] folder structure, the include and library paths are propperly (I hope so!) added to the project. How to compile FLTK – [following the instruction of Principles and Practice using […]

  11. Hi,

    This is the best guide i found (and I was searching for a long time), but I still got a problem. When I compile code example from Bjarne’s book, there errors shows: https://imgur.com/a/zoFdZ

    Hope you will help me, cause I’m installing it already too long and I’m tired of it πŸ™
    Help me bumpyroadtocode, you’re my only hope

    • Haha, that’s too funny. I was struggling with fltk for about two weeks 24/7, I don’t know why it is so hard. I had exactly the same problem as you did and I resolved the issue of the x.H problem in this guide, but as per your request also in the guide you did. Just refresh your page and have a look at my change. The change is in about the middle of the page, essentially you have to change some stuff in the x.H file. If you want to find the change in my post you can also search for the following text: “At this point maybe people experience an error message saying β€œβ€¦ cannot open include file β€˜x11/xlib.h’ no such file or directory …”.” I hope this helps, let me know how things go!

      • Thanks for reply, but it still doesn’t work: access to x.H is denied, so I can’t save it :/

      • I did, and I still got the same error πŸ™

      • No, I didn’t change anything, cause I can’t save it – I don’t have permissons to save that x.H file, so I can’t do anything

        • I cannot see a way for this to work if you can’t open files like the x.H. Two things, what operating system are you using? And where is your x.H you’re trying to open located?

      • I’m using Windows 10, and the x.H is in the D:\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\include\FL
        I even edited it, by moving it into another folder, writing that line, and than moving it back. It worked, but not completely – now I got error “#error: is deprecated and will be REMOVED. Please use . You can define _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS to acknowledge that you have received this warning.” xD

        • I highly recommend uninstalling Visual Studio 2017 and using my other guide here. It seems like it would be helpful to really be able to modifie fltk files without messing things up in the Visual Studio environment. (The guide I sent is more best practice and prevent cross-contamination)

  12. Thank you very much! I lost 10 hours for implementation this shit, before I found your guide :D.

  13. This is absolutely helpful, helping many many people to save hours and hours. Mr. Stroustrup should simply add the link to this site in his new version of the textbook.

  14. An option for windows machines is to use “vcpkg” to install FLTK and integrate it with Visual Studio.
    It works really well for tons of third-party libraries.

  15. Thanks so much for your help on both installing FLTK and “fixing” the graphics and GUI interface files for the Stroustrup Chapter 12 Drill. Really saved the day for me!

  16. Hay man, thanks for the post, it really helped me a lot, but I have one problem. When I try to compile the test program from page 1206 from the book Programming, principles and practice using C++ it gives me linker error – cannot open the fltkd.lib file. I believe it is because I did not copied the files from the lib folder from the FLTK folder to the VS/include folder. But in every download that I make from fltk.org the lib folder is empty?! :/ There is only one readme file. Any sugestions? Thanks in advance.

  17. Thank you so much!!! it halped!

  18. alok bhushan pandey
    alok bhushan pandey

    1>—— Build started: Project: Project19, Configuration: Debug Win32 ——
    1>Graph.cpp
    1>c:\users\alok bhushan pandey\desktop\graph.cpp(56): warning C4244: ‘=’: conversion from ‘double’ to ‘int’, possible loss of data
    1>c:\users\alok bhushan pandey\desktop\graph.cpp(57): warning C4244: ‘=’: conversion from ‘double’ to ‘int’, possible loss of data
    1>GUI.cpp
    1>c:\users\alok bhushan pandey\desktop\window.h(6): fatal error C1083: Cannot open include file: ‘std_lib_facilities.h’: No such file or directory
    1>Window.cpp
    1>c:\users\alok bhushan pandey\desktop\window.h(6): fatal error C1083: Cannot open include file: ‘std_lib_facilities.h’: No such file or directory
    1>Source.cpp
    1>d:\cpp\project19\project19\graph.h(89): error C2143: syntax error: missing ‘;’ before ‘d:\cpp\project19\project19\graph.h(112): note: see reference to class template instantiation ‘Graph_lib::Vector_ref’ being compiled
    1>d:\cpp\project19\project19\graph.h(89): error C4430: missing type specifier – int assumed. Note: C++ does not support default-int
    1>d:\cpp\project19\project19\graph.h(89): error C2238: unexpected token(s) preceding ‘;’
    1>d:\cpp\project19\project19\graph.h(90): error C2143: syntax error: missing ‘;’ before ‘d:\cpp\project19\project19\graph.h(90): error C4430: missing type specifier – int assumed. Note: C++ does not support default-int
    1>d:\cpp\project19\project19\graph.h(90): error C2238: unexpected token(s) preceding ‘;’
    1>d:\cpp\project19\project19\graph.h(119): error C2061: syntax error: identifier ‘initializer_list’
    1>d:\cpp\project19\project19\graph.h(119): error C2535: ‘Graph_lib::Shape::Shape(void)’: member function already defined or declared
    1>d:\cpp\project19\project19\graph.h(118): note: see declaration of ‘Graph_lib::Shape::Shape’
    1>d:\cpp\project19\project19\graph.h(158): error C2143: syntax error: missing ‘;’ before ‘d:\cpp\project19\project19\graph.h(158): error C4430: missing type specifier – int assumed. Note: C++ does not support default-int
    1>d:\cpp\project19\project19\graph.h(158): error C2238: unexpected token(s) preceding ‘;’
    1>d:\cpp\project19\project19\graph.h(125): error C2065: ‘points’: undeclared identifier
    1>d:\cpp\project19\project19\graph.h(125): error C2228: left of ‘.push_back’ must have class/struct/union
    1>d:\cpp\project19\project19\graph.h(125): note: type is ‘unknown-type’
    1>d:\cpp\project19\project19\graph.h(126): error C2065: ‘points’: undeclared identifier
    1>d:\cpp\project19\project19\graph.h(143): error C2065: ‘points’: undeclared identifier
    1>d:\cpp\project19\project19\graph.h(144): error C2065: ‘points’: undeclared identifier
    1>d:\cpp\project19\project19\graph.h(144): error C2228: left of ‘.size’ must have class/struct/union
    1>d:\cpp\project19\project19\graph.h(144): note: type is ‘unknown-type’
    1>d:\cpp\project19\project19\graph.h(192): error C3861: ‘error’: identifier not found
    1>d:\cpp\project19\project19\graph.h(197): error C3861: ‘error’: identifier not found
    1>d:\cpp\project19\project19\graph.h(238): error C2061: syntax error: identifier ‘initializer_list’
    1>d:\cpp\project19\project19\graph.h(238): error C2535: ‘Graph_lib::Lines::Lines(void)’: member function already defined or declared
    1>d:\cpp\project19\project19\graph.h(237): note: see declaration of ‘Graph_lib::Lines::Lines’
    1>d:\cpp\project19\project19\graph.h(238): error C2065: ‘lst’: undeclared identifier
    1>d:\cpp\project19\project19\graph.h(238): error C2228: left of ‘.size’ must have class/struct/union
    1>d:\cpp\project19\project19\graph.h(238): note: type is ‘unknown-type’
    1>d:\cpp\project19\project19\graph.h(238): error C3861: ‘error’: identifier not found
    1>d:\cpp\project19\project19\graph.h(245): error C4430: missing type specifier – int assumed. Note: C++ does not support default-int
    1>d:\cpp\project19\project19\graph.h(245): error C2143: syntax error: missing ‘,’ before ‘&’
    1>d:\cpp\project19\project19\graph.h(249): error C4430: missing type specifier – int assumed. Note: C++ does not support default-int
    1>d:\cpp\project19\project19\graph.h(249): error C2143: syntax error: missing ‘,’ before ‘&’
    1>d:\cpp\project19\project19\graph.h(250): error C3646: ‘label’: unknown override specifier
    1>d:\cpp\project19\project19\graph.h(250): error C2059: syntax error: ‘(‘
    1>d:\cpp\project19\project19\graph.h(250): error C2334: unexpected token(s) preceding ‘{‘; skipping apparent function body
    1>d:\cpp\project19\project19\graph.h(258): error C3646: ‘lab’: unknown override specifier
    1>d:\cpp\project19\project19\graph.h(258): error C4430: missing type specifier – int assumed. Note: C++ does not support default-int
    1>d:\cpp\project19\project19\graph.h(245): error C2065: ‘s’: undeclared identifier
    1>d:\cpp\project19\project19\graph.h(245): error C2614: ‘Graph_lib::Text’: illegal member initialization: ‘lab’ is not a base or member
    1>d:\cpp\project19\project19\graph.h(249): error C2065: ‘lab’: undeclared identifier
    1>d:\cpp\project19\project19\graph.h(249): error C2065: ‘s’: undeclared identifier
    1>d:\cpp\project19\project19\graph.h(267): error C2061: syntax error: identifier ‘string’
    1>d:\cpp\project19\project19\graph.h(326): error C4430: missing type specifier – int assumed. Note: C++ does not support default-int
    1>d:\cpp\project19\project19\graph.h(326): error C2143: syntax error: missing ‘,’ before ‘&’
    1>d:\cpp\project19\project19\graph.h(329): error C3646: ‘mark’: unknown override specifier
    1>d:\cpp\project19\project19\graph.h(329): error C4430: missing type specifier – int assumed. Note: C++ does not support default-int
    1>d:\cpp\project19\project19\graph.h(326): error C2065: ‘m’: undeclared identifier
    1>d:\cpp\project19\project19\graph.h(326): error C2614: ‘Graph_lib::Marked_polyline’: illegal member initialization: ‘mark’ is not a base or member
    1>d:\cpp\project19\project19\graph.h(333): error C4430: missing type specifier – int assumed. Note: C++ does not support default-int
    1>d:\cpp\project19\project19\graph.h(333): error C2143: syntax error: missing ‘,’ before ‘&’
    1>d:\cpp\project19\project19\graph.h(333): error C2065: ‘m’: undeclared identifier
    1>d:\cpp\project19\project19\graph.h(338): error C3861: ‘string’: identifier not found
    1>d:\cpp\project19\project19\graph.h(361): error C4430: missing type specifier – int assumed. Note: C++ does not support default-int
    1>d:\cpp\project19\project19\graph.h(361): error C2143: syntax error: missing ‘,’ before ‘&’
    1>d:\cpp\project19\project19\graph.h(364): error C2061: syntax error: identifier ‘string’
    1>d:\cpp\project19\project19\window.h(6): fatal error C1083: Cannot open include file: ‘std_lib_facilities.h’: No such file or directory
    1>Generating Code…
    1>Done building project “Project19.vcxproj” — FAILED.
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

  19. OH MY GOD I DID IT!!!
    few minthes I was fighting with this example for a week and failed, but today I decided to take another try and I managed, words can’t tell how proud I am of myself )))
    THANK YOU SO MUCH!

    As Addition I have to say that I had to edit Graph.h a little bit:
    change {} to () in line
    fnt_sz {(fl_size()<14)?14:fl_size()} { add(x); }
    to
    fnt_sz ((fl_size()<14)?14:fl_size()) { add(x); }

    (I'm using VS2010)

    • Thats the one thing I do not understang in Stroustrups book. Why on earth would you use {} in that case? It looks just confusing to me … anyway, happy it worked out for you!!

  20. Thank you for posting this. It helped so much especially since other tutorials werent working πŸ™‚

  21. Thank you very much for this post. I managed to follow it to the end successfully! I am using “Programming, Principles and Practice Using C++” but got stuck on D.3 Installing FLTK and that’s where you helped me. Thanks again.

  22. I got stuck following Mr. Stroustrup instructions from his textbook. This post saved me from crawling the Internet for hours.
    Absolutely amazing, thank you so much.

  23. After redoing all of this three times I still get 6 errors that are all related to simple_window.cpp
    These are the errors:

    Severity Code Description Project File Line Suppression State
    Error C2084 function ‘void Simple_window::cb_next(Graph_lib::Address,Graph_lib::Address)’ already has a body Programming Principles and Practice Using C++ c:\users\cm storm i7\source\repos\programming principles and practice using c++\programming principles and practice using c++\simple_window.cpp 44
    Error C2556 ‘bool Simple_window::wait_for_button(void)’: overloaded function differs only by return type from ‘void Simple_window::wait_for_button(void)’ Programming Principles and Practice Using C++ c:\users\cm storm i7\source\repos\programming principles and practice using c++\programming principles and practice using c++\simple_window.cpp 25
    Error C2371 ‘Simple_window::wait_for_button’: redefinition; different basic types Programming Principles and Practice Using C++ c:\users\cm storm i7\source\repos\programming principles and practice using c++\programming principles and practice using c++\simple_window.cpp 21
    Error C2084 function ‘Simple_window::Simple_window(Graph_lib::Point,int,int,const std::string &)’ already has a body Programming Principles and Practice Using C++ c:\users\cm storm i7\source\repos\programming principles and practice using c++\programming principles and practice using c++\simple_window.cpp 11
    Error C2084 function ‘void Simple_window::next(void)’ already has a body Programming Principles and Practice Using C++ c:\users\cm storm i7\source\repos\programming principles and practice using c++\programming principles and practice using c++\simple_window.cpp 51
    Error C2084 function ‘void Simple_window::wait_for_button(void)’ already has a body Programming Principles and Practice Using C++ c:\users\cm storm i7\source\repos\programming principles and practice using c++\programming principles and practice using c++\simple_window.cpp 25

    • I now got rid of these simple_window related errors and now I get the following errors:

      Severity Code Description Project File Line Suppression State
      Error LNK2005 “class std::mersenne_twister_engine & __cdecl get_rand(void)” (?get_rand@@YAAAV?$mersenne_twister_engine@I$0CA@$0CHA@$0BIN@$0BP@$0JJAILANP@$0L@$0PPPPPPPP@$06$0JNCMFGIA@$0P@$0OPMGAAAA@$0BC@$0GMAHIJGF@@std@@XZ) already defined in Graph.obj Programming Principles and Practice Using C++ C:\Users\CM Storm i7\source\repos\Programming Principles and Practice Using C++\Programming Principles and Practice Using C++\Simple_window.obj 1
      Error LNK2005 “class std::mersenne_twister_engine & __cdecl get_rand(void)” (?get_rand@@YAAAV?$mersenne_twister_engine@I$0CA@$0CHA@$0BIN@$0BP@$0JJAILANP@$0L@$0PPPPPPPP@$06$0JNCMFGIA@$0P@$0OPMGAAAA@$0BC@$0GMAHIJGF@@std@@XZ) already defined in Graph.obj Programming Principles and Practice Using C++ C:\Users\CM Storm i7\source\repos\Programming Principles and Practice Using C++\Programming Principles and Practice Using C++\GUI.obj 1
      Error LNK2005 “class std::mersenne_twister_engine & __cdecl get_rand(void)” (?get_rand@@YAAAV?$mersenne_twister_engine@I$0CA@$0CHA@$0BIN@$0BP@$0JJAILANP@$0L@$0PPPPPPPP@$06$0JNCMFGIA@$0P@$0OPMGAAAA@$0BC@$0GMAHIJGF@@std@@XZ) already defined in Graph.obj Programming Principles and Practice Using C++ C:\Users\CM Storm i7\source\repos\Programming Principles and Practice Using C++\Programming Principles and Practice Using C++\Window.obj 1
      Error LNK2005 “void __cdecl seed_randint(int)” (?seed_randint@@YAXH@Z) already defined in Graph.obj Programming Principles and Practice Using C++ C:\Users\CM Storm i7\source\repos\Programming Principles and Practice Using C++\Programming Principles and Practice Using C++\GUI.obj 1
      Error LNK2005 “void __cdecl seed_randint(int)” (?seed_randint@@YAXH@Z) already defined in Graph.obj Programming Principles and Practice Using C++ C:\Users\CM Storm i7\source\repos\Programming Principles and Practice Using C++\Programming Principles and Practice Using C++\Simple_window.obj 1
      Error LNK2005 “void __cdecl seed_randint(int)” (?seed_randint@@YAXH@Z) already defined in Graph.obj Programming Principles and Practice Using C++ C:\Users\CM Storm i7\source\repos\Programming Principles and Practice Using C++\Programming Principles and Practice Using C++\Window.obj 1
      Error LNK1169 one or more multiply defined symbols found Programming Principles and Practice Using C++ C:\Users\CM Storm i7\source\repos\Programming Principles and Practice Using C++\Debug\Programming Principles and Practice Using C++.exe 1

  24. I followed the set up but I keep getting this error
    LNK1104 cannot open file ‘fltkd.lib’
    What could I be missing?

  25. Just want to echo everyone else and say THANK YOU for this wonderful guide. The installation and compiling of this library and Stroustrup’s interfaces is such a nightmare due to massively outdated documentation from both parties. You are an absolute life saver πŸ™‚

  26. Followed the steps but can’t use Polygon. (here is what happens: https://cdn.discordapp.com/attachments/244238376167800832/593075173553340433/unknown.png )
    It seems to be defined in Graph.h but these errors happen and it won’t run.

  27. Thank you so mush,Your article helped me to connet fltk to my project, your article is better than straustrup’s book

  28. Can someone help me? I’m getting this error and I dont know what to do, img link here https://imgur.com/nS0eXvu

  29. Really helpful guide with images. Thanks a lot for this post!

    (This is a guide that Bjarne Stroustrup should have made, since it is need for his “book”, but he did not… 😠)

  30. Thank you you wonderful person! I’ve been trying to get this to work for 2 weeks now and i was just about to give up on chapters 12-16 you’re the best!

  31. Dear Bumpyroadtocode, though I am terribly inexperienced, I managed to install FLTK and make running the first example of BS-ppp-chapter 12. I am immensely grateful to you, as I am able now to continue the study of BS-ppp.
    Without your instructions , I would have been completely stuck . Kind regards. Luc Bonte

  32. Hi @bumpyroadtocode thanks a lot for your guide! It is really clear and informative. I’m a beginner and appreciate a lot these detailed descriptions. I just want to let you guys know that in my case I had to do a final step to make everything work: in std_lib_facilities.h comment out:

    // random number generators. See 24.7.

    //default_random_engine& get_rand()
    //{
    // static default_random_engine ran;
    // return ran;
    //};

    //void seed_randint(int s) { get_rand().seed(s); }

    //inline int randint(int min, int max) { return uniform_int_distribution{min, max}(get_rand()); }
    //
    //inline int randint(int max) { return randint(0, max); }

    //inline double sqrt(int x) { return sqrt(double(x)); } // to match C++0x

    // container algorithms. See 21.9.

    I’m using Visual Studio 2015. With this extra step, all worked for me.

  33. Hi @bumpyroadtocode thanks a lot for your guide! It is really clear and informative. I’m a beginner and appreciate a lot these detailed descriptions. I just want to let you guys know that in my case I had to do a final step to make everything work: in std_lib_facilities.h comment out the following:

    // random number generators. See 24.7.

    //default_random_engine& get_rand()
    //{
    // static default_random_engine ran;
    // return ran;
    //};

    //void seed_randint(int s) { get_rand().seed(s); }

    //inline int randint(int min, int max) { return uniform_int_distribution{min, max}(get_rand()); }
    //
    //inline int randint(int max) { return randint(0, max); }

    //inline double sqrt(int x) { return sqrt(double(x)); } // to match C++0x

    // container algorithms. See 21.9.

    I’m using Visual Studio 2015. With this extra step, all worked for me.

  34. Thanks so much for the guidance. I lost a week until I found your article. I succeeded, but the error “Polygon is not unique” occurred
    , “Rectangle is not unique”, “Ellipse is not unique”
    Found a solution!
    To fix the ambiguity error of the Polygon, Rectangle, and Ellipse classes:
    1. In the header file Graph.h, rename the name of the conflicting structures (classes).
    2. Rename the method names of these structures (classes) in the source file Graph.cpp.
    3. Rename to source file
    the names of these classes, respectively.

    PS.
    Once again, many thanks to the author of the article for the time saved and the opportunity to move on.

  35. Echoing sentiments above – this stumbling block would have prevented any further progress through the book. Many, many thanks sir!

  36. Thank you for writing the post. While studying “programming principles and practice using c ++”, I was looking for a way out because I got stuck. Thank you very much.(in Korea)

  37. Could you do a tutorial on how to install fltk on Visual Studio Code?

  38. Thanks for the guide, it was really useful.

    You helped make the road to code a little less bumpy! ^^

  39. Hello buddy, i was able to do the fltk stuffs following your instructions but i now have a hard time with Bjarne’s header and cpp files. The link to the page you added seems unavailable. Bjarne complained about that page being lost and provided a new link to download those files. I then followed your instructions in debugging the those files but there seem to be more bugs in them as compared to the one you debugged. Could you please help, i’m really exausted and disoriented, i feel like ditching the whole idea of learning to program in general but it happens to be my sole dream.
    Thanks anyway for the fltk stuffs.

    • It was one of the most frustrating things in my programming path so far for sure… Can you send me the link to the new webpage where there is the new header file? I was thinking to do a video tutorial the coming days, so might integrate it!

Leave a Reply

Physical Address

304 North Cardinal St.
Dorchester Center, MA 02124