Configurations | Running a C++ FLTK Program on Windows 11 Using Premake 5
2 min readApr 14, 2024
The Fast Light Tool Kit (“FLTK”) is a cross-platform C++ GUI toolkit for different operation systems.
Step 0: Download The FILT Library And Compile It
In the official link, download the latest library source code.
In the directory ide/VisualC2010/
, open up the fltk.sln
file, and compile it. Build the solution both in the debug and release mode. It will generate static libraries.
Step 1: Create a project using premake 5
Use the lua file below to generate the project.
workspace "FltkDemo"
configurations { "Debug", "Release", "Dist" }
platforms "x86"
architecture "x86"
startproject "Sandbox"
location "project-files"
configurations
{
"Debug",
"Release",
"Dist",
}
filter "configurations:Debug"
defines { "DEBUG" }
runtime "Debug"
symbols "on"
filter "configurations:Release or Dist"
defines { "NDEBUG" }
runtime "Release"
optimize "on"
symbols "off"
outputdir = "%{cfg.buildcfg}-%{cfg.system}-%{cfg.architecture}"
project "Sandbox"
location "Sandbox"
kind "ConsoleApp"
language "C++"
cppdialect "C++latest"
staticruntime "off"
targetdir ("bin/%{outputdir}/%{prj.name}")
objdir ("bin-int/%{outputdir}/%{prj.name}")
files
{
"%{prj.name}/src/**.h",
"%{prj.name}/src/**.cpp",
}
includedirs
{
"./vendor/fltk-release-1.3.9/",
}
libdirs {
"./vendor/fltk-release-1.3.9/lib/"
}
filter "configurations:Debug"
links
{
"fltkd.lib",
"fltkformsd.lib",
"fltkgld.lib",
"fltkimagesd.lib",
"fltkjpegd.lib",
"fltkpngd.lib",
"fltkzlibd.lib",
}
filter "configurations:Release or Dist"
links
{
"fltk.lib",
"fltkforms.lib",
"fltkgl.lib",
"fltkimages.lib",
"fltkjpeg.lib",
"fltkpng.lib",
"fltkzlib.lib",
}
Step2: Write an Application
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Box.H>
int main(int argc, char** argv) {
Fl_Window* window = new Fl_Window(340, 180);
Fl_Box* box = new Fl_Box(20, 40, 300, 100, "Hello, World!");
box->box(FL_UP_BOX);
box->labelfont(FL_BOLD + FL_ITALIC);
box->labelsize(36);
box->labeltype(FL_SHADOW_LABEL);
window->end();
window->show(argc, argv);
return Fl::run();
}
This code will create a new window application.
The code sample is on this link.
That’s all. If you found this article helpful, please show your support by clicking the clap icon 👏 and following me 🙏.