2
votes

Background
Currently, I'm working on a project that deals with Computer Vision.

I use ..
- Haskell as programming language.
- GTK+ for creating the GUI.
- FFmpeg to read and extract videos/frames from paths or the webcam.
- some algorithms for edge-detection.

I want to ..
- render videos (unmodified input video, aswell as the modified output video) to a drawingarea-widget that is part of the GTK-library.

My setup
- Windows 10 - 64 bit
- MSYS2 / Mingw32
- Haskell Platform (GHC 8.0.1)
- Cabal Version 1.24.0.0
- ffmpeg-light-0.12.0
- gtk-0.14.6

Problem
To render videos with GTK I need to install bindings for GI, so I tried to install the package 'haskell-gi' but it fails at linking-phase due to undefined references.

Example
After running cabal install haskell-gi i get:

C:\Users\Roland\AppData\Local\Temp\cabal-tmp-1788\haskell-gi-0.20.3\dist\build/libHShaskell-gi-0.20.3-4ylmwt0eEVy4Aeczi0KBpN.a(LibGIRepository.o):fake:(.text+0x19d8): undefined reference to `g_irepository_require'
C:\Users\Roland\AppData\Local\Temp\cabal-tmp-1788\haskell-gi-0.20.3\dist\build/libHShaskell-gi-0.20.3-4ylmwt0eEVy4Aeczi0KBpN.a(LibGIRepository.o):fake:(.text+0x1f59): undefined reference to `g_typelib_symbol'
C:\Users\Roland\AppData\Local\Temp\cabal-tmp-1788\haskell-gi-0.20.3\dist\build/libHShaskell-gi-0.20.3-4ylmwt0eEVy4Aeczi0KBpN.a(LibGIRepository.o):fake:(.text+0x26f3): undefined reference to `g_irepository_prepend_search_path'
C:\Users\Roland\AppData\Local\Temp\cabal-tmp-1788\haskell-gi-0.20.3\dist\build/libHShaskell-gi-0.20.3-4ylmwt0eEVy4Aeczi0KBpN.a(LibGIRepository.o):fake:(.text+0x2bee): undefined reference to `g_base_info_gtype_get_type'
C:\Users\Roland\AppData\Local\Temp\cabal-tmp-1788\haskell-gi-0.20.3\dist\build/libHShaskell-gi-0.20.3-4ylmwt0eEVy4Aeczi0KBpN.a(LibGIRepository.o):fake:(.text+0x2f2e): undefined reference to `g_irepository_find_by_name'
C:\Users\Roland\AppData\Local\Temp\cabal-tmp-1788\haskell-gi-0.20.3\dist\build/libHShaskell-gi-0.20.3-4ylmwt0eEVy4Aeczi0KBpN.a(LibGIRepository.o):fake:(.text+0x42c7): undefined reference to `g_struct_info_get_field'
C:\Users\Roland\AppData\Local\Temp\cabal-tmp-1788\haskell-gi-0.20.3\dist\build/libHShaskell-gi-0.20.3-4ylmwt0eEVy4Aeczi0KBpN.a(LibGIRepository.o):fake:(.text+0x460b): undefined reference to `g_struct_info_get_n_fields'
C:\Users\Roland\AppData\Local\Temp\cabal-tmp-1788\haskell-gi-0.20.3\dist\build/libHShaskell-gi-0.20.3-4ylmwt0eEVy4Aeczi0KBpN.a(LibGIRepository.o):fake:(.text+0x4775): undefined reference to `g_struct_info_get_size'
C:\Users\Roland\AppData\Local\Temp\cabal-tmp-1788\haskell-gi-0.20.3\dist\build/libHShaskell-gi-0.20.3-4ylmwt0eEVy4Aeczi0KBpN.a(LibGIRepository.o):fake:(.text+0x4aef): undefined reference to `g_union_info_get_field'
C:\Users\Roland\AppData\Local\Temp\cabal-tmp-1788\haskell-gi-0.20.3\dist\build/libHShaskell-gi-0.20.3-4ylmwt0eEVy4Aeczi0KBpN.a(LibGIRepository.o):fake:(.text+0x4e33): undefined reference to `g_union_info_get_n_fields'
C:\Users\Roland\AppData\Local\Temp\cabal-tmp-1788\haskell-gi-0.20.3\dist\build/libHShaskell-gi-0.20.3-4ylmwt0eEVy4Aeczi0KBpN.a(LibGIRepository.o):fake:(.text+0x4f9d): undefined reference to `g_union_info_get_size'
collect2.exe: error: ld returned 1 exit status
`gcc.exe' failed in phase `Linker'. (Exit code: 1)
cabal: Leaving directory 'C:\Users\Roland\AppData\Local\Temp\cabal-tmp-1788\haskell-gi-0.20.3'
cabal: Error: some packages failed to install:
haskell-gi-0.20.3 failed during the building phase. The exception was:
ExitFailure 1

Note
This undefined references are methods which are defined in .c/.h-files which are part of GObjects' gobject-introspection folder.

What have I tried so far?
Whilst installing Gtk2Hs and ffmpeg-light I was facing similar problems but I was able to get rid off by ..
- downloading the development-source-files and adding --extra-include-dir or --extra-lib-dir tags to the cabal installation
- adding linker flags (pkg-config --libs gobject-introspection-1.0) to the cabal settings
- downloading missing libraries and adding them to the PATH
- modifying .pc files (that are part of the package-config)

None of the options above worked with 'haskell-gi'. I also searched SO for related things but that didn't work too.

Question
Does anyone of you have an idea how to get over this problem? Any help appreciated.

1

1 Answers

1
votes

I don't know what the packages are called on Windows, but on Ubuntu I had to install the C libs/headers for GTK and GI separately with

sudo apt install libgirepository1.0-dev 
sudo apt install libgtk-3-dev

since cabal (or in my case, stack) did not install these for me (though I got different error messages).

You don't say if you've already done this, but https://www.gtk.org/download/windows.php says you should

pacman -S mingw-w64-x86_64-gtk3 
pacman -S mingw-w64-x86_64-toolchain base-devel 

since you've already got MSYS.

It might be helpful if you can post your cabal settings or link to a repo.

(You might also find https://github.com/lettier/movie-monad useful to look at for your project.)