fltk-1.4 with cmake on windows

571 views
Skip to first unread message

Daniele Lugli

unread,
Nov 28, 2016, 6:59:11 AM11/28/16
to fltk.general
Hello all,

I am starting a new project which needs a GUI and fltk looks the right choice.

Working on Windows 10, Visual Studio Community 2013. Need 64 bit release with /MT.

Downloaded fresh fltk-1.4.x-r12122 and CMake 1.7. (Not an expert of cmake).

Run cmake-gui.
Path to source: where-installed\fltk-1.4-x-r12122\src
Path to build: where-installed\fltk-1.4-x-r12122\build
Click Configure
Generator: Visual Studio 12 2013 Win64 (seems the closest),
Use default native compilers

--> Error in configuration process, project files may be invalid
CMake Error at CMakeLists.txt:482 (FL_ADD_LIBRARY):
Unknown CMake command "FL_ADD_LIBRARY".

(Plus warning:
CMake Warning (dev) in CMakeLists.txt:
No cmake_minimum_required command is present.)

Am I doing something wrong? Any suggestion?

Thank you in advance

Daniele Lugli

Albrecht Schlosser

unread,
Nov 28, 2016, 7:18:16 AM11/28/16
to fltkg...@googlegroups.com
On 28.11.2016 12:38 Daniele Lugli wrote:

> I am starting a new project which needs a GUI and fltk looks the right
> choice.

Welcome to the FLTK community!

> Working on Windows 10, Visual Studio Community 2013. Need 64 bit release
> with /MT.
>
> Downloaded fresh fltk-1.4.x-r12122 and CMake 1.7. (Not an expert of cmake).

FLTK 1.4 is in an early stage of development and maybe not yet as stable
as you may need. I suggest to download the stable FLTK 1.3.4-1 version
for your first tries.

> Run cmake-gui.
> Path to source: where-installed\fltk-1.4-x-r12122\src

That should read:

Path to source: where-installed\fltk-1.4-x-r12122

(remove '\src').

> Path to build: where-installed\fltk-1.4-x-r12122\build

Good. With CMake you can choose a build directory entirely outside the
source tree or an extra build directory _in_ the source tree as you did.
The build directory chosen by you is a ususal choice.

> Click Configure
> Generator: Visual Studio 12 2013 Win64 (seems the closest),

Personally I don't have any experience with Visual Studio 2013
Community, but Visual Studio 2015 Community is also available freely and
known to work. Anyway, your choice should be okay.

> Use default native compilers

Okay.

> --> Error in configuration process, project files may be invalid
> CMake Error at CMakeLists.txt:482 (FL_ADD_LIBRARY):
> Unknown CMake command "FL_ADD_LIBRARY".
>
> (Plus warning:
> CMake Warning (dev) in CMakeLists.txt:
> No cmake_minimum_required command is present.)

All these errors and warnings result from the wrong source directory.

> Am I doing something wrong? Any suggestion?

See above.

Notes: FLTK 1.3.4 works well with CMake although CMake support is not
yet complete. I recommend to use this version for new users.

FLTK 1.4.x is the new development version and may not be as stable as
1.3.4 in the near future. CMake support will be improved in this
version, but for your attempted usage 1.3.4 should be okay.

FLTK 1.4.x will be API compatible with 1.3.4 [1] so you can even try
both and switch forwards and backwards as you need. Currently FLTK 1.4.0
is on the same level as 1.3.4, so there should be no differences (except
stable vs. development versions).

Regards
Albrecht


[1] as usual this means that new features may be added in 1.4, but in
some special cases we may also have to change the API slightly, although
we strive to keeping it backwards compatible.

Daniele Lugli

unread,
Nov 28, 2016, 12:11:58 PM11/28/16
to fltk.general, Albrech...@online.de
Hi Albrecht,

thank you for your exceptionally prompt reply! It is really a good first impact with the fltk community!

Of course I will trust your suggestion and go with fltk-1.3.4, but first I would like to try and complete the build of 1.4
I am reluctant to switch to VS Community 2015 as I already have some code working well with 2013 and a new version of the compiler/IDE can be a jump in the dark, but of course I will switch if I find that 2013 gives problems with fltk.

So I changed "Where is the source code" to the _parent_ of the src directory (not really intuitive :) but I understand this is a cmake-related, not fltk-related detail).

Configure now completes, but complains missing HAVE_GL_GL_H, HAVE_GL_GLU_H, HAVE_LOCALE_H and suggests to re-run cmake-gui from a Visual Studio developer.
Done so, it finds the three headers somewhere in the guts of the system, OK.

