Posted on

FLTK: Fast Light Toolkit

FLTK Version: 1.3.5

In terminal

brew install fltk

In CLion, take C++ 14 program as example, as in my project renju, the CMakeLists.txt file should be configured as:

cmake_minimum_required(VERSION 3.13)
project(renju)

set(CMAKE_CXX_STANDARD 14)

set(SOURCE_FILES main.cpp)

add_executable(${PROJECT_NAME} ${SOURCE_FILES})

set(FLTK_SKIP_FLUID true)
find_package(FLTK REQUIRED)
include_directories(${FLTK_INCLUDE_DIR})
target_link_libraries(${PROJECT_NAME} ${FLTK_BASE_LIBRARY} ${FLTK_PLATFORM_DEPENDENT_LIBS})

As you add more source files you should modify line 6 by appending the .cpp source files to be added to the SOURCE_FILES list.

Demonstration

After that, the demo code from the official website should work.

source code:

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

References

  1. https://git.ph.qmul.ac.uk/spa4321/2017/commit/d401cac26bf9650fe6f88cc2f47d4efc305afcdd
  2. https://www.fltk.org/doc-1.3/basics.html
  3. https://cmake.org/cmake/help/latest/command/add_library.html#normal-libraries
  4. https://www.jetbrains.com/help/clion/quick-cmake-tutorial.html
  5. https://cmake.org/cmake/help/latest/command/find_library.html
  6. https://www.fltk.org/doc-1.3/index.html

Leave a Reply

Your email address will not be published. Required fields are marked *