Haskell cabal: C compiler cannot create executables - haskell

I'm trying to install ghc-mod for GHC 8.0.1 on windows/x64. When I try to install ghc-mod via cabal install ghc-mod I get an error saying my C compiler isn't working (it is using the c-compiler bundled with ghc).
Here is the output (of the second time I ran the command. Its basically what the first one says but reduced to the error message):
C:\Users\******>cabal install ghc-mod
Resolving dependencies...
Configuring old-time-1.1.0.3...
Failed to install old-time-1.1.0.3
Build log ( C:\Users\******\AppData\Roaming\cabal\logs\old-time-1.1.0.3.log ):
Configuring old-time-1.1.0.3...
bash.exe: warning: could not find /tmp, please create!
configure: WARNING: unrecognized options: --with-compiler
checking for gcc... C:\PROGRA~1\Haskell Platform\8.0.1\mingw\bin\gcc.exe
^ I think the error lies here, as you can see the file path is corrupted but I wasn't able to locate the cause for this
checking whether the C compiler works... no
configure: error: in `/cygdrive/c/Users/******/AppData/Local/Temp/cabal-tmp-6084/old-time-1.1.0.3':
configure: error: C compiler cannot create executables
See `config.log' for more details
cabal: Leaving directory 'C:\Users\******\AppData\Local\Temp\cabal-tmp-6084\old-time-1.1.0.3'
cabal: Error: some packages failed to install:
cpphs-1.20.2 depends on old-time-1.1.0.3 which failed to install.
ghc-mod-5.6.0.0 depends on old-time-1.1.0.3 which failed to install.
haskell-src-exts-1.17.1 depends on old-time-1.1.0.3 which failed to install.
hlint-1.9.35 depends on old-time-1.1.0.3 which failed to install.
old-time-1.1.0.3 failed during the configure step. The exception was:
ExitFailure 77
Could you please help me to install ghc-mod or provide any other way of installing it.
I already trieded reinstalling Haskell since I'm just starting off but this didn't make any difference.
And YES I added the 3 lines provided on the haskell homepage.

I can't know for certain, but thought I'd write an answer with what I think is going on.
The old-time package contains a configure script, which is a Unix shell script used to (surprise!) configure the package. The Cabal build system allows packages to automatically integrate configure, and will run the script for them. On POSIX systems, there's always a shell easily available. However, on Windows, that's not the case. I believe that's the problem you're running into.
Now the tricky part: why don't you have a shell? In theory, the Haskell Platform ships a shell. Well, here are my guesses:
For Stack usage, there's a Haskell Platform bug where Stack cannot find the MSYS tools, which include the shell script. Newer versions of Stack work around this bug, but passing in --no-system-ghc tells Stack to ignore any installed toolchain and manage the installation itself, which is more reliable than using HP's copy.
For Cabal usage, I'm less certain. I think the HP team decided to require you to use a special batch program to set environment variables correctly, so if you just run cabal install foo from a normal command window, Cabal won't find MSYS and it will fail. However, without more information, I can't be certain this is the case.
My personal recommendation: uninstall Haskell Platform, and use the recommended Stack installation instructions. In your case, that's just downloading and running the 64-bit Windows installer.
Finally: your suspected problem is not actually a problem; on Windows, pathnames longer than 8 characters can be compressed in the way you see (with ~1 at the end). There's nothing buggy in that path display.

Related

GHC linker cannot find lHSsemigroups

