deech / fltkhs

Haskell bindings to FLTK GUI toolkit.
MIT License
190 stars 24 forks source link

`make` error when trying to compile on Windows #42

Closed mpwp closed 7 years ago

mpwp commented 7 years ago

I'm trying to port a little program on Windows but I can't manage to install fltkhs. Using the procedure described on hackage, I'm stuck here:

[ 97%] Built target fltkc_obj
Scanning dependencies of target fltkc-dyn
make[2]: *** No rule to make target '/lib', needed by 'c-lib/libfltkc-dyn.dll'. Stop.
make[1]: *** [CMakeFiles/Makefile2:127: c-src/CMakeFiles/fltkc-dyn.dir/all] Error
make: *** [Makefile:84:all] Error

After running stack install in fltkhs-hello-world directory, and got the same error with cabal.

By checking online, it seems make apparently knows that he needs to do something with /lib but not what. I don't find any clues in the makefiles of fltk and fltkhs (but I'm a noob here).

As I just want to make a statically linked executable, and it seems the dynamic part is problematic: I tried to install fltkhs manually, deleting everything related to dynamic libraries in the package (ugly hack) and it nearly works.. but after I got some g++ linking errors (lot of undefined references) when trying to use the library, I think it's normal.

I tried to disable shared libraries when running cmake, but it changes nothing.

It's not related but I had to make changes in FL_Types.hs otherwise it won't compile (CULLong instead of CInt):

type FDHandlerPrim = CULLong -> Ptr () -> IO ()
type FDHandler = CULLong -> IO ()

And the move from defaultUserHooks to autoconfUserHooks in Setup.hs don't work on my computer as setup.exe fail to find a configure script.

I don't know how to resolve this issue as I normally don't use haskell on windows and I never directly used makefiles. On my dev machine (linux) everything runs so smoothly. I'm available for testing and to give as much information as I can.

deech commented 7 years ago

Glad it's working on Linux. I'm not surprised that the build instructions aren't working. When I was writing them I only had access to a Windows 7 machine. Which Windows version are you using?

mpwp commented 7 years ago

Currently I'm on a windows 8.1 machine (64bits as you guessed!). I'm using last version of cmake (3.7.2). And msys2 that comes bundled with stack, I tried to install it first but the results are the same so I ended with only one to avoid duplicates or bad links..

First problems were too long directory name for windows (the ..AppData.. stuff was very long) and I got a 'é' character in my user login that makes it bugs. But that stuff is corrected now. I will try on a windows 7 vm as soon as I make the network working.

deech commented 7 years ago

Hi, Over the past week I've overhauled the Windows installation process. It's much simpler now and doesn't depend on CMake, just stack. Even though the instructions are for Windows 10 I'm hoping they will work fine for Windows 8 as well. Would you mind trying it out?

mpwp commented 7 years ago

Hi! Yes, sure, I'm trying it right now. I saw that you made a lot of changes during the week, thanks a lot!

I got an error when installing fltkhs-hello-world, here the full log (I made a clean install of stack before):

