fltk 1.3.4-2 compile error on windows 7

629 views
Skip to first unread message

imranm...@gmail.com

unread,
Feb 6, 2018, 8:13:38 PM2/6/18
to fltk.general
Hi,
I'm a bit new to C++ GUI and C++ in general, and am trying to build fltk1.3.4-2 on windows 7. I'm using the instructions here (http://www.fltk.org/articles.php?L598+I140+T+P1+Q) because they are the latest ones I could find online. 
I've downloaded the latest mingw32 and msys as recommended (gcc/g++ ver 6.3.0, binutils, and win32api packages), and run configure (no flags), but my make fails on compiling Fl_win32 complaining that "S_OK" was not declared in the file's scope. Am I doing something wrong? Do I need to add extra flags for the configure script? Have I made a mistake in setting up my mingw32 and msys?

Also, I went through the configure log and I see quite a number of errors - though I assume many of these are part of the config process, eg checking the availability of files/functions? What should I look for to see if something is broken in the configure flow?

Thanks

Albrecht Schlosser

unread,
Feb 6, 2018, 8:32:03 PM2/6/18
to fltkg...@googlegroups.com
On 07.02.2018 00:43 imranmoezkhan wrote:
> Hi,
> I'm a bit new to C++ GUI and C++ in general, and am trying to build
> fltk1.3.4-2 on windows 7.

Welcome to the FLTK community. 1.3.4-2 is currently the best choice.

> I'm using the instructions here
> (http://www.fltk.org/articles.php?L598+I140+T+P1+Q) because they are the
> latest ones I could find online.

These instructions are outdated WRT installation of MinGW. I recommend
to remove (or rename) the entire MinGW installation, then go back to the
MinGW site www.mingw.org and click on the "download/installer" link on
the left hand side:
http://mingw.org/download/installer

There are also some helpful docs like "Getting Started" etc.

This should get you going. You may need to select the (C and C++)
compilers and maybe some more options.

Note that you really should use the default installation path (C:\MinGW
?) or at least one w/o spaces in the path name. This is important!

> I've downloaded the latest mingw32 and msys as recommended (gcc/g++ ver
> 6.3.0, binutils, and win32api packages), and run configure (no flags),
> but my make fails on compiling Fl_win32 complaining that "S_OK" was not
> declared in the file's scope. Am I doing something wrong? Do I need to
> add extra flags for the configure script? Have I made a mistake in
> setting up my mingw32 and msys?

It's likely the MinGW setup (see above).

Once you downloaded and unpacked the FLTK tarball you can directly run
'make'. This will run ./configure with default values and initialize
some files. After that you can run ./configure with any arguments, but
the default values are best for a start. FLTK will usually build w/o errors.

> Also, I went through the configure log and I see quite a number of
> errors - though I assume many of these are part of the config process,
> eg checking the availability of files/functions? What should I look for
> to see if something is broken in the configure flow?

Hard to say. If it doesn't work you can post error messages here (please
cut'n'paste exact messages or append a log file).

imranm...@gmail.com