Changed all /MD flags to /MT in the CMAKE group.
Changed CMAKE_INSTALL_PREFIX from C:/Program Files/FLTK to C:/Program Files/FLTK-1.4 (anticipating the parallel installation of the 1.3 version too).
Click Generate.
Opened the solution in VS, changed Debug to Release, ALL_BUILD
Some warnings, eg conversion from double to float or from float to int, deprecated strdup and similar -- no error though.

Tried a handful of exe from build\bin\examples\Release, all working -- and impressive.

Found nothing under C:/Program Files/FLTK-1.4. I see that INSTALL has not been built (maybe it is not included in ALL_BUILD?)
Try to build INSTALL separately -- cannot create the directory.
Relaunch VS as administrator and retry -- OK.
Wonderful !

By the way, is it really necessary to install FLTK or could I also keep it in my private tree? In this way I could carry it with my stuff: sometimes I work on different machines and it would be nice not to have to reinstall it every time.

---

Now I am going to do the same with 1.3 as suggested.

Even if I find no problem, I would like to document the steps here, if it does not clutter too much. It could be useful for somebody else, or a good reminder for myself.

Thank you again!

Daniele Lugli

Michael Surette

unread,
Nov 28, 2016, 12:42:14 PM11/28/16
to fltkg...@googlegroups.com
On Mon, Nov 28, 2016 at 11:32 AM, Daniele Lugli wrote:

>
> By the way, is it really necessary to install FLTK or could I also keep it
> in my private tree? In this way I could carry it with my stuff: sometimes I
> work on different machines and it would be nice not to have to reinstall it
> every time.

You can indeed use the libraries from their build folder. Check out
README.CMake.txt in your download which explains how to do this with
really good CMake support.

--
Mike

Albrecht Schlosser

unread,
Nov 28, 2016, 12:49:28 PM11/28/16
to fltk.general
On 28.11.2016 at 17:32 Daniele Lugli wrote:
> Hi Albrecht,
>
> thank you for your exceptionally prompt reply! It is really a good first
> impact with the fltk community!

Welcome. We're not always that fast, but we try to help as good as we can.

> Of course I will trust your suggestion and go with fltk-1.3.4, but first
> I would like to try and complete the build of 1.4
> I am reluctant to switch to VS Community 2015 as I already have some
> code working well with 2013 and a new version of the compiler/IDE can be
> a jump in the dark, but of course I will switch if I find that 2013
> gives problems with fltk.

That's all fine. And it's always good to have two versions to test. I
only wrote about VS 2015 for completeness, because I use it for testing
and I know it works. I do also have VS 2008 and VS 2010 on another PC,
and they all work. It's good to read that VS 2013 Community works as
well, thanks for your feedback.

> So I changed "Where is the source code" to the _parent_ of the src
> directory (not really intuitive :) but I understand this is a
> cmake-related, not fltk-related detail).

The src/ directory is only one of potentially many more source
subdirectories in the FLTK source folder. There is also fluid, test, and
there are image and zip library folders. From CMake's point of view the
"source code directory" should always be the top level directory unless
you read anything else in the build instructions. CMake looks for the
file CMakeLists.txt, and it _should_ find the top-level one, not one in
the subdirectories (note: there is and must be one in the src/ directory
as well). CMakeLists.txt is for CMake what Makefiles are for
conventional configure/make build systems.

> Configure now completes, but complains missing HAVE_GL_GL_H,
> HAVE_GL_GLU_H, HAVE_LOCALE_H and suggests to re-run cmake-gui from a
> Visual Studio developer.
> Done so, it finds the three headers somewhere in the guts of the system, OK.

This is a known (CMake) issue, and the warning is generated by FLTK's
CMake script intentionally. However it would likely also work if you
just opened the solution and started to build...

> Changed all /MD flags to /MT in the CMAKE group.

There should be a better way to do this, but I can't help directly
because I don't use VS for my development. You could try to set /MT in
OPTION_OPTIM, but I don't know if this would work. See below for more...

> Changed CMAKE_INSTALL_PREFIX from C:/Program Files/FLTK to C:/Program
> Files/FLTK-1.4 (anticipating the parallel installation of the 1.3
> version too).
> Click Generate.
> Opened the solution in VS, changed Debug to Release, ALL_BUILD
> Some warnings, eg conversion from double to float or from float to int,
> deprecated strdup and similar -- no error though.

Perfect. There are options to suppress these warnings, and I know that
you can set _these_ options in OPTION_OPTIM because I did this to see
*real* warnings and errors. You may try to set these options in CMake's
OPTION_OPTIM:

/wd4244 /wd4267 /wd4305 /wd4996 /wd4312 /wd4334 /wd4838

