Read Instruction on the Following Lines or in the Following Line

Last successfully tested: xxx.11.2017

Chapter 12 to xvi 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 information technology was quiet frustrating getting everything to run, I thought I would have the extra time to make information technology actress detailed, I hope it is not disruptive or over complicating things for who ever is struggling with this.

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

Pace 1: Downloading fltk-i.3.4.

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

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

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

Pace 2: Compiling and building fltk-ane.3.4 from source.

Get to your extracted fltk-ane.3.four binder. In my case C:\Users\Philipp\Documents\dev\fltk-ane.3.four-1-source\fltk-1.three.4-one\ide\VisualC2010

Open (double-click) fltk.sln.

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

Click OK and look for a few moments.
Your window will look similar 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 prepare Debug mode.

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

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

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

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

Good task. Done compiling and exam-running.

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

i. Go to: your fltk-one.3.4-ane folder (in my case: C:\Users\Philipp\Documents\dev\fltk-1.iii.four-1-source\fltk-1.3.4-1) and re-create the Fl folder into your include binder (in my instance): C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\xiv.10.25017\include

2. Go to: the lib binder in your fltk source binder (in my case C:\Users\Philipp\Documents\dev\fltk-1.3.iv-1-source\fltk-1.three.4-ane\lib) and copy all fourteen .lib files (Note that in that location 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 binder (in my case: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\lib\x64). Of grade you noticed that in the lib folder at that place are 2 more than folders: x64 and x86. I just pasted the fourteen .lib files into both of them (In case there is someone out there who can tell me if that is incorrect or right, please contact me).

fltk-1.iii.four-i\lib to VC\Tools\MSVC\14.10.25017\lib\x64

fltk-ane.3.4-1\lib to VC\Tools\MSVC\14.ten.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-one.3.iv-1\fluid) and copy fluid.exe and fluidd.exe into your Visual Studio 2017 bin folder (in my instance: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\bin).

Splendid, that's all done. At present lets setup a new project and run into if Visual Studio 2017 Community is able to locate and use the files we simply copied over.
Let's open Visual Studio 2017 Customs (or any other of course) and under the Visual C++ – Windows Desktop tab create a new Windows Desktop Wizard projection.

Tick the box Empty project (very important).

I called information technology fltk_test.

In your newly created Empty Project right click the Source Files binder and Add a New Item which is going to be a .cpp file.
I chosen information technology fltk_test.cpp.

Re-create the following code into your .cpp file:

[lawmaking linguistic communication="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();
}
[/lawmaking]

(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 signal.)
And so go to your top navigation bar and click Projection and in the drop-down carte Properties.

Brand sure to set the Configuration to Debug.

On your left manus side go to Linker.

And Input.

Click on the drop-downward pointer in the Additional Dependencies tab.

And click on Edit.

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

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

Please practise the same.

Click OK to ostend your entry.

Now go to Organization.
And fix the SubSystem to Console (/SUBSYSTEM:Panel) with the aid of the drop-down menu.

Click Use and hit F5 to examination-run the projection.
If you have done everything I told you then far your project should compile and run and bear witness 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, merely like you did before.

Click on the drib-downwards arrow to show the Additional Dependencies menu and select Edit.

Re-create paste the post-obit 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.

Gear up the SubSystem to Windows (/SUBSYSTEM:WINDOWS), which can be found in the driblet-downward menu and click OK.

Apply your changes and leave 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 height of your sheet Local Windows Debugger.
If everything went well you lot should be able to wait at something like this (application window with the fltk-interface and no panel window, if this didn't go as planned delight go to the adjacent step):

At this point maybe people experience an fault message maxim "… cannot open up include file 'x11/xlib.h' no such file or directory …". Here is how to ready this:
(If everything works for you but fine, please skip ahead!)

Double click the error message in your errors tab, the 10.H file will open up in Visual Studio 2017 Community every bit a new tab, if non go to your External Dependencies folder in your Solution Explorer within Visual Studio and look for the file manually and open up information technology. As you may notice already, the errors will be underlined in curly red.

At present become to line 28, betwixt # 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 exist skilful to go, at present: Hit F5 to test-run the project and information technology should expect like this:

If you got to this signal: Congratulations, you made it!
For who ever was interested in just getting the fltk-1.iii.4 GUI library running and applying information technology on a test project, this is the end of your journeying and this guide. If you are working through Bjarne Stroustrup's Programming Principles and Practice Using C++ and you lot are in Chapter 12 starting to use fltk keep on reading for instructions on how to use it within the "Stroustrup"-environs:

Step 4: Using fltk-1.iii.4 with Bjarne Stroustrup'due south header and .cpp files.
Safe your fltk test-project and create a new projection. Nether the Visual C++ – Windows Desktop tab create a new Windows Desktop Sorcerer project, only like you did before (I will go through this a scrap faster as you lot should exist familiar by now).

Tick the box Empty project (very of import).

I called mine BS_PPP_Cpp_fltk.

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

Copy and paste the post-obit code from Bjarne Stroustrup's Programming Principles and Practise Using C++, Drill i page 437:

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

int principal()
{
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 nosotros did with our fltk test-projection higher up.

At present this time, we have to add together a couple of header files from Bjarne Stroustrup, and also some additional .cpp files.
Let'due south begin with the header files:
Nearly of the people reading, working through Programming Principles and Exercise Using C++ included the std_lib_facilities.h already many times so for who ever does not know where to become information technology from, this is the link. Download it and copy it in your projection folder (in my example: 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 as well 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.

In one case you lot added all your header files the Header Files folder should expect like this:

Now too 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 binder and your Solution Explorer in Visual Studio 2017 should look like this:

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

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

Remove all the notation double forward-slashes:

Open the GUI.cpp file by double clicking information technology:

Add Graph_lib:: in front of Window& of Button::adhere (line eight)

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

and remove or notate the constructor Menu::Carte equally it is already divers in GUI.h.

Open the Graph.cpp file:

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

The last modify yous have to brand is in Graph.h, open up and #include "std_lib_facilities.h":

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

CONGRATULATION, ALL DONE!
If you made it so far and everything worked out I am very happy I could assist you. At this betoken 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 institute here.

Thanks for going through this with me, if you accept any questions I am very happy to aid. As well if you lot have any suggestions for improvement, delight let me know.

Title Photograph past Elijah Ekdahl on Unsplash

spaldingcabol1944.blogspot.com

Source: https://bumpyroadtocode.com/2017/08/05/how-to-install-and-use-fltk-1-3-4-in-visual-studio-2017-complete-guide/

0 Response to "Read Instruction on the Following Lines or in the Following Line"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel