Installing FLTK 1.3.3 under Visual Studio Community 2013

Downloading and building FLTK

Download FLTK from here: get fltk-1.3.3-source.tar.gz and decompress it, using for example 7-Zip. You should end up with a directory fltk-1.3.3; I have put mine in a subfolder of my Documents folder:

2014_12_25-01.png

Now open the project file fltk.sln in fltk-1.3.3/ide/VisualC2010. If asked, say you’re okay with updating the project files.

Make sure you have selected Debug as your solution configuration.

2014_12_25-04.png

In the context menu of the demo project, select Set as StartUp Project.

2014_12_25-05.png

Now build the solution (Build – Build Solution or Ctrl+Shift+B). If successful, you should be able to run the demo project (Debug – Start Debugging or F5).

Change the solution configuration to Release and build again. Check if you can run the demo project (F5).

Now we have to copy the generated library files to the right directory so Visual Studio finds them. In my installation, the libraries and headers are in C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC (just VC from now on). If you have the right directory, there should be a bunch of subdirectories:

2014_12_25-06.png

Now copy (don’t move) the following from you fltk-1.3.3 folder:

  • The complete FL directory to VC\include
  • All .lib files from fltk-1.3.3\lib (except README.lib) to VC\lib. There should be 14 files: seven pairs of two files each, one of which has an added “d” (for “debug”) at the end of the file name.
  • fluid.exe and fluidd.exe from fltk-1.3.3\fluid to VC\bin

Setting up a FLTK project

To set up a FLTK project, select File – New – Project and choose Win32 Project:

2014_12_25-07.png

In the wizard under Application Settings, check Empty project:

2014_12_25-08.png

Create a source file with Project – Add New Item:

2014_12_25-09.png

Enter this code:

#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();
}

Now open Project – Properties and make sure you have selected Debug in Configuration in the top left corner. Under Linker – Input, edit Additional Dependencies and add fltkd.libwsock32.libcomctl32.libfltkjpegd.lib and fltkimagesd.lib, each on their own line:

2014_12_25-10.png

Because this is the Debug configuration, we would like to have a visible console window. To get that, go to Linker – System and set /SUBSYSTEM:CONSOLE for SubSystem:

2014_12_25-11.png

Now build and run the project. You should get a console window and the GUI window:

2014_12_25-12.png

Now go back to Project – Properties and select Release as the configuration. Go to Linker – Input and edit the Additional Dependencies just like before, but this time, add fltk.libwsock32.libcomctl32.libfltkjpeg.lib and fltkimages.lib – notice the missing “d” at the end of the names:

2014_12_25-13.png

Make sure that under Linker – System, the option /SUBSYSTEM:WINDOWS is selected so we don’t get a console window. Now build and run to see if only the GUI window shows up.

That’s how you set up any project using FLTK!

Getting FLTK with headers from Stroustrup’s book to run

A lot of people struggling with FLTK are using it in the first place because they’re working through Bjarne Stroustrup’s book “Programming – Principles and Practice Using C++”, which uses FLTK in its Chapters 12 to 16 for GUI examples. Stroustrup provides a small interface library to be used in all the exercises. Here is how to set up a project using this interface library:

Create a new Win32 project. I’ve called mine stroustrup_ppp:

2014_12_25-14.png

Make sure it’s empty by selecting Empty project in Application Settings in the Application Wizard.

Now set all the project properties just like above so Visual Studio properly links to the FLTK library files.

For the example, we’re going to do the drill of Chapter 12. Select Project – Add New Itemto add a new file:

2014_12_25-14.png

If you haven’t already, download the standard library access header and the GUI support code from the website and put them in the same directory as chapter12_drill.cpp. Ignore all the matrix files and Gui.h – download GUI.h. Don’t download simple_window.cpp as everything is already defined in simple_window.h. The directory should look like this afterwards:

2014_12_25-14.png

Now add all the files to the project using Project – Add Existing Item:

2014_12_25-15.png

This is actually overkill as we’re not going to use GUI.h and GUI.cpp for a while, but you won’t have to add anything else when you eventually use them.

For some reason, in Point.h, the constructors are commented out. Uncomment everything in the struct.

Now edit chapter12_drill.cpp and enter this code:

#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();
}

If you try to build your solution now, you get a slew of errors. Here is how to get rid of them:

In std_lib_facilities.h, comment out the complete vector part:

2014_12_25-16.png

This should get rid of errors related to vector and initializer lists; you lose range checking, though.

Next, because list initialization inside member initializer list or non-static data member initializer is not implemented in VS 2013, comment out the constructor of Lines in graph.h (line 238). For the same reason, replace the constructor of Text:

2014_12_25-17.png

Next, in GUI.cpp, add Graph_lib:: in front of Window& in the definition of Button::attach (line 8), In_box::attach (line 30) and Out_box::attach (line 49). In Graph.cpp, in the definition of can_open, replace return ff; with return bool(ff); (line 319).

Finally, in GUI.cpp, remove the constructor Menu::Menu as it is already defined in GUI.h.

Now you should be able to build and run the project!

2014_12_25-18.png

Written on December 25, 2014
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Visual Studio 6.0是一款集成开发环境(IDE),用于开发软件应用程序。它由微软公司开发,包含了许多开发工具和语言支持,例如Visual Basic、Visual C++、Visual J++等。 要在Windows 10上安装Visual Studio 6.0,你可以参考一些教程和指南。首先,你可以取消安装Visual Studio FoxPro和Visual Studio InterDev 6.0,以解决可能出现的javasign报错问题。此外,你可以在Visual Studio Marketplace上找到Qt Visual Studio Tools,这是一个用于在Visual Studio中开发Qt应用程序的插件。你还可以参考一些关于在Windows 10上安装Visual Studio 6.0的教程,例如"How to install Visual Studio 6 onto Windows 10"和"Installing Visual Basic/Studio 6 on Windows 10"。 总之,Visual Studio 6.0是一款强大的开发工具,可以帮助开发人员创建各种类型的软件应用程序。你可以根据你的需求和平台选择适合的版本,并按照相关教程进行安装和配置。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [Install Visual Studio 6.0 on Windows 10](https://blog.csdn.net/newtelcom/article/details/78509033)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* [Visual Studio 2022 - Qt 6.0.0+ 使用前准备 环境配置](https://blog.csdn.net/iosWorker/article/details/122950400)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值