Using FLTK on Win64

213 views
Skip to first unread message

Alexander Ivanenko

unread,
Jan 6, 2017, 1:51:00 PM1/6/17
to fltk.general
Hello All,

I compiled FLTK for Win64 using VisualStudio 2015.
However, while compiling simple text editor example it gives the error:
fatal error C1083: Cannot open include file: 'X11/X.h': No such file or directory

It seems that FLTK headers expect WIN32 to be defined even in 64-bit system?

Best Regards,
Alexander Ivanenko




Greg Ercolano

unread,
Jan 6, 2017, 1:55:26 PM1/6/17
to fltkg...@googlegroups.com
On 01/06/17 10:38, Alexander Ivanenko wrote:
> Hello All,
>
> I compiled FLTK for Win64 using VisualStudio 2015.
> However, while compiling simple text editor example it gives the error:
>
> fatal error C1083: Cannot open include file: 'X11/X.h': No such file or directory
>
>
> It seems that FLTK headers expect WIN32 to be defined even in 64-bit system?

Hmm, are you building with defaults?
Are you unsetting it for some reason?

I believe it's supposed to be set, whether x32 or x64:
https://msdn.microsoft.com/en-us/library/b0084kay.aspx

"""
_WIN32 Defined as 1 when the compilation target is 32-bit ARM,
64-bit ARM, x86, or x64. Otherwise, undefined.

_WIN64 Defined as 1 when the compilation target is 64-bit ARM
or x64. Otherwise, undefined.
"""


Martin McDonough

unread,
Jan 6, 2017, 9:47:51 PM1/6/17
to fltk.general
How did you build fltk? Did you use cmake to create a MSVC project, or one of the existing projects in the ide directory?

Alexander Ivanenko

unread,
Jan 7, 2017, 6:15:00 AM1/7/17
to fltk.general
I used the existing projects for VS 2010(I added x64 configuration there).
However, Greg could be right - WIN32 should be defined even for x64. The thing is that I added FLTK example code to one of my older projects and it could be that WIN32 definition was manually removed from the building configuration there.

суббота, 7 января 2017 г., 5:47:51 UTC+3 пользователь Martin McDonough написал:

Ian MacArthur

unread,
Jan 7, 2017, 6:51:08 AM1/7/17
to fltkg...@googlegroups.com

> On 7 Jan 2017, at 05:26, Alexander Ivanenko wrote:
>
> I used the existing projects for VS 2010(I added x64 configuration there).
> However, Greg could be right - WIN32 should be defined even for x64. The thing is that I added FLTK example code to one of my older projects and it could be that WIN32 definition was manually removed from the building configuration there.


Note, as Greg pointed out, that “WIN32” is something of a misnomer these days, in that the “32” bit doesn’t mean that it only applies to 32-bit systems. The “WIN64” setting is like an extension to that, but in effect *both* are needed, not one or the other.

Though, I don’t think fltk uses WIN64 at all - all the API’s we use are portable, so in fact fltk probably only needs WIN32 set, on either 32 or 64-bit Windows hosts.

It might be worth noting that the executable format that MS use on their 64-bit systems is similarly confusingly named.
32-bit Windows executables are typed as “PE32”, whereas 64-bit Windows executables are typed as “PE32+” (i.e. 32-bit with extensions, I suppose, rather than PE64, say.)
I have no idea why they chose to go that way, but it always struck me as odd.
Likely something to do with backwards compatibility at a guess, but who knows?


On a more pertinent note; older MS compilers used to define WIN32 as well as _WIN32 and so forth, and fltk *depends* on finding WIN32 set. However, more recent MS compiler no longer set WIN32, whilst they do still set _WIN32.
The fltk build files dodge that issue by ensuring that WIN32 is also set, but other projects that depend only on the compiler setting the definitions might be caught out.

That is, code that used to work with an older MS compiler, and where WIN32 was set, may now appear broken because the compiler has stopped setting WIN32 and now just sets _WIN32 instead.

Summary: make sure WIN32 is set in your build config, and all should be well!




Alexander Ivanenko

unread,
Jan 7, 2017, 9:33:25 AM1/7/17
to fltk.general
Thank you, Ian. I added #define WIN32 prior to FLTK includes and it worked.

суббота, 7 января 2017 г., 14:51:08 UTC+3 пользователь Ian MacArthur написал:
Reply all
Reply to author
Forward
0 new messages