Missing dependencies for chart-cairo on linux mint 17 - haskell

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.

Related

Installation of haskell-chart fails due to gtk-0.14.2 build error

I'm trying to install haskell-chart from here (github), I clone it, install stack, ran stack setup (it installs GHC successfully), but then I ran make that fails with the messages:
...
Chart-cairo-1.8: copy/register
Chart-diagrams-1.8: copy/register
Progress: 4/6
-- While building package gtk-0.14.2 using:
/tmp/stack4807/gtk-0.14.2/.stack-work/dist/x86_64-linux/Cabal-1.22.5.0/setup/setup --builddir=.stack-work/dist/x86_64-linux/Cabal-1.22.5.0 build --ghc-options " -ddump-hi -ddump-to-file"
Process exited with code: ExitFailure 1
...
[ 22 of 209] Compiling Graphics.UI.Gtk.Embedding.Plug ( .stack-work/dist/x86_64-linux/Cabal-1.22.5.0/build/Graphics/UI/Gtk/Embedding/Plug.hs, .stack-work/dist/x86_64-linux/Cabal-1.22.5.0/build/Graphics/UI/Gtk/Embedding/Plug.o )
/tmp/stack4807/gtk-0.14.2/Graphics/UI/Gtk/Embedding/Plug.chs:120:6:
Couldn't match expected type ‘CUInt’
with actual type ‘Maybe DrawWindow’
In the first argument of ‘gtk_plug_new’, namely...
Stack version is 1.1.2 x86_64 hpack-0.14.1, LTS Haskell 5.18 (ghc-7.10.3). What can I do with this errors?
In order to build haskell-chart from github sources on linux one should replace in stack.yaml
flags:
gtk:
have-quartz-gtk: true
with
flags: {}
because Linux don't use Quartz flag have-quartz-gtk, and Quartz is not needed to build gtk (Windows also do not use Quartz).
Using brew I upgraded gtk+ from version 2.24.25 to 2.24.30 and installed the latest version of XQuartz (version 2.7.9 - I couldn't determine which version I had originally installed.)
With these changes I was able to successfully build the project with stack build.
Specific commands:
$ brew cask install xquartz --force
$ brew upgrade gtk
Note that you don't actually have to use gtk. There are two rendering backend for the chart library - one based upon cairo from gtk2hs the other on the diagrams library. The cairo backend is significantly faster, whereas the diagrams backend is pure haskell, and hence is easier to build.
By default, both backends are built, but you can build just the core library and the diagrams backend with:
stack build ./chart ./chart-diagrams

Problems installing gtk2hs on windows

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.

cabal installation failure for llvm-general

I am attempting to install the llvm-general Cabal package on OS X. When I do, I get the following error:
$ cabal install llvm-general
Resolving dependencies...
[1 of 1] Compiling Main ( /var/folders/PP/PP+wAuBcGWuqzt-Iekiipk+++TI/-Tmp-/llvm-general-3.4.4.2-38424/llvm-general-3.4.4.2/Setup.hs, /var/folders/PP/PP+wAuBcGWuqzt-Iekiipk+++TI/-Tmp-/llvm-general-3.4.4.2-38424/llvm-general-3.4.4.2/dist/setup/Main.o )
Linking /var/folders/PP/PP+wAuBcGWuqzt-Iekiipk+++TI/-Tmp-/llvm-general-3.4.4.2-38424/llvm-general-3.4.4.2/dist/setup/setup ...
setup: The program llvm-config version ==3.4.* is required but the version
found at /usr/local/bin/llvm-config is version 3.2
cabal: Error: some packages failed to install:
llvm-general-3.4.4.2 failed during the configure step. The exception was:
ExitFailure 1
What it's doing is running /usr/local/bin/llvm-config; this, I believe, is the version of LLVM installed by the OS X developer tools that I installed a while ago. I do have the current version of LLVM, but it's installed with Homebrew as a local (keg-only) installation. Is there any way I can point cabal to that version of LLVM for the purposes of this installation?
I believe that cabal simply looks in your PATH for llvm-config, so just adjust your path accordingly. Otherwise you can try:
modify the file llvm-general.cabal to reference an absolute path for llvm-config (line 52)
temporarily move aside /usr/local/bin/llvm-config and replace it with the llvm-config for the llvm installation you want to use
For reference, I found llvm-config for version 3.4 at /usr/local/Cellar/llvm34/3.4.2/lib/llvm-3.4/bin/llvm-config on my OSX system.

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