[1 of 2] Compiling Main             ( C:\Users\user\AppData\Local\Temp\stack3176\fltkhs-0.5.0.2\Setup.hs, C:\Users\user\AppData\Local\Temp\stack3176\fltkhs-0.5.0.2\.stack-work\dist\b7fec021\setup\Main.o )
[2 of 2] Compiling StackSetupShim   ( C:\sr\setup-exe-src\setup-shim-Z6RU0evB.hs, C:\Users\user\AppData\Local\Temp\stack3176\fltkhs-0.5.0.2\.stack-work\dist\b7fec021\setup\StackSetupShim.o )
Linking C:\Users\user\AppData\Local\Temp\stack3176\fltkhs-0.5.0.2\.stack-work\dist\b7fec021\setup\setup.exe ...
Running autoconf ...
Configuring fltkhs-0.5.0.2...
configure: WARNING: unrecognized options: --with-compiler
checking for g++... g++
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.exe
checking for suffix of executables... .exe
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking for gcc... C:\Users\user\AppData\Local\Programs\stack\X86_64~1\GHC-80~1.1\mingw\bin\gcc.exe
checking whether we are using the GNU C compiler... yes
checking whether C:\Users\user\AppData\Local\Programs\stack\X86_64~1\GHC-80~1.1\mingw\bin\gcc.exe accepts -g... yes
checking for C:\Users\user\AppData\Local\Programs\stack\X86_64~1\GHC-80~1.1\mingw\bin\gcc.exe option to accept ISO C89... none needed
checking for fltk-config... fltk-config
checking how to run the C preprocessor... C:\Users\user\AppData\Local\Programs\stack\X86_64~1\GHC-80~1.1\mingw\bin\gcc.exe -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking stddef.h usability... yes
checking stddef.h presence... yes
checking for stddef.h... yes
checking for stdint.h... (cached) yes
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking for unistd.h... (cached) yes
checking for main in -ldl... no
checking for size_t... yes
checking for stdlib.h... (cached) yes
checking for GNU libc compatible malloc... yes
checking for select... no
checking for strdup... yes
checking for strerror... yes
checking for strrchr... yes
checking for strtol... yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating c-src/Makefile
config.status: creating c-examples/Makefile
config.status: creating fltkhs.buildinfo
configure: WARNING: unrecognized options: --with-compiler
==Compiling C bindings==
*** Compiling Fl_Menu_ButtonC.cpp...
*** Compiling Fl_PositionerC.cpp...
*** Compiling Fl_TimerC.cpp...
*** Compiling Fl_Value_OutputC.cpp...
*** Compiling Fl_Value_SliderC.cpp...
*** Compiling Fl_ScrollbarC.cpp...
*** Compiling Fl_ScrollC.cpp...
*** Compiling Fl_RollerC.cpp...
*** Compiling Fl_DialC.cpp...
*** Compiling Fl_CounterC.cpp...
*** Compiling Fl_SpinnerC.cpp...
*** Compiling UtilsC.cpp...
*** Compiling xC.cpp...
*** Compiling fl_utf8C.cpp...
*** Compiling glC.cpp...
*** Compiling glutC.cpp...
*** Compiling DerivedText_Editor.cpp...
*** Compiling DerivedShared_Image.cpp...
*** Compiling filenameC.cpp...
*** Compiling Fl_AskC.cpp...
*** Compiling Fl_BitmapC.cpp...
*** Compiling Fl_BoxC.cpp...
*** Compiling Fl_BrowserC.cpp...
*** Compiling Fl_ButtonC.cpp...
*** Compiling Fl_CallbackC.cpp...
*** Compiling Fl_C.cpp...
*** Compiling Fl_Check_ButtonC.cpp...
*** Compiling Fl_ChoiceC.cpp...
*** Compiling Fl_ClockC.cpp...
*** Compiling Fl_Color_ChooserC.cpp...
*** Compiling Fl_Copy_SurfaceC.cpp...
*** Compiling Fl_Double_WindowC.cpp...
*** Compiling Fl_DrawC.cpp...
*** Compiling Fl_DeviceC.cpp...
*** Compiling Fl_EnumerationsC.cpp...
*** Compiling Fl_File_BrowserC.cpp...
*** Compiling Fl_File_IconC.cpp...
*** Compiling Fl_File_InputC.cpp...
*** Compiling Fl_File_ChooserC.cpp...
*** Compiling Fl_Float_InputC.cpp...
*** Compiling Fl_Gl_WindowC.cpp...
*** Compiling Fl_GroupC.cpp...
*** Compiling Fl_Hold_BrowserC.cpp...
*** Compiling Fl_Image_SurfaceC.cpp...
*** Compiling Fl_ImageC.cpp...
*** Compiling Fl_JPEG_ImageC.cpp...
*** Compiling Fl_Input_C.cpp...
*** Compiling Fl_InputC.cpp...
*** Compiling Fl_Int_InputC.cpp...
*** Compiling Fl_Light_ButtonC.cpp...
*** Compiling Fl_Menu_C.cpp...
*** Compiling Fl_Menu_ItemC.cpp...
*** Compiling Fl_Multi_BrowserC.cpp...
*** Compiling Fl_Multiline_InputC.cpp...
*** Compiling Fl_Multiline_OutputC.cpp...
*** Compiling Fl_Native_File_ChooserC.cpp...
*** Compiling Fl_OutputC.cpp...
*** Compiling Fl_Overlay_WindowC.cpp...
*** Compiling Fl_Paged_DeviceC.cpp...
*** Compiling Fl_PixmapC.cpp...
*** Compiling Fl_PNM_ImageC.cpp...
*** Compiling Fl_PNG_ImageC.cpp...
*** Compiling Fl_XBM_ImageC.cpp...
*** Compiling Fl_XPM_ImageC.cpp...
*** Compiling Fl_GIF_ImageC.cpp...
*** Compiling Fl_BMP_ImageC.cpp...
*** Compiling Fl_PreferencesC.cpp...
*** Compiling Fl_PrinterC.cpp...
*** Compiling Fl_ProgressC.cpp...
*** Compiling Fl_Radio_ButtonC.cpp...
*** Compiling Fl_Radio_Light_ButtonC.cpp...
*** Compiling Fl_Repeat_ButtonC.cpp...
*** Compiling Fl_Return_ButtonC.cpp...
*** Compiling Fl_RGB_ImageC.cpp...
*** Compiling Fl_Round_ButtonC.cpp...
*** Compiling Fl_Round_ClockC.cpp...
*** Compiling Fl_Secret_InputC.cpp...
*** Compiling Fl_Select_BrowserC.cpp...
*** Compiling Fl_Shared_ImageC.cpp...
*** Compiling fl_show_colormapC.cpp...
*** Compiling Fl_Single_WindowC.cpp...
*** Compiling Fl_SliderC.cpp...
*** Compiling Fl_Menu_BarC.cpp...
*** Compiling Fl_Sys_Menu_BarC.cpp...
*** Compiling Fl_TableC.cpp...
*** Compiling Fl_Table_RowC.cpp...
*** Compiling Fl_TabsC.cpp...
*** Compiling Fl_Text_BufferC.cpp...
*** Compiling Fl_Text_DisplayC.cpp...
*** Compiling Fl_Text_EditorC.cpp...
*** Compiling Fl_Text_SelectionC.cpp...
*** Compiling Fl_TileC.cpp...
*** Compiling Fl_PackC.cpp...
*** Compiling Fl_Toggle_ButtonC.cpp...
*** Compiling Fl_TooltipC.cpp...
*** Compiling Fl_TreeC.cpp...
*** Compiling Fl_Tree_ItemC.cpp...
*** Compiling Fl_Tree_PrefsC.cpp...
*** Compiling Fl_ValuatorC.cpp...
*** Compiling Fl_AdjusterC.cpp...
*** Compiling Fl_Value_InputC.cpp...
*** Compiling Fl_WidgetC.cpp...
*** Compiling Fl_WindowC.cpp...
*** Compiling Fl_WizardC.cpp...
*** Linking libfltkc.a...
*** Linking libfltkc-dyn.so...
Building fltkhs-0.5.0.2...
Preprocessing library fltkhs-0.5.0.2...
In file included from .stack-work\dist\b7fec021\build\Graphics\UI\FLTK\LowLevel\Ask.chs.h:3:0:
./c-src/Fl_Types.h:3:25: fatal error: FL/fl_types.h: No such file or directory
compilation terminated.
c2hs.exe: Error during preprocessing custom header file

