On 06.12.2016 19:07 Ian wrote:
>
> On 06/12/2016 14:40:53, "Albrecht Schlosser" wrote:
>
>> Still investigating... Meanwhile I made a little more progress, but I
>> have a few questions:
>>
>> (1) Please post your gcc version. This is mine:
>>
>> $ gcc --version | head -n1
>> gcc.exe (x86_64-win32-seh, Built by MinGW-W64 project) 6.1.0
>>
> For mingw32 I have: gcc.exe (GCC) 5.3.0
>
> For mingw-64 I have: gcc.exe (x86_64-win32-seh, Built by MinGW-W64
> project) 6.1.0
>
> Which looks to be "the same" I think.
Yep, so do I. I had 'posix' threading installed before, but that didn't
work since I couldn't get rid of the pthreads dependency even if I
didn't use threads. Seems to be built into the compiler/runtime system.
See below.
>> The interesting part is the thread model (win32) and exception
>> handling (seh). Both options must be selected when installing
>> mingw-w64. Other options for thread model would be 'posix' and for
>> exception handling that would be 'sjlj'. I'm particularly interested
>> in the thread model, but I'm also interested in any insight in what
>> exception handling (seh or sjlj) we should recommend for end users
>> (although I'm aware that FLTK doesn't use exceptions). Any clues?
>
> I believe "seh" is the model that recent MS compilers use, so is what I
> selected.
> I think "sjlj" is "short jump, long jump" or some such thing, and is
> maybe the "older" way or something? Do not really know though!
That's what I seem to remember as well. AFAICT sjlj == setjmp, longjmp,
the way resolve exceptions.
>> (2) Please start a "Windows Explorer" Window and cd to your build/bin
>> and/or build/bin/examples folder(s), resp. Can you start the Windows
>> exe's by clicking on the resp. .exe files in the explorer window:
>>
>> (a) bin/fluid
>> (b) bin/examples/demo and others, particularly:
>> (c) bin/glpuzzle and
>> (d) bin/threads ?
>>
> Well, that was interesting.
>
> All work fine from the shell, in both mingw32 and mingw-64 builds,
> whether built via configure or cmake. (4 cases tested.)
Yep, that was to be expected.
> However, when double-clicking the exe from Explorer, they all work
> *except* for the cmake builds of the threads examples.
> These fail as follows:
>
> cmake/mingw32 threads fails - pthreadGC-3.dll missing
>
> cmake/mingw-64 - libwinpthread-1.dll missing
Same here.
> So both look to be trying to use win-pthreads rather than native Windows
> threads. The configure based builds are fine however.
Exactly, that's what I found out and was working on meanwhile. I fixed
the CMake build (WRT pthreads) in svn r12138. configure explicitly did
not check for pthreads under Windows except when Cygwin
(--enable-cygwin) is used. I did it similar in CMake now.
BTW (OT): I think that 'configure --enable-cygwin' is obsolete, i.e. it
should be the default for Cygwin builds (as well as --enable-x11). This
is the only combination that works with "real" Cygwin builds for some
time (several months, maybe years). The previous -mno-cygwin compiler
switch has been removed since gcc 4.0 and building native Windows
executables works with the MinGW cross compiler tools anyway. Hence
there's no need to have such an option. Either build a Cygwin program
(with cygwin1.dll and X11) or cross-compile a native (GDI) program. We
don't have a third option (Cygwin with GDI) for years now. But that's
another story.
>> (3) How did you configure your CMake build, which options did you
>> enter on the command line, which options did you change elsewhere
>> (cmake-gui)?
> I use the cli cmake -G "Msys Makefiles", then once that completes I use
> cmake-gui to update the config to add in -static-libstdc++
> -static-libgcc to the linker settings.
>
> It's not a very sophisticated approach, but so far it (mostly!) works.
Yep, that should do it. See below for a command line option w/o
cmake-gui. So far I couldn't find a difference between "Msys Makefiles"
and "Unix Makefiles".
My plans are to make the linker flags '-static-libstdc++ -static-libgcc'
the default for MinGW builds. We might add an option to switch them off,
but that would hopefully not be necessary. If we had this new default,
running CMake with all defaults should produce native (redistributable)
Windows programs, which is (AFAICT) what most users building with MinGW
would expect. Thoughts?
>> (4) Can you please run cmake with this command line and report if this
>> works for you?
>>
>> $ cmake -G"Unix Makefiles" -DCMAKE_EXE_LINKER_FLAGS='-static-libgcc
>> -static-libstdc++' -DCMAKE_BUILD_TYPE=Debug -DOPTION_USE_THREADS=OFF
>> <path/to/fltk>
> Will do - I'll report back later though, can't get to it right now.
Okay, that would still be interesting, but with the latest svn (r 12138)
'-DOPTION_USE_THREADS=OFF' should no longer be necessary. :-)
-DCMAKE_BUILD_TYPE=Debug is optional anyway, but adds some compiler
flags for debugging, so I recommend to use it.
>> This is my latest command line to build FLTK with mingw-w64 (gcc
>> 6.1.0) as shown above, after modifying the PATH in the same way you
>> described.
>>
>> FWI: echo $PATH
>> /c/mingw-w64_win32/bin:/usr/local/bin:/mingw/bin:/bin:/c/WINDOWS/system32
>>
>> I'm always trying to use the _minimal_ PATH I can find for development.
>>
>>
>> Side note: -DOPTION_USE_THREADS=OFF was used intentionally
>> (threads.exe still works with Windows Threads). If I don't use this
>> (OFF), then CMake obviously finds pthreads in my mingw and/or
>> mingw-w64 environment and links with -pthread which leads to
>> threads.exe depending on winpthread.dll or similar.
> Yes, looks like I'm seeing something similar above.
Should be fixed with r12138.