Problems installing gtk2hs on windows - haskell

I have decided to try to install gtk2hs on my Windows 8 (64 bit) machine. I am relying on the lastest Haskell Platform distribution.
So, I go on the wiki, and follow the instructions. I get gtk+ 32-bit distribution, version 2.24, in the all in one bundle. I unpack it correclty, set up PATH to point to gtk/bin, and create INCLUDE and LIB variables to point respectively to gtk/include and gtk/lib (this step does not seem necessary, but it can't hurt!)
I then verify all is in order by invoking
pkg-config --modversion gtk+-2.0
and the terminal happly chirps back
2.24.10
Great!
Then, I run cabal install
gtk2hs-buildtools
and that also goes well.
But then, when I run cabal install gtk, it complains that glib fails to install, because it can't find some C dependencies. I try to isolate the problem by running
cabal install glib
and get the following:
C:\Users\Federico>cabal install glib
Resolving dependencies...
Configuring glib-0.13.1.0...
Failed to install glib-0.13.1.0
Last 10 lines of the build log ( C:\Users\Federico\AppData\Roaming\cabal\logs\gl
ib-0.13.1.0.log ):
[1 of 2] Compiling Gtk2HsSetup ( Gtk2HsSetup.hs, dist\setup-wrapper\Gtk2HsS
etup.o )
[2 of 2] Compiling Main ( SetupMain.hs, dist\setup-wrapper\Main.o )
Linking dist/setup-wrapper\setup.exe ...
Configuring glib-0.13.1.0...
setup.exe: Missing dependencies on foreign libraries:
* Missing C libraries: gobject-2.0, gthread-2.0, glib-2.0, intl
This problem can usually be solved by installing the system packages that
provide these libraries (you may need the "-dev" versions). If the libraries
are already installed but in a non-standard location then you can use the
flags --extra-include-dirs= and --extra-lib-dirs= to specify where they are.
cabal: Error: some packages failed to install:
glib-0.13.1.0 failed during the configure step. The exception was:
ExitFailure 1
But this is utter crap! I KNOW the libraries are there. I can see them, in the gtk/bin folder! I re-check my path, and all is good. They are visible, in path. so is include, and lib. All of it. And yet, cabal complains it can't find them.
But this isn't the scariest bit yet...I download the 64-bit of the library, version 2.16...simply swap the two gtk folders...and now, cabal happly builds the whole thing! Of course, it's unsuable, because ghc on the plaftorm is 32-bit and the libraries are 64-bit, so ghc fails to link against it...but at least cabal was pleased.
I then remove glib, cairo, pango, gtk etc, and go about trying installing again, 2.16, 32-bit. And surely, cabal complains about C dependencies missing.
At this point, befuddled by this kafkian situation, I turn to the wisdom of stack overflow!
Is cabal trolling me? Are the error messages misleading? Or am I missing something obvious?
Thanks to all for the help!

If you are using 64 bit version of GHC, you want to use 64 bit version of gtk as well.
You can download it on this link. Scroll down a bit and download 2.x (not 3.x) all in one bundle, don't download 2.16:
http://www.gtk.org/download/win64.php
Above is no longer an option. You can try installing MSYS and than using MSYS console with pacman package manager to install gtk dev library on windows (I haven't tried it yet though). This pretty much sucks in my opinion.

Related

Cabal can't find foreign libraries

Recently I was trying to install llvm-general-3.5.1.0 package.. for about a week. Basically I am getting this error: link. My situation is identical. Windows 10, ghc 7.10.2, cabal 1.22.4.0. I installed llvm 3.5.2 from sources with cmake and everything went fine. In llvm/lib directory I have *.lib files (eg. LLVMAnalysis.lib).
But somehow cabal can't see those libraries and gives this frustrating error:
Configuring llvm-general-3.5.1.0...
setup.exe: Missing dependencies on foreign libraries:
* Missing C libraries: LLVMLTO, LLVMObjCARCOpts, LLVMLinker, LLVMipo,
LLVMVectorize, LLVMBitWriter, LLVMCppBackendCodeGen, LLVMCppBackendInfo,
LLVMTableGen, LLVMDebugInfo, LLVMOption, LLVMX86Disassembler,
LLVMX86AsmParser, LLVMX86CodeGen, LLVMSelectionDAG, LLVMAsmPrinter,
LLVMX86Desc, LLVMX86Info, LLVMX86AsmPrinter, LLVMX86Utils, LLVMJIT,
LLVMIRReader, LLVMAsmParser, LLVMLineEditor, LLVMMCAnalysis,
LLVMMCDisassembler, LLVMInstrumentation, LLVMInterpreter, LLVMCodeGen,
LLVMScalarOpts, LLVMInstCombine, LLVMTransformUtils, LLVMipa, LLVMAnalysis,
LLVMProfileData, LLVMMCJIT, LLVMTarget, LLVMRuntimeDyld, LLVMObject,
LLVMMCParser, LLVMBitReader, LLVMExecutionEngine, LLVMMC, LLVMCore,
LLVMSupport
This problem can usually be solved by installing the system packages that
provide these libraries (you may need the "-dev" versions). If the libraries
are already installed but in a non-standard location then you can use the
flags --extra-include-dirs= and --extra-lib-dirs= to specify where they are.
I really want to use this package on my Windows, but nothing seems to work (I tried everything like --extra-lib-dirs and compiled also with MinGW and VS - the same problem).
I can't accept the fact that it won't install. I mean, there must be some way to fix Setup.hs from this cabal package or something. Does anyone have an idea what can be wrong with cabal in this case and how can I try to workaround this? I don't know how exactly cabal works, maybe someone with this knowledge will have an idea? Or maybe there is a way to do this without cabal?
Ok, i've managed to build it and, i think, found the root of the issue.
First, steps to build:
Get the MinGW. My installation of MinGW has gcc 4.8.
Get 32-bit MinGHC.
Compile LLVM 3.5 with MinGW's gcc and install it somewhere.
Copy contents of MinGW installation directory into MinGHC Install
Dir\ghc-7.10.2\mingw, replacing conflict files.
In the command line set your PATH so it has haskell toolset from
MinGHC (i recommend using switch .bat scripts) and llvm-config.exe.
Get the llvm-general package source either using cabal fetch or
downloading via browser from hackage.
Replace cc-options: -std=c++11 line of llvm-general.cabal with
cc-options: -std=gnu++11.
Finally, cabal configure and cabal build should work.
I have been changing my build environment many times, so if this doesn't work for you let me know, i probably forgot something.
Now let's go into details.
What we thought is a bug of cabal is not, actually. The problem is that both stack and MinGHC (and Haskell Platform, i guess) use quite old gcc - 4.6. This gcc has even two defects:
It doesn't support -std=c++11 and LLVM 3.5 can't be built using it.
As a consequence, this gcc can't be used by ghc when compiling
llvm-general, because it can't parse LLVM headers properly.
Even if it could, its linker can't link against LLVM libs compiled by
MinGW using gcc 4.8. This is why cabal was telling you it
couldn't find LLVM libs. I've hacked Setup.hs so that it wouldn't
look for these libs, but pass -lLLVMSomething to linker via -pgml
ghc option. This lead to clear error message:
ld.exe: ignoring libLLVMSupport.a ...
ld.exe: can't find -lLLVMSupport
So, the cabal was actually finding these libs, but was dropping them because they couldn't be linked to.
Ideally, the solution would be to update mingw distribution used by stack/MinGHC. But as a workaround you can just replace old gcc with new one.
Finally, -std=gnu++11 is used because current MinGW release is affected by this bug, which prevents compilation of c++ bits of the package. Whew, that was a long way.

Missing dependencies for chart-cairo on linux mint 17

I'm struggling to install GTK / gtk2hs binding on Linux Mint 17.
The first time I encountered this problem was when I tried to get glade support in Haskell.
There were the same problems but it was purely for fun so I let it be.
This time I was trying to visualize a graph with Haskell Chart.
The problem occured in the forth step cabal install chart-cairo
I'm using GHC version 7.6.3, cabal version 1.16.0.2, gtk2hs-buildtools version 0.12.4-2ubuntu1 (from the package manager), gtk2hsC2hs version 0.13.6 (this is where glade needs to have >=0.13.8, but I can't find a newer version)
Things I've tried so far:
After downloading the gtk2hs-buildtools from the package manager I updated cabal and installed the tools from the command line
Added the "$HOME/.cabal/bin" to the front of $PATH (after that gtk installed correctly)
cabal install chart-cairo gets me this error message
Resolving dependencies...
[1 of 2] Compiling SetupWrapper ( /tmp/cairo-0.13.0.2-19862/cairo-0.13.0.2/SetupWrapper.hs, /tmp/cairo-0.13.0.2-19862/cairo-0.13.0.2/dist/setup/SetupWrapper.o )
[2 of 2] Compiling Main ( /tmp/cairo-0.13.0.2-19862/cairo-0.13.0.2/dist/setup/setup.hs, /tmp/cairo-0.13.0.2-19862/cairo-0.13.0.2/dist/setup/Main.o )
Linking /tmp/cairo-0.13.0.2-19862/cairo-0.13.0.2/dist/setup/setup ...
[1 of 2] Compiling Gtk2HsSetup ( Gtk2HsSetup.hs, dist/setup-wrapper/Gtk2HsSetup.o )
[2 of 2] Compiling Main ( SetupMain.hs, dist/setup-wrapper/Main.o )
Linking dist/setup-wrapper/setup ...
Configuring cairo-0.13.0.2...
Building cairo-0.13.0.2...
Preprocessing library cairo-0.13.0.2...
[ 1 of 18] Compiling Graphics.Rendering.Cairo.Matrix ( dist/build/Graphics/Rendering/Cairo/Matrix.hs, dist/build/Graphics/Rendering/Cairo/Matrix.o )
[ 2 of 18] Compiling Graphics.Rendering.Cairo.Types ( dist/build/Graphics/Rendering/Cairo/Types.hs, dist/build/Graphics/Rendering/Cairo/Types.o )
[ 3 of 18] Compiling Graphics.Rendering.Cairo.Internal.Utilities ( dist/build/Graphics/Rendering/Cairo/Internal/Utilities.hs, dist/build/Graphics/Rendering/Cairo/Internal/Utilities.o )
Graphics/Rendering/Cairo/Internal/Utilities.chs:24:42:
Module `Data.Text.Foreign' does not export `withCStringLen'
Failed to install cairo-0.13.0.2
cabal: Error: some packages failed to install:
Chart-cairo-1.3.2 depends on cairo-0.13.0.2 which failed to install.
cairo-0.13.0.2 failed during the building phase. The exception was:
ExitFailure 1
pkg-config cairo --modversion tells me I have the version 1.13.1 (which is newer than 0.13.0.2?)
I just tried it myself, and hit some snags that I was able to overcome.... Perhaps you are having the same problem.
For some reason, some dependencies would not automatically install. It is easy to install them by hand though. Try this:
cabal install alex
cabal install gtk2hs-buildtools
cabal install cairo
cabal install chart-cairo
In general, if you see an error message in your cabal output like the following line in your post
Failed to install cairo-0.13.0.2
it is a good idea to try the install manually. Although dependencies are supposed to be worked out, I've run into many cases where they don't (I think it might have to do with cabal installing command line tools, but have never looked into it fully). In this particular case, that is what I did, but I had to go up the chain 4 times....
An old version of text is being used (also causing cabal to choose the old version of cairo with bad build-deps). Try adding --constraint='cairo>=0.13.0.5' to your cabal install. That should also force cabal to choose a newer version of text.
pkg-config cairo --modversion gives the version of the actual cairo library. 0.13.0.2 is the version of the Gtk2Hs haskell package that wraps cairo (actual cairo version wrapped depends what is installed)
I encountered the same issue. This is a late reply but a good resource for this problem is found here. On my Debian system (Linux Mint) I found that doing:
sudo apt-get install libghc-gtk-dev
solved the problem. But the link provides installation advice for several Linux based systems as well as Windows, BSD and Mac.

Installing SDL on Windows for Haskell (GHC)

Background:
I've been using the gloss library for some simple diagram work. But when it came time for something more interactive, I found I wanted a more powerful library. After doing some research, I decided that I liked the features of the SDL library and wanted to try to install the Haskell bindings for it. I have to this point been unsuccessful.
Part 1:
How do I install and configure the SDL binaries so that they can be used by the Haskell bindings?
Part 2:
Which one of the numerous and ill documented SDL packages on Hackage it the current preferred binding in the community? How do I get that package to install correctly?
Part 3: (Optional)
If SDL is not a good fit for haskell development what is the preferred alternative?
I am going to answer your question for SDL2 (should also work for SDL1 with some modifications).
Install pkg-config for Windows
(How to install pkg config in windows?)
This tool is very important. It is used by various Cabal packages to search for libraries and contains directions for linking and compiling.
Download the SDL development libraries for Windows/MinGW:
http://libsdl.org/release/SDL2-devel-2.0.3-mingw.tar.gz
If you have installed the 32-bit version of the Haskell platform, extract the folder i686-w64-mingw32
For 64-bit versions extract x86_64-w64-mingw32
You will get following layout:
include
share
bin
lib
"Register" the library with pkg-config.
Either copy lib/pkgconfig/sdl2.pc into the folder of your pkg-config.exe or modify/create the PKG_CONFIG_PATH accordingly. Check that you set up everything correctly:
C:\pkg-config --list-all | grep sdl2
sdl2 sdl2 - Simple DirectMedia Layer is a cross-platform multimedia
library designed to provide low level access to audio, keyboard,
mouse, joystick, 3D hardware via OpenGL, and 2D video framebuffer.
Add the bin folder to your PATH environment variable.
Install the sdl2 package via the Cabal installer and tell Cabal where to find your libraries.
Example:
cabal install sdl2 --extra-include-dirs=C:\lib\sdl2\include --extra-lib-dirs=C:\lib\sdl2\lib\
To test my installation, I have written a small example:
https://github.com/ftl2014/haskell-stuff/blob/master/sdl/
Caveat emptor:
If Cabal complains about a "missing" library, it might be the case that library was actually found but it is incompatible (e.g. using a 32-bit instead of a 64-bit version) or corrupt. The same is true for header files.
For some reason, Cabal complained about not finding SDL.h, and I had to use the headers in the root include folder of the archive (but maybe I was just drinking too much Kool-aid).
I wasn't able to get it to install on my system. Here's what I tried. Strangely, I was able to get configure find the header files but not the actual binary.
Let's try it. I have installed the new 2014 Haskell Platform.
cabal install sdl
Configuring SDL-0.6.5...
setup.exe: The package has a './configure' script. This requires a Unix
compatibility toolchain such as MinGW+MSYS or Cygwin.
Failed to install SDL-0.6.5
GHC in the Haskell Platform comes with MinGW, so we probably need to install MSYS. The MSYS page says to install minggw get, which says to install
An automated GUI installer assistant called mingw-get-setup.exe is the preferred method for first time installation. This will guide you through the setup of the mingw-get installer proper; you will then use this to perform further package installations, and to manage your installation.
Running the installer with the default options gives us the following screen:
We already have mingw from installing the Haskell platform, so we'll click on only the last item in the list, msys-base, and select "Mark for Installation". Then, in the "Installation" menu in the top left, select "Apply Changes". This asks if it is ok to proceed, and we select "Apply"
This installer didn't put msys-base in the path, we can add it to the path, and try installing sdl again
set PATH=C:\MinGW\msys\1.0\bin\;%PATH%
cabal install sdl
Configuring SDL-0.6.5...
configure: WARNING: unrecognized options: --with-compiler, --with-gcc
checking for sdl-config... no
checking for sdl11-config... no
configure: error: *** SDL not found! Get SDL from www.libsdl.org.
If you already installed it, check it's in the path. If problem remains,
please send a mail to the address that appears in ./configure --version
indicating your platform, the version of configure script and the problem.
Failed to install SDL-0.6.5
We need to download and install libsdl. I went to the libsdl download page and downloaded the Win32 development libraries, SDL-devel-1.2.15-mingw32.tar.gz. I extracted this archive (7-zip can extract both tar archives and gzip compressed files). For convenience, I moved the SDL-1.2.15 directory to c:. We'll add this to the path, as suggested by the previous error, and try again
set PATH=C:\SDL-1.2.15\bin\;%PATH%
cabal install sdl
* Missing (or bad) header file: SDL/SDL.h
* Missing C library: SDL
This problem can usually be solved by installing the system package that
provides this library (you may need the "-dev" version). If the library is
already installed but in a non-standard location then you can use the flags
--extra-include-dirs= and --extra-lib-dirs= to specify where it is.
If the header file does exist, it may contain errors that are caught by the C
compiler at the preprocessing stage. In this case you can re-run configure
with the verbosity flag -v3 to see the error messages.
We can make part of this error go away by adding the suggested --extra-include-dirs flag, but still get the following error
cabal install sdl --extra-include-dirs=c:\SDL-1.2.15\include
* Missing C library: SDL
This problem can usually be solved by installing the system package that
provides this library (you may need the "-dev" version). If the library is
already installed but in a non-standard location then you can use the flags
--extra-include-dirs= and --extra-lib-dirs= to specify where it is.
Adding the --extra-lib-dirs flag with c:\SDL-1.2.15\bin or C:\SDL-1.2.15\lib or c:\SDL-1.2.15 failed to fix this problem.

haskell snap exitfailure 1

I am new to Haskell, and wanted to play around with snap framework. Unfortunately I just cant get the thing to compile. I've tried (all I know too), updating cabal and running sudo ghc-pkg recache but I still get the following when I run cabal install snap. Please help.
12 warnings and 1 error generated.
Failed to install binary-0.7.1.0
cabal: Error: some packages failed to install:
SHA-1.6.4 depends on binary-0.7.1.0 which faile
d to install.
binary-0.7.1.0 failed during the building phase
. The exception was:
ExitFailure 1
pwstore-fast-2.4.1 depends on binary-0.7.1.0 wh
ich failed to install.
snap-0.13.2.2 depends on binary-0.7.1.0 which f
ailed to install.
Solution:
I first install the 'real' gcc via homebrew like so:
brew update
brew install gcc47
This took a while to install (as in over an hour). Once it was done I updated the GHC settings to use the copy of gcc installed by homebrew.
GHC settings are located either here :
/Library/Frameworks/GHC.framework/Versions/Current/usr/lib/ghc-7.6.3/settings
or here if you installed ghc with homebrew (I did not).
/usr/local/Cellar/ghc/7.6.3/lib/ghc-7.6.3/settings
Update the line
("C compiler command", "/usr/bin/gcc")
to
("C compiler command", "/usr/local/Cellar/gcc47/4.7.3/bin/gcc-4.7")
Then just run
cabal update && cabal install snap
and all should be well. :)
Your problem is that the binary package has some C preprocessor constructs that are not strictly valid.
After looking around a bit, I found a similar problem somebody had when installing the Haskell platform. It seems the core issue is that the Clang C preprocessor is stricter than the GCC one most Haskellers use. I'm assuming that this is your problem: you're using Clang rather than GCC. If you're on OS X, this is the default choice.
The easiest solution seems to be to switch to using GCC for the preprocessing. Note that on OS X, /usr/bin/gcc actually points to Clang! You will need to point GHC to an actual install of GCC.
You can do this by editing GHC's configuration file. On my system it's found at
/usr/local/lib/ghc-7.6.3/settings
Yours is probably somewhere similar, although I'm on Linux rather than OS X. In the file, change
("C compiler command", "/usr/bin/gcc")
to point to an actual copy of gcc rather than Clang and try installing again.
In the long run, this feels like a bug with the package and probably needs to be addressed, although I don't really know enough about the issue or constraints package authors have to be sure.