It's strange cause FL/fl_types.h does exist in FLTK_HOME. Is it normal that c-src/Fl_Types.h is the only header without his .cpp partner? Fl_ExportMacros.h too.

deech commented 7 years ago

FLTK_HOME no longer exists I'm afraid. All of the CMake stuff has been removed. Did you do a make install in the FTLK from the MSYS2 shell? If not please follow the new Windows FLTK install instructions. That'll put the libraries in /usr/local/lib or some other well known location.

mpwp commented 7 years ago

Yes, I was trying the new windows fltk install instructions. I'm not totally fluent in english, sorry. When I was talking about FLTK_HOME, I was referring to the fltk directory where the configure, make, make install procedure was done. Thanks for your support!

deech commented 7 years ago

Ok, great. Are you were you trying this in an MSYS2 prompt? Is there a directory called /usr/local/include/FL or perhaps /usr/include/FL? On my machine that's where it copied the headers. Thanks for your patience.

mpwp commented 7 years ago

Yes, it's a MSYS2 prompt and there is a directory /usr/local/include/FL with the fltk headers. edit: I've just tried the install in verbose mode, but nothing interesting here.

deech commented 7 years ago

I'm sorry about all this and thanks again for your patience but I just pushed a fix to fltkhs-hello-world. Since you already have FLTK installed on your system can you try:

> wget --no-check-certificate https://github.com/deech/fltkhs-hello-world/archive/master.zip
> unzip master.zip
> mv fltkhs-hello-world-master fltkhs-hello-world
> cd fltkhs-hello-world
> stack build
> stack exec fltkhs-hello-world
mpwp commented 7 years ago

I got the same error as before, it's frustrating because I can't help more at that level. I will check tomorrow, have a nice day!

deech commented 7 years ago

Argh! :) I have no idea why it can't find headers in /usr/local/include. That's a pretty standard location. I would try two things next:

  1. Manually set the include path:

    export C_INCLUDE_PATH=/usr/local/include:$C_INCLUDE_PATH export INCLUDE_PATH=/usr/local/include:$INCLUDE_PATH stack build

  2. And if that doesn't work, come out of the MSYS2 prompt completely, navigate to the fltkhs-hello-world directory from the standard Command prompt (run 'cmd.exe') and then do stack build.

I'm guessing it's a Windows 8 thing but unfortunately I don't have a machine to test on. Sigh.

deech commented 7 years ago

So I was able to borrow a friend's Windows 8 laptop and I'm past the point where your error occurred. Something that I had to do that isn't documented is pacman -Syu at the MSYS2 prompt. This upgrades the msys install. When I didn't do this I wasn't getting your error but various other utilities (eg. wget) were acting weird. Might help.

deech commented 7 years ago

Aside from doing pacman -Syu I was able to compile on Windows 8 without a hitch.

mpwp commented 7 years ago

Hi deech!

Thanks a lot for your support, well appreciated! Finally, I managed to install it on the laptop of a friend (running windows 7 pro), with the same procedure as the windows 10 install by the way.

I still got the same error with the path exports and the pacman -Syu on the windows 8 machine, it may be a specific bug that I will investigate later.

But if I need to meet my friend just to make an executable on windows, it's not really an issue now.. Thanks again!