Fixing (some/most of) these warnings is on my to-do-list for FLTK 1.4.
There's also an STR with a patch, so this is likely to happen soon...

> Tried a handful of exe from build\bin\examples\Release, all working --
> and impressive.

Great!

> Found nothing under C:/Program Files/FLTK-1.4. I see that INSTALL has
> not been built (maybe it is not included in ALL_BUILD?)

Yes, it is intentionally not included. If you want to install then only
after you tested a new version and you really want to do it, so it's a
separate build step.

> Try to build INSTALL separately -- cannot create the directory.
> Relaunch VS as administrator and retry -- OK.
> Wonderful !

:-)

> By the way, is it really necessary to install FLTK or could I also keep
> it in my private tree? In this way I could carry it with my stuff:
> sometimes I work on different machines and it would be nice not to have
> to reinstall it every time.

You don't need to "install" it, particularly not in a system folder
where you need admin privileges. The interesting point comes when you
build your own applications that use the FLTK library. You can use the
FLTK library and include files directly from the FLTK build directory,
and that's what the FLTK team usually recommends. There are two points
though that make an installation step "interesting" (helpful):

Point 1: the build directory layout WRT header and library files can
differ from a real install directory, so the setup of your own projects
may have to be different as well.

Point 2: There are at least two files created in CMake's build
directory, i.e. in a subdirectory of your build/ folder:

config.h and FL/abi-version.h .

config.h should only be visible to the FLTK library build and will not
be installed in your install directory. FL/abi-version.h however must be
seen by the compiler when you compile your project. You must set your
"additional include directories" (or similar) in your own project to:

(1) /path/to/fltk
(2) /path/to/fltk/build

if you *don't* install FLTK (and, BTW, you can accidentally include
config.h in your application if you do so).

OTOH, if you "install" FLTK in one of your personal directories, say
/path/to/my/projects/fltk-1.3 then you need only one additional include
directory:

(1) /path/to/my/projects/fltk-1.3

The file FL/abi-version.h will be installed in the correct place, and
config.h won't be accessible to your own project's build process.

So I think it is better to do this additional installation step if you
use Visual Studio and it has the additional advantage that you can do it
after testing a new FLTK snapshot or release w/o disturbing your
previously installed version while still testing. YMMV.

See also Michael Surette's post. What he says is that you can easily use
FLTK from the build directory if you setup your own build with CMake as
well which I't generally recommend. But this can be different if you use
your own Visual Studio projects generated manually, and I assume that's
what you have.

> Now I am going to do the same with 1.3 as suggested.

Good luck, and have fun!

> Even if I find no problem, I would like to document the steps here, if
> it does not clutter too much. It could be useful for somebody else, or a
> good reminder for myself.

Feel free to do that. Note that we also have our "articles". If you
think that you can help others an article would be a good choice.
Articles can be updated when you see that your instructions are outdated
or need some polishing, whereas mailing list contents can't be changed.

PS: Please don't top-post here. For better reading you should trim the
message you're replying to and interleave citations and your new text.
Thanks.

Ian MacArthur

unread,
Nov 28, 2016, 1:30:55 PM11/28/16
to fltkg...@googlegroups.com

> On 28 Nov 2016, at 16:32, Daniele Lugli wrote:
>
> By the way, is it really necessary to install FLTK or could I also keep it in my private tree? In this way I could carry it with my stuff: sometimes I work on different machines and it would be nice not to have to reinstall it every time.