unread,
Feb 8, 2018, 6:58:32 AM2/8/18
to fltk.general
Hi Albrecht,
Thanks for your reply. Is there a link to updated build instructions for fltk? The MSWindows readme in the fltk directory has quite similar instructions - which I've tried to follow exactly.
I did another clean install of MinGW to the recommended path (C:\MinGW ...I've done a lot of scripting work on unix, so I know how touchy it is about spaces in paths :-), and installed MSys in a sub-directory of MinGW as the mingw graphical installer does (is this the recommended way?). I think gcc and g++ are working correctly, because compiling for the source jpeg, zlib, png files proceeds without any problem. Its just when fltk source starts, that I get the following error:

Compiling pngerror.c...
Compiling pngpread.c...
Archiving ../lib/libfltk_png.a...
=== making src ===
Compiling Fl.cxx...
In file included from Fl.cxx:1909:0:
Fl_win32.cxx: In function 'RECT border_width_title_bar_height(Fl_Window*, int&,
int&, int&, float*)':
Fl_win32.cxx:2712:97: error: 'S_OK' was not declared in this scope
       if ( DwmGetWindowAttribute(fl_xid(win), DWMWA_EXTENDED_FRAME_BOUNDS, &r,
sizeof(RECT)) == S_OK ) {

                 ^~~~
make[1]: *** [Fl.o] Error 1
make: *** [all] Error 1


I have already installed the win32api package for mingw and msys as well - I see the relevant headers in C:\MinGW\include and C:\MinGW\msys\1.0\include\w32api

Can't quite figure out what is going wrong - any ideas?

Thanks

Albrecht Schlosser

unread,
Feb 8, 2018, 10:41:07 AM2/8/18
to fltkg...@googlegroups.com
On 08.02.2018 05:46 imranmoezkhan wrote:
> Hi Albrecht,
> Thanks for your reply. Is there a link to updated build instructions for
> fltk? The MSWindows readme in the fltk directory has quite similar
> instructions - which I've tried to follow exactly.

I don't think that we currently have better instructions. I started new
installation instructions some time ago but I was distracted. I'll see
if I find this and update the documentation.

The new graphical MinGW installer is much easier to use but you still
need to select the correct packages.

> I did another clean install of MinGW to the recommended path (C:\MinGW
> ...I've done a lot of scripting work on unix, so I know how touchy it is
> about spaces in paths :-), and installed MSys in a sub-directory of
> MinGW as the mingw graphical installer does (is this the recommended
> way?). I think gcc and g++ are working correctly, because compiling for
> the source jpeg, zlib, png files proceeds without any problem. Its just
> when fltk source starts, that I get the following error:
>
> Compiling pngerror.c...
> Compiling pngpread.c...
> Archiving ../lib/libfltk_png.a...
> === making src ===
> Compiling Fl.cxx...
> In file included from Fl.cxx:1909:0:
> Fl_win32.cxx: In function 'RECT
> border_width_title_bar_height(Fl_Window*, int&,
> int&, int&, float*)':
> Fl_win32.cxx:2712:97: error: 'S_OK' was not declared in this scope
>        if ( DwmGetWindowAttribute(fl_xid(win),
> DWMWA_EXTENDED_FRAME_BOUNDS, &r,
> sizeof(RECT)) == S_OK ) {
>
>                  ^~~~
> make[1]: *** [Fl.o] Error 1
> make: *** [all] Error 1

This error is really unexpected, but I have good news:

I installed a new MinGW version from scratch (mine is somewhat older)
and tried the new installation. With FLTK 1.4 I couldn't see the same
error but I got a related linker error. The I tried FLTK 1.3.4 svn and I
can confirm the error you see. I'm working on a patch.

There are two issues in the current MinGW version:

(1) S_OK is not defined as it was before. A quick workaround is:

#include <winerror.h>

somewhere at the top of src/Fl_win32.cxx. However, this doesn't get you
to a successful build because of issue #2.

(2) There is a (IMHO buggy) inline implementation of a winsock related
function in the latest version of MinGW's winsock.h. This inline
implementation requires us (FLTK) to link explicitly with the winsock
dll (ws2_32) which we tried to avoid by dynamic loading of the library
to reduce dependencies.

Here is my preliminary comment in one of our CMake files:

# The current MinGW version (as of Feb 2018) uses (in winsock.h) an *inline*
# implementation of a winsock library function (__FD_ISSET) that depends on
# __WSAFDIsSet (which is in ws2_32.dll). Hence we need to link with winsock2
# (ws2_32.lib) explicitly although we load all winsock functions we use
# dynamically to avoid to have to link to winsock2. Otherwise we
# get a linker error when linking fluid and/or our test programs.
# Unfortunately user programs may be affected as well.
# Note: This is a bug in the latest MinGW implementation. :-(
# AlbrechtS - Feb 08, 2018

> I have already installed the win32api package for mingw and msys as well
> - I see the relevant headers in C:\MinGW\include and
> C:\MinGW\msys\1.0\include\w32api
>
> Can't quite figure out what is going wrong - any ideas?

Looks as if you didn't make a mistake, it's an issue introduced by the
latest MinGW implementation.

BTW: The same issue (at least #2 above) applies to FLTK 1.4.0 as well.

I'll post a patch ASAP once I did some more tests.

@Ian and other devs and users: take care (make a backup) before updating
your MinGW installation. See my analysis above. There may be other
issues I didn't find yet.

Albrecht Schlosser

unread,
Feb 8, 2018, 12:48:05 PM2/8/18
to fltkg...@googlegroups.com
On 08.02.2018 16:41 Albrecht Schlosser wrote:
> On 08.02.2018 05:46 imranmoezkhan wrote:
>
> This error is really unexpected, ...
>
>> Can't quite figure out what is going wrong - any ideas?
>
> Looks as if you didn't make a mistake, it's an issue introduced by the
> latest MinGW implementation.
>
> BTW: The same issue (at least #2 above) applies to FLTK 1.4.0 as well.
>
> I'll post a patch ASAP once I did some more tests.

@imranmoezkhan: I posted a patch in another message of this thread. I
hope you know how to apply a patch. If not, please ask here.

For those using configure and make: You may need to create a new
'configure' file. This may require autoconf and can be done like so:

$ make distclean
$ autoconf -f
$ make

This should build the library w/o further errors. Hopefully...

A shortcut (w/o the patch) would be (for Windows with MinGW):

Use the one-line patch I suggested before: add

#include <winerror.h>

somewhere at the top of src/Fl_win32.cxx.

Then edit the generated file makeinclude in FLTK's root directory so it
reads:

LDLIBS = -lole32 -luuid -lcomctl32 -lws2_32
GLDLIBS = -lglu32 -lopengl32 -lole32 -luuid -lcomctl32 -lws2_32

i.e. add "-lws2_32" to the definitions of LDLIB and GLDLIB (~line
#96/97). This should fix the build, but the next "configure" execution
would overwrite this file again.

imranm...@gmail.com

unread,
Feb 14, 2018, 8:31:49 AM2/14/18
to fltk.general
Hi Albrecht,
Apologies for the late reply.
Adding winerror header and linking to lws2_32 lib solved the problem. I had a couple of internal compiler errors when I was building, but that's probably because of 32/64-bit issues with the mingw compiler (I'm running in compatibility). After a couple of attempts, I got the demo test working. 

Just an additional note (maybe useful to someone):
I'm using codeblocks as IDE on windows, so I switched the default cb mingw compiler to the one I used for building fltk (since it builds .a files and codeblocks default mingw for windows would only accept .lib). I added the compiler and linker flags generated by fltk-config, but the build failed. Error was something like: "Undefined reference to `__WSAFDIsSet " . So I had to add the "-lws2_32" flag you suggested for the makeinclude file fix - this worked and I got my helloworld window working. 
I guess fltk-config doesn't read the ldflag from the fltk makeinclude for the compiler/linker flags?

For the patches, I'm not sure how to apply these - should I just apply the git-diffs inside?

Thanks so much for helping me out with this!

Albrecht Schlosser

unread,
Feb 19, 2018, 7:05:15 AM2/19/18
to fltkg...@googlegroups.com
On 14.02.2018 02:43 imranmoezkhan wrote:

> Apologies for the late reply.

Same here, sorry for the late reply.

> Adding winerror header and linking to lws2_32 lib solved the problem. I
> had a couple of internal compiler errors when I was building, but that's
> probably because of 32/64-bit issues with the mingw compiler (I'm
> running in compatibility). After a couple of attempts, I got the demo
> test working.

You should always use the same compiler for building libs and
applications, particularly if you're using C++ (the C calling interface
is much more stable across compilers and doesn't use name mangling like
C++ does).

> Just an additional note (maybe useful to someone):
> I'm using codeblocks as IDE on windows, so I switched the default cb
> mingw compiler to the one I used for building fltk (since it builds .a
> files and codeblocks default mingw for windows would only accept .lib).
> I added the compiler and linker flags generated by fltk-config, but the
> build failed. Error was something like: "Undefined reference to
> `__WSAFDIsSet " . So I had to add the "-lws2_32" flag you suggested for
> the makeinclude file fix - this worked and I got my helloworld window
> working.

That is the better solution. I suggested to change makeinclude only as a
workaround.

> I guess fltk-config doesn't read the ldflag from the fltk makeinclude
> for the compiler/linker flags?

No, it doesn't. fltk-config and makeinclude are generated by configure,
so they are both output of the configure process. If you want to use
fltk-config you need to edit this file as well: append '-lws2_32' after
'-lcomctl32' where applicable.

> For the patches, I'm not sure how to apply these - should I just apply
> the git-diffs inside?

You would need a program called 'patch' to apply the patches. But since
you fixed the main issue by adding '-lws2_32' the only other 'patch'
would be to add '#include <winerror.h>' as you obviously did as well, so
you should be done with it.

Of course you can also apply the patches from the git-diffs. Lines
marked with '-' in the first column must be removed and lines marked
with '+' must be added. Other lines are only context info.

> Thanks so much for helping me out with this!

Welcome.

wong HC

unread,
Mar 19, 2018, 12:40:37 PM3/19/18
to fltk.general
Hi, after following the instruction, I get an error like this.

can you show me how can I solve this?
I am using MinGW 6.3 in windows to compile FLTK 1.3.4
Auto Generated Inline Image 1

Albrecht Schlosser

unread,
Mar 20, 2018, 1:50:06 PM3/20/18
to fltkg...@googlegroups.com
On 19.03.2018 17:38 wong HC wrote:
> Hi, after following the instruction, I get an error like this.
>
> can you show me how can I solve this?
> I am using MinGW 6.3 in windows to compile FLTK 1.3.4

I'm afraid I don't have a solution for your issue. The text in your
posted image says "... entry point ... could not be located in the
dynamic link library ...\fluid\fluid.exe".

This is strange since fluid.exe is an executable program and not a dll.
The given entry point is "mangled" and doesn't tell us which entry point
was not found.

In case of such strange error messages it's likely that your build mixes
two different build environments of an older and the current FLTK
version. Please make sure that you remove all old FLTK libraries you may
have built before, particularly if they were in default locations where
they can be found by the current build process.

Once you made sure that there are no other FLTK versions, please try to
compile FLTK with debug information. If you used configure in MinGW then
you should try "./configure --enable-debug" to configure, then run make
as you did before.

If this still shows errors, please post errors here, preferred with cut
and paste from the MinGW text console. Please leave enough context so we
can see where the build broke.

Please add your configure and build steps (command lines) so we can see
any errors and/or test ourselves.

zeichlicht

unread,
Feb 21, 2020, 8:12:29 AM2/21/20
to fltk.general
... just a thanks ...

... i came across the same " -lws2_32" problem as imaramm,  at about the same time as imararmm did ... a few years ago ...

... for one reason or another i am re-building old code on a new machine ... and of course came across this same problem ...   

... and the addition of the library works ...

... i forgot to say thanks a few years ago ... 

... your timely manner was much appreciated ...

mark

wong HC

unread,
Feb 21, 2020, 8:41:17 AM2/21/20
to fltk.general
Hi, am here to say thanks.
Reply all
Reply to author
Forward
0 new messages