I'm attempting to compile a Haskell project on Windows with profiling enabled, using the following command.
ghc --make -O -prof -fprof-auto game_dangerous.hs
I develop the project myself and the same source code compiled and linked fine without profiling. As expected (from previous experience) I ran into a number of errors of the form:
Could not find module `Data.Vector.Mutable'
Perhaps you haven't installed the profiling libraries for package `vector-0.12.0.2'?
I proceeded to iteratively reinstall packages based on the errors encountered using for example:
cabal install -p vector --reinstall
Cabal kept giving me warnings about possibly breaking packages with the reinstalls but I pressed on as (as far as I could see) every package that could be broken was going to get reinstalled itself as I moved through the tree of dependencies. Also, I've previously followed the same process on another machine and it worked fine. After reinstalling all the required packages my project now compiles but the linker fails with this error:
C://Program Files//Haskell Platform//8.6.3//mingw//bin/ld.exe: cannot find -lHSsemigroups-0.18.5-8pPnWqWrcWhEagTFf5Pnk2_p
collect2.exe: error: ld returned 1 exit status
`gcc.exe' failed in phase `Linker'. (Exit code: 1)
However, the build does complete successfully without profiling enabled. Does anyone know what may have gone wrong and how to fix the issue? Thanks in advance.
Steven
I would try making a .cabal file for your program, where you explicitly specify the cabal packages your program depends on and use cabal v2-build to compile your program. It will warn you about missing dependencies of your program until you include them all in build-depends section of the .cabal file. You only need to include the dependencies of your program, not the dependencies of the dependencies. After that you can add cabal.project.local to enable profiling and maybe something else. It should be enough to run cabal v2-build to build your program and packages it depends on with profiling(and other options in the cabal.project.local) enabled.
You need to have profiling enabled in the packages used by your program to support profiling in it. Cabal v2 builds allows you to have multiple instances of the same package. Those instances are different because different flags and options have been used to build them.
It is possible to achieve the same result using a separate package database for your program. That is using ghc-pkg with --package-db option.
Another option is to use stack. It will solve the same issues, but differently at the cost of more space and some performance penalties in ghc(compared to ghc built from source which can be used with cabal).

Error when running stack build language-plutus-core on Windows 8

When I ran the command stack build language-plutus-core I received the following error:
-- While building custom Setup.hs for package cryptonite-openssl-0.7 using:
C:\sr\setup-exe-cache\x86_64-windows\Cabal-simple_Z6RU0evB_2.4.0.1_ghc-8.6
.4.exe --builddir=.stack-work\dist\e626a42b configure --with-ghc=C:\Users...
Process exited with code: ExitFailure 1
Logs have been written to: C:\Projects\2019-08-07-Plutus\plutus-master\.stac
k-work\logs\cryptonite-openssl-0.7.log
Configuring cryptonite-openssl-0.7...
Cabal-simple_Z6RU0evB_2.4.0.1_ghc-8.6.4.exe: Missing dependencies on foreign libraries:
* Missing (or bad) C libraries: eay32, ssl32
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.
If the library files do 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.
Anyone any idea how to fix this? Do i need to install eay32, ssl32 separately?
Consider installing these packages using the bundled MSYS in your stack installation. First do stack exec bash to enter MSYS, then use the pacman in that MSYS environment.
The packages from the bundled pacman are from MinGW32, MinGW64 and MSYS2, so most of them (as far as I have used) should be prefixed with mingw-w64-i686- or mingw-w64-x86_64-. See the official documentation for msys2 for detailed information.

failing cabal install MissingH and network on Windows