As others have noted, it is not necessary to install fltk; it can be used fine from its build tree, making it easy to have multiple versions of fltk in play, if that is needed.
(I seldom “install" fltk, but I have many instances of it on this machine...)


> Now I am going to do the same with 1.3 as suggested.


If you are building 1.3.4 from source under VS, then the built in IDE project might be your easiest option, unless you are keen to use cmake for your build.

The fltk.../ide/VisualC2010 project has worked fine for me on a variety of different VS versions, from VS2010 up to the community VS2015 edition.



Daniele Lugli

unread,
Nov 28, 2016, 1:56:15 PM11/28/16
to fltk.general

Thank you Mike, but I cannot use cmake for my project, so I think I am going to follow the suggestion of Albrecht.

Daniele

Daniele Lugli

unread,
Nov 28, 2016, 2:08:33 PM11/28/16
to fltk.general, Albrech...@online.de


Il giorno lunedì 28 novembre 2016 18:49:28 UTC+1, Albrecht Schlosser ha scritto:

> Changed all /MD flags to /MT in the CMAKE group.

There should be a better way to do this, but I can't help directly
because I don't use VS for my development. You could try to set /MT in
OPTION_OPTIM, but I don't know if this would work. See below for more...

No problem, there aren't so many...
 

> Some warnings, eg conversion from double to float or from float to int,
> deprecated strdup and similar -- no error though.

Perfect. There are options to suppress these warnings, and I know that
you can set _these_ options in OPTION_OPTIM because I did this to see
*real* warnings and errors. You may try to set these options in CMake's
OPTION_OPTIM:

   /wd4244 /wd4267 /wd4305 /wd4996 /wd4312 /wd4334 /wd4838

I'll keep them in mind for the next build.

OK, I did so; I installed fltk-1.3 in my private tree.


See also Michael Surette's post. What he says is that you can easily use
FLTK from the build directory if you setup your own build with CMake as
well which I't generally recommend. But this can be different if you use
your own Visual Studio projects generated manually, and I assume that's
what you have.

Correct.
 

> Now I am going to do the same with 1.3 as suggested.

Good luck, and have fun!

> Even if I find no problem, I would like to document the steps here, if
> it does not clutter too much. It could be useful for somebody else, or a
> good reminder for myself.

Feel free to do that.

Thank you. Here are the steps I followed:
- Downloaded fltk-1.3.4-1-source.tar.gz
- Run cmake-gui from a developer command prompt
- Where is the source code: path\to\it\fltk-1.3.4-1
- Where to build the binaries: path\to\it\fltk-1.3.4-1\build (new directory)
- Configure
- Visual Studio 12 2013 Win64, Use default native compilers
- HAVE_GL_GL_H, HAVE_GL_GLU_H,HAVE_LOCALE_H are OK
- CMAKE group: /MD --> /MT
- CMAKE group: CMAKE_INSTALL_PREFIX: changed to some my local place
- Generate
- Open project
- Debug --> Release
- Right click ALL_BUILD: Build
- Same conversion warning as for fltk-1.4 (previous post)
- tried some exe from fltk-1.3.4-1/build/bin/examples/Release, most OK but:
- demo.exe complains missing demo.menu: copied fltk-1.3.4-1/build/bin/examples/demo.menu to fltk-1.3.4-1/build/bin/examples/Release, OK
- help.exe complains missing help-test.html: copied fltk-1.3.4-1/build/bin/examples/help-test.html to fltk-1.3.4-1/build/bin/examples/Release, OK
- Right click on INSTALL: Build
 
Note that we also have our "articles". If you
think that you can help others an article would be a good choice.
Articles can be updated when you see that your instructions are outdated
or need some polishing, whereas mailing list contents can't be changed.

I'll have a look at the articles and hope to be able to contribute soon.

PS: Please don't top-post here. For better reading you should trim the
message you're replying to and interleave citations and your new text.

Sorry for that.


Daniele

Daniele Lugli

unread,
Nov 28, 2016, 2:10:35 PM11/28/16
to fltk.general

This is in fact the first thing I tried some days ago, but I found myself stuck when changing the platform from win32 to x64

Thank you

Daniele

imaca...@gmail.com

unread,
Nov 28, 2016, 3:44:58 PM11/28/16
to general fltk

 

This is in fact the first thing I tried some days ago, but I found myself stuck when changing the platform from win32 to x64

 

 

 

 

Hmm, I’m no expert on VS (I don’t really like any IDE to be honest) but I think it is something like this:

 

With the project open in VS, right click on the solution, then select “Configuration” in the dialog, then select “Configuration Manager” and in the dialog, select the “Active Solution” drop down, then do New -> x64 to create a x64 based clone of the project.

 

Then set that x64 project as your Active Solution, and proceed with the build as normal.

 

Well... something like that.

 

I have No Idea why it has to be so complicated; which is probably why I do not like IDE’s, since their idea of making things simpler is not the same as mine!

 

 

Daniele Lugli

unread,
Nov 28, 2016, 3:58:57 PM11/28/16
to fltk.general


Il giorno lunedì 28 novembre 2016 21:44:58 UTC+1, Ian MacArthur ha scritto:

 

Hmm, I’m no expert on VS (I don’t really like any IDE to be honest) but I think it is something like this:

 

With the project open in VS, right click on the solution, then select “Configuration” in the dialog, then select “Configuration Manager” and in the dialog, select the “Active Solution” drop down, then do New -> x64 to create a x64 based clone of the project.

 

Then set that x64 project as your Active Solution, and proceed with the build as normal.

 

Well... something like that.

 

I have No Idea why it has to be so complicated; which is probably why I do not like IDE’s, since their idea of making things simpler is not the same as mine!

 

What you listed is exactly what I did, but to no success. Changing the architecture from win32 to x64, don't know why, looses many settings, which should be reset by hand -- in something like 80 projects. So I gave up.

Daniele

 

Reply all
Reply to author
Forward
0 new messages