Registering multiple versions of packages with `ghc-pkg`?

I'm trying to install GHC and Cabal on FreeBSD 8.1.
I've installed GHC 7.0.1 (because it's current stable release) and now trying to install Cabal (to install cabal-install), but it fails with this error message.
%./Setup configure
Configuring Cabal-1.8.0.4...
Setup: At least the following dependencies are missing:
base >=4 && <3 && >=1 && <5, filepath >=1 && <1.2
%
Definitely I'm having too higher version of library.
%ghc-pkg list
/usr/local/lib/ghc-7.0.1/package.conf.d
Cabal-1.10.0.0
array-0.3.0.2
base-4.3.0.0
bin-package-db-0.0.0.0
bytestring-0.9.1.8
containers-0.4.0.0
directory-1.1.0.0
extensible-exceptions-0.1.1.2
ffi-1.0
filepath-1.2.0.0
ghc-7.0.1
ghc-binary-0.5.0.2
ghc-prim-0.2.0.0
haskell2010-1.0.0.0
haskell98-1.1.0.0
hpc-0.5.0.6
integer-gmp-0.2.0.2
old-locale-1.0.0.2
old-time-1.0.0.6
pretty-1.0.1.2
process-1.0.1.4
random-1.0.0.3
rts-1.0
template-haskell-2.5.0.0
time-1.2.0.3
unix-2.4.1.0
/home/eonil/.ghc/x86_64-freebsd-7.0.1/package.conf.d
network-2.2.1.5
parsec-2.1.0.1
%
Should I downgrade to GHC 6.x? Or can I install lower version of the packages? (or side-by-side install)
You've hit on what is known as Haskell's own DLL hell.
You can install previous versions of libraries just by appending the version number, e.g. cabal install base-3.0.3.2, although I don't know what restrictions there are with GHC 7.0.1.
You can also create little cabal sandboxes with cabal-dev or capri. These would sort of allow you to start from scratch, ignoring packages that would cause conflicts.
If none of this works and you do find you have to reinstall GHC, can I recommend you use Haskell Platform. It bundles GHC 6.12.3 with a number of useful libraries.
Update: Misread you were trying to actually install cabal install. I'd just use Haskell Platform. It comes with all this stuff already set up.
One solution would be to install ghc-6.12, which would provide Cabal-1.8. You could use that ghc to build cabal-install for the executable, then switch to ghc-7 for everything else once the cabal executable is built.
However I think you should be able to build Cabal-1.8 with ghc-7. It looks like the installer is getting confused over the base dependencies. Try doing ./Setup configure -fbase4 -f-base3 and see if that works.
Edit: if you have darcs installed, you can check out the cabal source tree. This is already set up for Cabal-1.10 and ghc-7, so it should build out of the box. You could wget the source too if you can't install darcs.
I had to downgrade GHC 6.x.
Originally I did this for Happstack. However Happstack needs at least 6.12.x of GHC and installing Cabal on FreeBSD 8.1 with GHC 7.x is too hard. (I couldn't succeed)
I just downloaded and installed GHC 6.12.3 from GHC website, and everything worked magically! Cabal, Happstack installed at once. I failed just only once because of insufficient swapping space.

Resources