Code::Blocks + GLUT + FLTK

Code::Blocks provides project templates for both GLUT and FLTK, but no for GLUT + FLTK. Here is a procedure to build a simple GLUT + FLTK program in Code::Blocks.


1.  Build up a new project for GLUT by using the Code::Blocks' template.
2.  Add search directories setting to the include and library directories of FLTK.
3.  Modify #include <GL/glut.h> in main.cpp to #include<FL/glut.H>
4.  Modify the Linker settings as follows
   1)  Add other linker options:  -mwindows
   2)  Link libraries as: fltk_images, fltk_gl, fltk, fltk_png, fltk_z, fltk_jpeg, glu32, opengl32, ole32, uuid, comctl32. Pay attention to that the sequential order of those libraries is important.


The project would be rebuilt successfully. You can then add FLTK functions as you like.

How to install GLUT for mingw

There are some binary distribution of glut in windows available, such as here. But it is not sure if they are available for your system, the version of your gcc compiler on your mingw32 or mingw64 etc. On the other hand, it is not easy to compile its sourcecode in mingw. However, freeglut provides cmake support for cross platform compiling. It is therefore suggested that freeglut, which provides binary distribution also, be adopted.


1. Compile freeglut by using cmake.


2. Keeping the include, library  and dll file of freeglut available and compile like:
    g++ -Os -Wall test.cc -o test -mwindows -lfreeglut -lopengl32 -lglu32


That's all.

VS Code下cmake, c++编译,调试环境的构成步骤

1   下载必须extension      按[Ctrl+Shift+X]打开extension窗口,选择安装"C/C++", "CMake", "CMake Tools" 2   在VSCode下打开作业目录 ...