I just installed a new Haskell version: HaskellPlatform-8.0.1-minimal-x86_64-setup-a,
I need the package MissingH, which needs the package network.
However cabal install network yields:
$ cabal install network
Resolving dependencies...
cabal: Entering directory 'C:\cygwin64\tmp\cabal-tmp-6136\network-2.6.2.1'
Configuring network-2.6.2.1...
configure: WARNING: unrecognized options: --with-compiler
checking build system type... x86_64-unknown-cygwin
checking host system type... x86_64-unknown-cygwin
checking for gcc... C:\PROGRA~1\HASKEL~1\802E01~1.1\mingw\bin\gcc.exe
checking whether the C compiler works... no
configure: error: in `/tmp/cabal-tmp-6136/network-2.6.2.1':
configure: error: C compiler cannot create executables
See `config.log' for more details
cabal: Leaving directory 'C:\cygwin64\tmp\cabal-tmp-6136\network-2.6.2.1'
Failed to install network-2.6.2.1
cabal.exe: Error: some packages failed to install:
network-2.6.2.1 failed during the configure step. The exception was:
ExitFailure 77
First, I tried to start Cygwin command window as administrator, but that didn't solve the problem.
Then, I followed stack cannot build network - where's config.log?
While installing using stack yields success,
although I have to run stack setup
$ stack build
Compiler version mismatched, found ghc-8.0.1 (x86_64), but expected minor version match with ghc-7.10.3 (x86_64) (based on resolver setting in C:\tmp\network-2.6.2.1\stack.yaml).
Try running "stack setup" to install the correct GHC into C:\Users\<username>\AppData\Local\Programs\stack\x86_64-windows\
after stack setup, stack build, I get:
$ stack test
network-2.6.2.1: test (suite: regression)
testGetAddrInfo: [OK]
Test Cases Total
Passed 1 1
Failed 0 0
Total 1 1
network-2.6.2.1: test (suite: simple)
Basic socket operations:
testSend: [OK]
testSendAll: [OK]
testSendTo: [OK]
testSendAllTo: [OK]
testSendMany: [OK]
testSendManyTo: [OK]
testRecv: [OK]
testOverFlowRecv: [OK]
testRecvFrom: [OK]
testOverFlowRecvFrom: [OK]
testUserTimeout: [OK]
Test Cases Total
Passed 11 11
Failed 0 0
Total 11 11
Yet still I can't continue with MissingH. In fact, it still tries to install network!
$ cabal install MissingH
Resolving dependencies...
cabal: Entering directory 'C:\cygwin64\tmp\cabal-tmp-5596\network-2.6.2.1'
Configuring network-2.6.2.1...
configure: WARNING: unrecognized options: --with-compiler
checking build system type... x86_64-unknown-cygwin
checking host system type... x86_64-unknown-cygwin
checking for gcc... C:\PROGRA~1\HASKEL~1\802E01~1.1\mingw\bin\gcc.exe
checking whether the C compiler works... no
configure: error: in `/tmp/cabal-tmp-5596/network-2.6.2.1':
configure: error: C compiler cannot create executables
See `config.log' for more details
cabal: Leaving directory 'C:\cygwin64\tmp\cabal-tmp-5596\network-2.6.2.1'
Failed to install network-2.6.2.1
I also tried: http://neilmitchell.blogspot.nl/2010/12/installing-haskell-network-library-on.html which was tested on GHC 6.12.3 and 7.0.1 (and not on the new 8.0.1 version).
Unfortunately, I get the error:
getEnv: invalid argument (The operation completed successfully.)
Just for completeness, my cabal version:
$ cabal -V
cabal-install version 1.24.0.0
compiled using version 1.24.0.0 of the Cabal library
What am I missing to install network and MissingH?
Stack makes some assumptions about your setup, noteably:
... that it's the only one managing packages on the system
... that it's the only one managing ghc on the system
... that it's the only one managing cabal on the system
... that every project is sandboxed
... that you would rather have stability and predictability than the newest versions of everything
You can get away with using stack together with "plain" tools - but only in different projects and if you're really careful. Things like differing versions of cabal-install can still trip it up. At the same time it keeps its own data separated so installing anything via stack is invisible to cabal. Thus you have two choices: Either have your project buy into stack completely or ditch it completely.
If you want to use it, just add MissingH to your .cabal file and rebuild and everything should be fine. If errors do pop up, the easiest solution is to purge the local cabal repository and try again. If that doesn't work, purge the whole platform and have stack reinstall everything itself and try again. Stack is a picky diva, but once she's on stage she runs it. Tip: if you like the cabal interface but choose to use stack you can always run stuff like stack exec -- cabal install MissingH.
The other option is to ditch stack completely. Uninstall it and use cabal alone, possibly with sandboxes. That still leaves you with the original problem - which looks like a native library is missing that you have to install separately. I have no idea which one it is in this specific case, but I can give you a few hints where to look. If you find no documentation about it, you can just look into the stack files. (they succeeded, after all) But the simplest option is to just look which networking libraries cygwin installed and have it also install the -dev versions of them. They are almost always the right ones.
The problem seems to be this
configure: error: in `/tmp/cabal-tmp-6136/network-2.6.2.1':
configure: error: C compiler cannot create executables
Either you don't have a C compiler installed or it's too old.
We don't actually support Cygwin anymore, try installing msys2 (actually doesn't platform come with this now?) and compiling via that.
You'll have to install a C compiler as well pacman -S mingw-w64-$(uname -m)-gcc should do. The ./configure scripts won't be able to detect GHC's inplace GCC I think. Not sure as I haven't used platform in a while.

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.

How to install wxHaskell on Windows with MinGW/MSYS

I was trying to install wxHaskell into a machine running Windows XP64, with MinGW/MSYS and wxWidget 3.0 built from source using gcc. I did:
cabal install wx
and got an error:
...
Configuring wxc-0.90.0.4...
setup.exe: wx-config: does not exist
Failed to install wxc-0.90.0.4
cabal.exe: Error: some packages failed to install:
wx-0.90.0.1 depends on wxc-0.90.0.4 which failed to install.
wxc-0.90.0.4 failed during the configure step. The exception was:
ExitFailure 1
wxcore-0.90.0.3 depends on wxc-0.90.0.4 which failed to install.
I had successfully used wxWidgets to write an sample application in C++ (gcc). So I do have a working wxWidget installation. And I have wx-config at:
$ which wx-config
/usr/local/bin/wx-config
The problem is that wx-config is a unix shell script, and cabal (called from MSYS) somehow refuses to recognize it even if it's on the system path. If I run wx-config in MSYS, I get something like:
$ wx-config --cxxflags
-I/usr/local/lib/wx/include/msw-unicode-3.0 -I/usr/local/include/wx-3.0 -D_LARGE
FILE_SOURCE=unknown -DWXUSINGDLL -D__WXMSW__ -mthreads
I have asked a question https://stackoverflow.com/questions/21998763/how-to-convert-msys-shell-scripts-to-windows-exe-files to see if it's possible to convert the script to an exe, but no one responded with any solutions.
There is also a related question here, wxHaskell installation on windows , and another here wx 0.90.0.1 fails to install on Haskell Platform 2012.2.0.0 (WinXP). In fact, I couldn't found an answer that's confirmed to work. Also, the errors/settings here seem to be different, or the answers therein don't seem solve my problem. In particular, I downloaded an external wx-config.exe from https://sourceforge.net/projects/wxhaskell/files/wx-config-win/ per http://www.haskell.org/haskellwiki/WxHaskell/Windows. But running wx-config.exe can't recognize my wxWidget installation and always gives me an error about cannot find wxWidgets, like this:
$ ./wx-config.exe --prefix=/usr/local/
wx-config Error: wxWidgets hasn't been found installed at 'C:\MinGW\msys\1.0\loc
al'.
Please use the --prefix flag (as in wx-config --prefix=C:\wxWidgets)
or set the environment variable WXWIN (as in WXWIN=C:\wxWidgets)
to specify where is your installation of wxWidgets.
Any idea how to work around this issue?
Thanks,
-- Update --
#JP I tried:
C:\temp\wxdirect-0.90.0.1>runhaskell Setup configure --extra-lib-dirs=c:\MinGW\lib --extra-include-dirs=c:\MinGW\include --extra-include-dirs=c:\MinGW\msys\1.0\local\include
Configuring wxdirect-0.90.0.1...
and got
Setup: At least the following dependencies are missing:
containers >=0.2 && <0.5, strict -any
I tweaked wxdirect.cabal to bypass containers >=0.2 && <0.5, but can't get pass strict.
I've written a powershell script that automates the setup of MinGW and the downloading/building of wxWidgets in order to build wxHaskell for Windows 7.
https://github.com/cessationoftime/wxHaskell-Windows-Builder

Resources