Visual Studio build error fix: legacy_stdio_definitions

68 views
Skip to first unread message

Robin Rowe

unread,
Mar 29, 2019, 2:56:05 AM3/29/19
to fltkg...@googlegroups.com
FLTK in git Windows build is broken. Won't compile on Windows 10 Visual
Studio without this addition to CMakeLists.txt:

project(FLTK)
cmake_minimum_required(VERSION 2.6.3)
link_libraries(legacy_stdio_definitions)

Without legacy_stdio_definitions, linker errors for "unresolved external
symbol __imp___snprintf".

Robin

Albrecht Schlosser

unread,
Mar 29, 2019, 4:54:33 AM3/29/19
to fltkg...@googlegroups.com
On 29.03.2019 07:55 Robin Rowe wrote:
> FLTK in git Windows build is broken.

Which branch? master?

> Won't compile on Windows 10 Visual Studio

Which version of Visual Studio?

> without this addition to CMakeLists.txt:
>
>     project(FLTK)
>     cmake_minimum_required(VERSION 2.6.3)
>     link_libraries(legacy_stdio_definitions)
>
> Without legacy_stdio_definitions, linker errors for "unresolved external
> symbol __imp___snprintf".

I just built the latest FLTK 1.4 (master) with Visual Studio 2017 and I
didn't see this error. I used all default options and built the 64-bit
version. Result:

Erstellen: 87 erfolgreich, 0 fehlerhaft, 0 aktuell, 2 übersprungen

... which translates to "Build: 87 successful, ..., 2 skipped"

I also built with shared libraries:

94 erfolgreich, 0 fehlerhaft, 2 übersprungen

Did you set any specific options?

Robin Rowe

unread,
Apr 3, 2019, 4:48:29 AM4/3/19
to fltkg...@googlegroups.com, Albrecht Schlosser
> Which branch? master?
> Which version of Visual Studio?

git clone https://github.com/fltk/fltk.git
cd fltk
mkdir build
cd build
cmake .. -A x64

Visual Studio Community 2017 15.9.5

Has issues building on Ubuntu too:

[ 49%] Building CXX object
src/CMakeFiles/fltk.dir/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx.o
/home/rower/code/fltk/src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx:29:10:
fatal error: windows.h: No such file or directory
#include <windows.h>
^~~~~~~~~~~
compilation terminated.
src/CMakeFiles/fltk.dir/build.make:3518: recipe for target
'src/CMakeFiles/fltk.dir/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx.o'
failed
make[2]: ***
[src/CMakeFiles/fltk.dir/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx.o]
Error 1
CMakeFiles/Makefile2:327: recipe for target
'src/CMakeFiles/fltk.dir/all' failed
make[1]: *** [src/CMakeFiles/fltk.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2

$ uname -a
Linux ubuntu 4.15.0-43-generic #46-Ubuntu SMP Thu Dec 6 14:45:28 UTC
2018 x86_64 x86_64 x86_64 GNU/Linux
$ g++ --version
g++ (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0

Solution?

Robin

Albrecht Schlosser

unread,
Apr 3, 2019, 5:37:10 AM4/3/19
to fltkg...@googlegroups.com
On 03.04.2019 10:48 Robin Rowe wrote:
> > Which branch? master?
> > Which version of Visual Studio?
>
>     git clone https://github.com/fltk/fltk.git
>     cd fltk
>     mkdir build
>     cd build
>     cmake .. -A x64
>
> Visual Studio Community 2017 15.9.5

I tried your commandline above with VS Community 2017 and it worked w/o
issues. Admittedly, 451 warnings may seem like an issue, but these are
mostly MS-specific and other benign warnings. The build with `cmake
--build` resulted in 0 (zero) errors.

There must be something wrong with your installation of VS or maybe with
your cmake version. Sorry, I'm afraid I can't help further.

> Has issues building on Ubuntu too:
>
> [ 49%] Building CXX object
> src/CMakeFiles/fltk.dir/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx.o
> /home/rower/code/fltk/src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx:29:10:
> fatal error: windows.h: No such file or directory
>  #include <windows.h>
>           ^~~~~~~~~~~
> compilation terminated.

This should never happen when building under Linux. What was your CMake
command line under Linux? Are you trying to cross-compile?

Note that `src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx' would only be
selected for compilation for Windows builds.

> $ uname -a
> Linux ubuntu 4.15.0-43-generic #46-Ubuntu SMP Thu Dec 6 14:45:28 UTC
> 2018 x86_64 x86_64 x86_64 GNU/Linux
> $ g++ --version
> g++ (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0
>
> Solution?

Try `cmake ..' w/o any other command line switches which should select
the Linux default generator 'Unix Makefiles', or select the generator
explicitly with `-G "Unix Makefiles"' or for instance `-G Ninja'. Both
options work well for me.


Reply all
Reply to author
Forward
0 new messages