Cabal v2-build: Undefined symbols for architecture x86_64 - haskell

Cabal suddenly stopped building my project. Nothing much changed in the project itself since the last successful build, I guess only OS updates were installed.
The error I get on cabal v2-build is:
Undefined symbols for architecture x86_64:
"_u_errorName_70", referenced from:
___hs_u_errorName in libHStxt-c-0.7.1.0-21406b30.a(text_icu.o)
"_ucnv_close_70", referenced from:
___hs_ucnv_close in libHStxt-c-0.7.1.0-21406b30.a(text_icu.o)
"_ucnv_fromUChars_70", referenced from:
___hs_ucnv_fromUChars in libHStxt-c-0.7.1.0-21406b30.a(text_icu.o)
"_ucnv_getMaxCharSize_70", referenced from:
___get_max_bytes_for_string in libHStxt-c-0.7.1.0-21406b30.a(text_icu.o)
"_ucnv_open_70", referenced from:
___hs_ucnv_open in libHStxt-c-0.7.1.0-21406b30.a(text_icu.o)
"_ucnv_setFallback_70", referenced from:
___hs_ucnv_setFallback in libHStxt-c-0.7.1.0-21406b30.a(text_icu.o)
"_ucnv_toUChars_70", referenced from:
___hs_ucnv_toUChars in libHStxt-c-0.7.1.0-21406b30.a(text_icu.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
`gcc' failed in phase `Linker'. (Exit code: 1)
Additionally, cabal repl stopped working as well:
<command line>: dlopen(/Users/user/.cabal/store/ghc-8.10.7/lib/libHStxt-c-0.7.1.0-21406b30-ghc8.10.7.dylib, 0x0005): Library not loaded: '/usr/local/opt/icu4c/lib/libicuuc.70.dylib'
Referenced from: '/Users/user/.cabal/store/ghc-8.10.7/lib/libHStxt-c-0.7.1.0-21406b30-ghc8.10.7.dylib'
Reason: tried: '/usr/local/opt/icu4c/lib/libicuuc.70.dylib' (no such file), '/usr/local/lib/libicuuc.70.dylib' (no such file), '/usr/lib/libicuuc.70.dylib' (no such file), '/usr/local/Cellar/icu4c/71.1/lib/libicuuc.70.dylib' (no such file), '/usr/local/lib/libicuuc.70.dylib' (no such file), '/usr/lib/libicuuc.70.dylib' (no such file)
Error: cabal: repl failed for exe:appname from
appname-1.0.0
I am on ghc 8.10.7, macOS Monterey 12.6.1 and cabal --version outputs
cabal-install version 3.8.1.0
compiled using version 3.8.1.0 of the Cabal library
Version of icu4c is 71.1, it is installed using brew.
How could I make the project compile successfully again?

Well, it looks like the text-icu package got built against icu4u version 70, and then your system upgraded to version 71. Unless you feel like downgrading icu4u, you should try deleting the package store (that is, ~/.cabal/store/ghc-<version>/). The next run of cabal v2-build in your project will then go and rebuild all its dependencies, including the packages rendered "stale" by your system upgrade. Note that deleting the store may break installed executables.

Related

Haskell linker unable to open output file

I am new to Haskell and I am using cabal for a small project. The project is managed on github and it works fine if I run cabal run on the current code. There are also no errors if I enter ghci *.hs However, if I make any changes to the code at all, the following is printed to the terminal. What might be the issue here?
C:\Users\65963\scripting-hs> cabal run
Resolving dependencies...
Build profile: -w ghc-8.10.3 -O1
In order, the following will be built (use -v for more details):
- scripting-hs-0.1.0.0 (exe:scripting-hs) (configuration changed)
Configuring executable 'scripting-hs' for scripting-hs-0.1.0.0..
Preprocessing executable 'scripting-hs' for scripting-hs-0.1.0.0..
Building executable 'scripting-hs' for scripting-hs-0.1.0.0..
Linking C:\Users\65963\scripting-hs\dist-newstyle\build\x86_64-windows\ghc-8.10.3\scripting-hs-0.1.0.0\x\scripting-hs\build\scripting-hs\scripting-hs.exe ...
C://ProgramData//chocolatey//lib//ghc//tools//ghc-8.10.3//mingw//bin/ld.exe: cannot open output file C:\Users\65963\CS Projects\St Andrews CS\CS2006\CS2006-Haskell2\scripting-hs\dist-newstyle\build\x86_64-windows\ghc-8.10.3\scripting-hs-0.1.0.0\x\scripting-hs\build\scripting-hs\scripting-hs.exe: Invalid argument
collect2.exe: error: ld returned 1 exit status
`gcc.exe' failed in phase `Linker'. (Exit code: 1)

Installing Euterpea for computer music applications and Haskell

I followed the instructions here http://www.euterpea.com for installing Euterpea (a domain-specific language for computer music applications embedded in Haskell), and I received a message that certain packages and things failed to install (see the code below). How can I install the remaining packages?
Mo-MacBook-Pro:~ Mo$ cabal update
Downloading the latest package list from hackage.haskell.org
cabal install Euterpea
To revert to previous state run:
cabal update --index-state='2018-06-25T08:34:14Z'
Mo-MacBook-Pro:~ Mo$ cabal install Euterpea
clang: warning: argument unused during compilation: '-nopie' [-Wunused-
command-line-argument]
Resolving dependencies...
Downloading heap-1.0.4...
Downloading PortMidi-0.1.6.1...
Configuring PortMidi-0.1.6.1...
Downloading lazysmallcheck-0.6...
Configuring heap-1.0.4...
Downloading semigroups-0.18.5...
Configuring lazysmallcheck-0.6...
Configuring semigroups-0.18.5...
Building heap-1.0.4...
Building PortMidi-0.1.6.1...
Building lazysmallcheck-0.6...
Building semigroups-0.18.5...
Installed semigroups-0.18.5
Downloading stm-2.5.0.0...
Configuring stm-2.5.0.0...
Installed lazysmallcheck-0.6
Downloading HCodecs-0.5.1...
Installed heap-1.0.4
Downloading Stream-0.4.7.2...
Configuring HCodecs-0.5.1...
Configuring Stream-0.4.7.2...
Building stm-2.5.0.0...
Building HCodecs-0.5.1...
Building Stream-0.4.7.2...
Failed to install HCodecs-0.5.1
Build log ( /Users/Mo/.cabal/logs/ghc-8.4.3/HCodecs-0.5.1-
BtnY8oBJJ5FGnsoQaqbvOm.log ):
cabal: Entering directory
'/var/folders/dy/q51p3v595kbd8_wclmt80v700000gn/T/cabal-tmp-
5294/HCodecs-0.5.1'
Configuring HCodecs-0.5.1...
clang: warning: argument unused during compilation: '-nopie' [-Wunused-
command-line-argument]
Preprocessing library for HCodecs-0.5.1..
Building library for HCodecs-0.5.1..
<command line>: cannot satisfy -package-id random-1.1-
7T1TXpwb46H1j0av1OnVaD
(use -v for more information)
cabal: Leaving directory
'/var/folders/dy/q51p3v595kbd8_wclmt80v700000gn/T/cabal-tmp-
5294/HCodecs-0.5.1'
Failed to install Stream-0.4.7.2
Build log ( /Users/Mo/.cabal/logs/ghc-8.4.3/Stream-0.4.7.2-
ES6rey5IgWg9tsXDghlP7Y.log ):
cabal: Entering directory
'/var/folders/dy/q51p3v595kbd8_wclmt80v700000gn/T/cabal-tmp-
5295/Stream-0.4.7.2'
Warning: Stream.cabal:6:4: Tabs used as indentation at 6:4, 12:4, 13:4,
14:4,
15:4, 16:4, 17:4
Configuring Stream-0.4.7.2...
clang: warning: argument unused during compilation: '-nopie' [-Wunused-
command-line-argument]
Preprocessing library for Stream-0.4.7.2..
Building library for Stream-0.4.7.2..
<command line>: cannot satisfy -package-id QuickCheck-2.11.3-
4Q6LQ7mN6Tj8otrLuHN0se
(use -v for more information)
cabal: Leaving directory
'/var/folders/dy/q51p3v595kbd8_wclmt80v700000gn/T/cabal-tmp-
5295/Stream-0.4.7.2'
Installed PortMidi-0.1.6.1
Installed stm-2.5.0.0
cabal: Error: some packages failed to install:
Euterpea-2.0.6-LLo28S848YneLemh6QUkK depends on Euterpea-2.0.6 which
failed to
install.
HCodecs-0.5.1-BtnY8oBJJ5FGnsoQaqbvOm failed during the building phase.
The
exception was:
ExitFailure 1
Stream-0.4.7.2-ES6rey5IgWg9tsXDghlP7Y failed during the building phase.
The
exception was:
ExitFailure 1
arrows-0.4.4.2-GLke2GgDEro6Tzj3MGmTOB depends on arrows-0.4.4.2 which
failed
to install.
It would be great if someone could help. Thanks.
I have included all the code, lest some particular relevant detail was omitted.
Edit
I have also tried to install Euterpea via stack. I get this message:
Mo-MacBook-Pro:~ Mo$ stack install Euterpea
Error: While constructing the build plan, the following exceptions were
encountered:
In the dependencies for Euterpea-2.0.6:
PortMidi must match ==0.1.6.1, but the stack configuration has no specified version (latest matching version is 0.1.6.1)
arrows must match >=0.4 && <0.5, but the stack configuration has no specified version (latest matching version is 0.4.4.2)
needed since Euterpea is a build target.
Some different approaches to resolving this:
* Consider trying 'stack solver', which uses the cabal-install solver to attempt to find some working build configuration. This can be convenient when dealing with many complicated constraint
errors, but results may be unpredictable.
* Recommended action: try adding the following to your extra-deps in /Users/Mo/.stack/global-project/stack.yaml:
- PortMidi-0.1.6.1
- arrows-0.4.4.2
Plan construction failed.
--
Edit 2.
As suggested below, I tried cabal install random-1.1 --force-reinstalls which generated:
clang: warning: argument unused during compilation: '-nopie' [- Wunused-command-line-argument]
Resolving dependencies...
Warning: The following packages are likely to be broken by the reinstalls:
tf-random-0.5
QuickCheck-2.11.3
Continuing even though the plan contains dangerous reinstalls.
Configuring random-1.1...
Building random-1.1...
Installed random-1.1
Then
Mo-MacBook-Pro:~ Mo$ cabal install Euterpea
clang: warning: argument unused during compilation: '-nopie' [- Wunused-command-line-argument]
Resolving dependencies...
Configuring Stream-0.4.7.2...
Configuring HCodecs-0.5.1...
Building HCodecs-0.5.1...
Building Stream-0.4.7.2...
Failed to install HCodecs-0.5.1
Build log ( /Users/lukeburke/.cabal/logs/ghc-8.4.3/HCodecs-0.5.1- BtnY8oBJJ5FGnsoQaqbvOm.log ):
cabal: Entering directory '/var/folders/dy/q51p3v595kbd8_wclmt80v700000gn/T/cabal-tmp-20742/HCodecs- 0.5.1'
Configuring HCodecs-0.5.1...
clang: warning: argument unused during compilation: '-nopie' [- Wunused-command-line-argument]
Preprocessing library for HCodecs-0.5.1..
Building library for HCodecs-0.5.1..
<command line>: cannot satisfy -package-id random-1.1- 7T1TXpwb46H1j0av1OnVaD
(use -v for more information)
cabal: Leaving directory '/var/folders/dy/q51p3v595kbd8_wclmt80v700000gn/T/cabal-tmp-20742/HCodecs- 0.5.1'
Failed to install Stream-0.4.7.2
Build log ( /Users/Mo/.cabal/logs/ghc-8.4.3/Stream-0.4.7.2- ES6rey5IgWg9tsXDghlP7Y.log ):
cabal: Entering directory '/var/folders/dy/q51p3v595kbd8_wclmt80v700000gn/T/cabal-tmp-20743/Stream- 0.4.7.2'
Warning: Stream.cabal:6:4: Tabs used as indentation at 6:4, 12:4, 13:4, 14:4,
15:4, 16:4, 17:4
Configuring Stream-0.4.7.2...
clang: warning: argument unused during compilation: '-nopie' [- Wunused-command-line-argument]
Preprocessing library for Stream-0.4.7.2..
Building library for Stream-0.4.7.2..
<command line>: cannot satisfy -package-id QuickCheck-2.11.3- 4Q6LQ7mN6Tj8otrLuHN0se
(use -v for more information)
cabal: Leaving directory '/var/folders/dy/q51p3v595kbd8_wclmt80v700000gn/T/cabal-tmp-20743/Stream- 0.4.7.2'
cabal: Error: some packages failed to install:
Euterpea-2.0.6-LLo28S848YneLemh6QUkK depends on Euterpea-2.0.6 which failed to
install.
HCodecs-0.5.1-BtnY8oBJJ5FGnsoQaqbvOm failed during the building phase. The
exception was:
ExitFailure 1
Stream-0.4.7.2-ES6rey5IgWg9tsXDghlP7Y failed during the building phase. The
exception was:
ExitFailure 1
arrows-0.4.4.2-GLke2GgDEro6Tzj3MGmTOB depends on arrows-0.4.4.2 which failed
to install.
Edit 3
It has been suggested below that multiple packages are botched and that I should try re-installing all of them (in a single command, i.e. cabal install random tf-random QuickCheck Euterpea --force-reinstalls.
However, if I write cabal install random tf-random QuickCheck Euterpea --force-reinstalls I receive the following code:
clang: warning: argument unused during compilation: '-nopie' [- Wunused-command-line-argument]
Resolving dependencies...
Warning: The following packages are likely to be broken by the reinstalls:
QuickCheck-2.11.3
Continuing even though the plan contains dangerous reinstalls.
Downloading erf-2.0.0.0...
Configuring random-1.1...
Configuring erf-2.0.0.0...
Building random-1.1...
Building erf-2.0.0.0...
Installed erf-2.0.0.0
Installed random-1.1
Downloading tf-random-0.5...
Configuring tf-random-0.5...
Building tf-random-0.5...
Failed to install tf-random-0.5
Build log ( /Users/Mo/.cabal/logs/ghc-8.4.3/tf-random-0.5- ADZoyzEXgHe6hyR0Bycce0.log ):
cabal: Entering directory '/var/folders/dy/q51p3v595kbd8_wclmt80v700000gn/T/cabal-tmp-21584/tf- random-0.5'
Configuring tf-random-0.5...
clang: warning: argument unused during compilation: '-nopie' [- Wunused-command-line-argument]
Preprocessing library for tf-random-0.5..
Building library for tf-random-0.5..
<command line>: cannot satisfy -package-id primitive-0.6.4.0- 9k41Y6ToOAE8KXK6VMGV2O
(use -v for more information)
cabal: Leaving directory '/var/folders/dy/q51p3v595kbd8_wclmt80v700000gn/T/cabal-tmp-21584/tf- random-0.5'
cabal: Error: some packages failed to install:
Euterpea-2.0.6-87WYqltNL8w8teqXOsc4TL depends on Euterpea-2.0.6 which failed
to install.
HCodecs-0.5.1-DrGKEnNk6EBHti2goL6KP5 depends on HCodecs-0.5.1 which. failed to
install.
QuickCheck-2.12.6.1-KuXpgimNOXzF2SmGPEs5LR depends on QuickCheck- 2.12.6.1
which failed to install.
Stream-0.4.7.2-FedzVSwUnWMDxlzmPNWt7x depends on Stream-0.4.7.2 which failed
to install.
arrows-0.4.4.2-EGvZPpby4BcD99TcXDoCg4 depends on arrows-0.4.4.2 which. failed
to install.
tf-random-0.5-ADZoyzEXgHe6hyR0Bycce0 failed during the building phase. The
exception was:
ExitFailure 1
What can I do to install Euterpea?
Installing the Euterpea package
This answer uses LTS 12.26 as I've verified it works, but this should work for most LTS releases (see bottom of step 2 for details).
Make a new Stack project:
stack new euter-test
cd euter-test
Edit stack.yaml and set the LTS to 12.26 and extra-deps to specify the versions of packages that aren't present in the LTS but are present on Hackage:
resolver: lts-12.26
...
extra-deps:
- Euterpea-2.0.6
- PortMidi-0.1.6.1
- arrows-0.4.4.2
- Stream-0.4.7.2
- lazysmallcheck-0.6
The errors you were getting on the Stack install ("PortMidi must match ==0.1.6.1, but the stack configuration has no specified version") indicate that a package you're using requires a particular version of a library, but the package repository (LTS snapshot) doesn't contain that library, so you need to specify it explicitly. Stack then prints which library and version is missing, so you can just keep trying stack build and adding the libraries until the build succeeds.
We use LTS 12.26 here, but by adding the extra-deps packages as described above, you should be able to get it working on any LTS.
Edit package.yaml and add Euterpea to the list of dependencies:
dependencies:
...
- Euterpea
A simple test in app/Main.hs:
module Main where
import Euterpea
main :: IO ()
main = play $ c 4 qn
Run stack build:
lazysmallcheck-0.6: download
heap-1.0.4: download
heap-1.0.4: configure
HCodecs-0.5.1: download
PortMidi-0.1.6.1: download
heap-1.0.4: build
lazysmallcheck-0.6: configure
lazysmallcheck-0.6: build
HCodecs-0.5.1: configure
HCodecs-0.5.1: build
PortMidi-0.1.6.1: configure
heap-1.0.4: copy/register
lazysmallcheck-0.6: copy/register
PortMidi-0.1.6.1: build
Stream-0.4.7.2: download
Stream-0.4.7.2: configure
Stream-0.4.7.2: build
Stream-0.4.7.2: copy/register
PortMidi-0.1.6.1: copy/register
arrows-0.4.4.2: download
arrows-0.4.4.2: configure
arrows-0.4.4.2: build
arrows-0.4.4.2: copy/register
HCodecs-0.5.1: copy/register
Euterpea-2.0.6: download
Euterpea-2.0.6: configure
Euterpea-2.0.6: build
Euterpea-2.0.6: copy/register
Building all executables for `euter' once. After a successful build of all of them, only specified executables will be rebuilt.
euter-0.1.0.0: configure (lib + exe)
Configuring euter-0.1.0.0...
euter-0.1.0.0: build (lib + exe)
Preprocessing library for euter-0.1.0.0..
Building library for euter-0.1.0.0..
[1 of 2] Compiling Lib ( src/Lib.hs, .stack-work/dist/x86_64-linux/Cabal-2.2.0.1/build/Lib.o )
[2 of 2] Compiling Paths_euter ( .stack-work/dist/x86_64-linux/Cabal-2.2.0.1/build/autogen/Paths_euter.hs, .stack-work/dist/x86_64-linux/Cabal-2.2.0.1/build/Paths_euter.o )
Preprocessing executable 'euter-exe' for euter-0.1.0.0..
Building executable 'euter-exe' for euter-0.1.0.0..
[1 of 2] Compiling Main ( app/Main.hs, .stack-work/dist/x86_64-linux/Cabal-2.2.0.1/build/euter-exe/euter-exe-tmp/Main.o )
[2 of 2] Compiling Paths_euter ( .stack-work/dist/x86_64-linux/Cabal-2.2.0.1/build/euter-exe/autogen/Paths_euter.hs, .stack-work/dist/x86_64-linux/Cabal-2.2.0.1/build/euter-exe/euter-exe-tmp/Paths_euter.o )
Linking .stack-work/dist/x86_64-linux/Cabal-2.2.0.1/build/euter-exe/euter-exe ...
euter-0.1.0.0: copy/register
Installing library in <...>
Installing executable euter-exe in <...>
Registering library for euter-0.1.0.0..
Running the executable produced by the project should emit a tone if you're running a MIDI synthesiser:
stack exec euter-test-exe
Troubleshooting
If you get an error like *** Exception: No MIDI outputs!, then you're not running a MIDI synthesiser (see below). Make sure you run it in the background (eg. in another terminal).
If you don't get an error but there's no audio output, try running devices in GHCI to see what outputs are available, and then use playDev x instead of play, where x is the OutputDeviceID of the synth input port. Eg:
> devices
Input devices:
InputDeviceID 1 Midi Through Port-0
Output devices:
OutputDeviceID 0 Midi Through Port-0
OutputDeviceID 2 Synth input port (25952:0)
> playDev 2 $ c 4 qn
If you run devices and don't see any synth input ports, but you have fluidsynth running in the background, then you might need to restart ghci and try again.
Running a MIDI synthesiser
Here's a quick step-by-step to get Fluidsynth running on Debian (with guesses at a Mac setup along the way).
Install fluidsynth:
On Debian this is sudo apt install fluidsynth, on mac it could be brew install fluidsynth - there's quite a few articles on how to do this, just google it if in doubt.
Run fluidsynth:
On Debian using ALSA this is
fluidsynth -s -a alsa -m alsa_seq /usr/share/sounds/sf2/FluidR3_GM.sf2
Instructing fluidsynth to run in server mode, use alsa as the audio driver and alsa_seq as the MIDI driver, and use the soundfont FluidR3_GM.sf2 (should be installed as part of the fluidsynth install).
On Mac, it seems like the correct commandline is:
fluidsynth -s -a coreaudio -m coremidi /usr/share/sounds/sf2/FluidR3_GM.sf2
If you can't find the FluidR3_GM.sf2 file then it's likely it's been installed in a different location. As a last resort, you can just download a soundfont file and use that rather than the one provided by FluidSynth.
After running this, you should be given a prompt and maybe a few warnings, and fluidsynth will be running. Make sure it's running before using Euterpea, and keep it running while using Euterpea.

Understanding `Makevars` for linking to external C library in R package

I am working on a package which includes C code from third-party library (SUNDIALS). The package compiles and works (i.e., is able to solve a test ODE) with the following Makevars file performing static linking
CXX=clang++
PKG_CPPFLAGS = -I../inst/include
PKG_LDFLAGS = /usr/local/lib
PKG_LIBS= $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) $(PKG_LDFLAGS)/libsundials_cvode.a $(PKG_LDFLAGS)/libsundials_nvecserial.a
However, a slightly modified version (based on the example in R-Exts, i.e. -
PKG_LIBS = -L$(XML_DIR)/lib -lxml2) of Makevars (below) fails
CXX=clang++
PKG_CPPFLAGS = -I../inst/include
PKG_LDFLAGS = /usr/local/lib
PKG_LIBS= $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) -L$(PKG_LDFLAGS) -lsundials_cvode -lsundials_nvecserial -lm
fails with the following error message.
Error: package or namespace load failed for ‘Rcppsbmod’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcppsbmod/libs/Rcppsbmod.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcppsbmod/libs/Rcppsbmod.so, 6): Library not loaded: libsundials_cvode.3.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcppsbmod/libs/Rcppsbmod.so
Reason: image not found
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcppsbmod’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcppsbmod’
Exited with status 1.
I am not sure why it is looking for the libraries in another location when I am specifying PKG_LDFLAGS as /usr/local/lib.
As an aside, the test example which comes which the SUNDIALS package compiles and works with the following command
gcc -Wall cvRoberts_dns.c -o cvRoberts_dns.exe -I/usr/local/include -L/usr/local/lib/ -lsundials_cvode -lsundials_nvecserial -lm
So, I know that the library is installed properly and correct files (for linking) are available at /usr/local/lib location.
The entire package source code can be found at - https://github.com/sn248/Rcppsbmod
Any help or guidance will be highly appreciated!
System-wide dynamic linking, as in your second use case which fails, requires the cooperation of the dynamic linker on your system.
That means after build and copyring the libraries to /usr/local/lib you must typically run sudo ldconfig to update the linker cache.
You can check if the libraries are know by grep'ing through the output of ldconfig -p. On my system, no sundials:
edd#rob:~$ ldconfig -p | grep sundials
edd#rob:~$
Relatedly you can (locally) use different directories by declaring them in
/etc/ld.so.conf.d/somefile.conf -- but that is of course not portable and would not help you with a package designated for CRAN.
The use of static libraries you build as part of your package as in your first example would work as it does not require any system assistance. It just takes longer the build the libraries each time.
I am fighting with similar issues, c.f. Runtime linking R-extension on MacOS. My current workaround is to set the rpath at compile time. In your case that would mean:
CXX=clang++
PKG_CPPFLAGS = -I../inst/include
PKG_LDFLAGS = /usr/local/lib
PKG_LIBS= $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) -L$(PKG_LDFLAGS) -lsundials_cvode -lsundials_nvecserial -lm -Wl,-rpath,$(PKG_LDFLAGS)
However, this does not fix your problems. Comparing the error messages I see one difference: In your case the library libsundials_cvode.3.dylib is not found, while in my case it is #rpath/libaf.3.dylib. This means that the library you installed identifies itself as libsundials_cvode.3.dylib. You can check this with
$ otool -L /usr/local/lib/libsundials_cvode.3.dylib
/usr/local/lib/libsundials_cvode.3.dylib:
/usr/local/opt/sundials/lib/libsundials_cvode.3.dylib (compatibility version 3.0.0, current version 3.1.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.0.0)
In your case the second output line should not contain an absolute path but only the basename of the library. My installation uses brew, which typically uses absolute paths as library names. In some trivial tests I had no problem with linking an R extension with these libraries.
I see several possibilities:
Try SUNDIAL from brew.
Adjust the library path in your installed libraries with
install_name_tool -id /usr/local/lib/libsundials_cvode.3.dylib /usr/local/lib/libsundials_cvode.3.dylib
to use absolute paths.
Adjust the library path in your installed libraries with
install_name_tool -id '#rpath/libsundials_cvode.3.dylib' /usr/local/lib/libsundials_cvode.3.dylib
and set rpath as above.
Adjust the name of the library your R extension is looking for with this addition to Makevars
all: $(SHLIB)
#if command -v install_name_tool; then install_name_tool -change libsundials_cvode.3.dylib /usr/local/lib/libsundials_cvode.3.dylib $(SHLIB); fi

ghc-modi and cabal version

(Haskell newbie here)
I'm trying to configure HaskForce plugin into IntelliJ IDEA, configured "ghc-mod" with "legacy-interactive" in "GHC Modi" Flags. The root problem seems to be related to cabal version, although when I try autocompleting on any Haskell symbol, I get this:
ghc-modi error
Unable to parse problems from ghc-modi: cabal-helper-wrapper.exe: ghc: readCreateProcess: does not exist (No such file or directory)
ghc-mod: readCreateProcess: C:\ACME\projects\htest\.cabal-sandbox\cabal-helper-0.5.3.0-553kah86RQN6BuDX6XLBiX\cabal-helper-wrapper.exe "C:\\ACME\\projects\\htest" "C:\\ACME\\projects\\htest\\dist" (exit 1): failed
When I run this last command (C:\ACME\projects\htest\.cabal-sandbox\cabal-helper-0.5.3.0-553kah86RQN6BuDX6XLBiX\cabal-helper-wrapper.exe "C:\\ACME\\projects\\htest" "C:\\ACME\\projects\\htest\\dist"), it tries to install cabal 1.18:
cabal-helper-wrapper.exe: Installing Cabal version 1.18.1.3 failed.
I already have cabal, of version 1.22 (installed via Haskell Platform v7.10.2-a, released recently in August).
Is there any way to work around this issue (i.e. still use ghc-mod / ghc-modi)?
Updated Haskforce plugin (0.3-beta24) seems to work correctly with following ghc-mod:
ghc-mod version 5.4.0.0 compiled by GHC 7.10.2

Fail to install cairo haskell bindings on windows

I am trying to install cairo-0.12.4 Haskell package on Windows 7. I first downloaded and unpacked Gtk+2 and added its bin subdir to PATH. I then tried to run cabal with extra libs and includes:
cabal --extra-lib-dirs="d:\Program Files (x86)\Gtk+\lib"
--extra-include-dirs="d:\Program Files (x86)\Gtk+\include" install
But I got the following error
Reading available packages...
Choosing modular solver.
Resolving dependencies...
Ready to install cairo-0.12.4
Waiting for install task to finish...
Extracting
C:\Users\abailly\AppData\Roaming\cabal\packages\hackage.haskell.org\cairo\0.12.4\cairo-0.12.4.tar.gz
to C:\Users\abailly\AppData\Local\Temp\cairo-0.12.4-2368...
Updating cairo.cabal with the latest revision from the index.
creating
C:\Users\abailly\AppData\Local\Temp\cairo-0.12.4-2368\cairo-0.12.4\dist\setup
creating
C:\Users\abailly\AppData\Local\Temp\cairo-0.12.4-2368\cairo-0.12.4\dist
creating
C:\Users\abailly\AppData\Local\Temp\cairo-0.12.4-2368\cairo-0.12.4\dist\setup
d:\Program Files (x86)\Haskell Platform\2012.2.0.0\bin\ghc.exe --make C:\Users\abailly\AppData\Local\Temp\cairo-0.12.4-2368\cairo-
0.12.4\Setup.hs -o C:\Users\abailly\AppData\Local\Temp\cairo-0.12.4-2368\cairo-0.12.4\dist\setup\setup.exe -odir C:\Users\abailly\
AppData\Local\Temp\cairo-0.12.4-2368\cairo-0.12.4\dist\setup -hidir C:\Users\abailly\AppData\Local\Temp\cairo-0.12.4-2368\cairo-0.
12.4\dist\setup -i -iC:\Users\abailly\AppData\Local\Temp\cairo-0.12.4-2368\cairo-0.12.4 -package Cabal-1.14.0
[1 of 2] Compiling SetupWrapper ( C:\Users\abailly\AppData\Local\Temp\cairo-0.12.4-2368\cairo-0.12.4\SetupWrapper.hs, C:\Users
\abailly\AppData\Local\Temp\cairo-0.12.4-2368\cairo-0.12.4\dist\setup\SetupWrapper.o )
[2 of 2] Compiling Main ( C:\Users\abailly\AppData\Local\Temp\cairo-0.12.4-2368\cairo-0.12.4\Setup.hs, C:\Users\abaill
y\AppData\Local\Temp\cairo-0.12.4-2368\cairo-0.12.4\dist\setup\Main.o )
Linking C:\Users\abailly\AppData\Local\Temp\cairo-0.12.4-2368\cairo-0.12.4\dist\setup\setup.exe ...
C:\Users\abailly\AppData\Local\Temp\cairo-0.12.4-2368\cairo-0.12.4\dist\setup\setup.exe
configure --verbose=2 --ghc --prefix=C:\Users\abailly\AppData\Roaming\cabal
--user --flags=cairo_svg --flags=cairo_ps --flags=cairo_pdf
--extra-include-dirs=D:\Program Files (x86)\Gtk+\include
--extra-lib-dirs=D:\Program Files (x86)\Gtk+\lib --constraint=mtl ==2.1.2
--constraint=bytestring ==0.9.2.1 --constraint=base ==4.5.0.0
--constraint=array ==0.4.0.0 --disable-tests --disable-benchmarks
[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.exe ...
Configuring cairo-0.12.4...
Flags chosen: cairo_svg=True, cairo_ps=True, cairo_pdf=True
Dependency array ==0.4.0.0: using array-0.4.0.0
Dependency base ==4.5.0.0: using base-4.5.0.0
Dependency bytestring ==0.9.2.1: using bytestring-0.9.2.1
Dependency mtl ==2.1.2: using mtl-2.1.2
Dependency cairo-pdf -any: using version 1.10.2
Dependency cairo-ps -any: using version 1.10.2
Dependency cairo-svg -any: using version 1.10.2
Dependency cairo >=1.2.0: using version 1.10.2
Using Cabal-1.14.0 compiled by ghc-7.4
Using compiler: ghc-7.4.1
Using install prefix: C:\Users\abailly\AppData\Roaming\cabal
Binaries installed in: C:\Users\abailly\AppData\Roaming\cabal\bin
Libraries installed in:
C:\Users\abailly\AppData\Roaming\cabal\cairo-0.12.4\ghc-7.4.1
Private binaries installed in:
C:\Users\abailly\AppData\Roaming\cabal\cairo-0.12.4
Data files installed in: C:\Users\abailly\AppData\Roaming\cabal\cairo-0.12.4
Documentation installed in:
C:\Users\abailly\AppData\Roaming\cabal\doc\cairo-0.12.4
Using alex version 3.0.1 found on system at: d:\Program Files (x86)\Haskell
Platform\2012.2.0.0\lib\extralibs\bin\alex.exe
Using ar found on system at: d:\Program Files (x86)\Haskell
Platform\2012.2.0.0\mingw\bin\ar.exe
No c2hs found
Using cpphs version 1.16 found on system at:
c:\Users\abailly\AppData\Roaming\cabal\bin\cpphs.exe
No ffihugs found
Using gcc version 4.5.2 found on system at: d:\Program Files (x86)\Haskell
Platform\2012.2.0.0\mingw\bin\gcc.exe
Using ghc version 7.4.1 found on system at: d:\Program Files (x86)\Haskell
Platform\2012.2.0.0\bin\ghc.exe
Using ghc-pkg version 7.4.1 found on system at: d:\Program Files (x86)\Haskell
Platform\2012.2.0.0\bin\ghc-pkg.exe
No greencard found
Using gtk2hsC2hs version 0.13.6 found on system at:
c:\Users\abailly\AppData\Roaming\cabal\bin\gtk2hsC2hs.exe
Using gtk2hsHookGenerator found on system at:
c:\Users\abailly\AppData\Roaming\cabal\bin\gtk2hsHookGenerator.exe
Using gtk2hsTypeGen found on system at:
c:\Users\abailly\AppData\Roaming\cabal\bin\gtk2hsTypeGen.exe
Using haddock version 2.10.0 found on system at: d:\Program Files
(x86)\Haskell Platform\2012.2.0.0\bin\haddock.exe
Using happy version 1.18.9 found on system at: d:\Program Files (x86)\Haskell
Platform\2012.2.0.0\lib\extralibs\bin\happy.exe
No hmake found
Using hpc version 0.6 found on system at: d:\Program Files (x86)\Haskell
Platform\2012.2.0.0\bin\hpc.exe
Using hsc2hs version 0.67 found on system at: d:\Program Files (x86)\Haskell
Platform\2012.2.0.0\bin\hsc2hs.exe
Using hscolour version 1.20 found on system at:
c:\Users\abailly\AppData\Roaming\cabal\bin\HsColour.exe
No hugs found
No jhc found
Using ld found on system at: d:\Program Files (x86)\Haskell
Platform\2012.2.0.0\mingw\bin\ld.exe
No lhc found
No lhc-pkg found
No nhc98 found
Using pkg-config version 0.26 found on system at: d:\Program Files
(x86)\Gtk+\bin\pkg-config.exe
Using ranlib found on system at: d:\Program Files (x86)\Haskell
Platform\2012.2.0.0\mingw\bin\ranlib.exe
Using strip found on system at: d:\Program Files (x86)\Haskell
Platform\2012.2.0.0\mingw\bin\strip.exe
Using tar found on system at: D:\Program Files (x86)\Git\bin\tar.exe
No uhc found
d:\Program Files (x86)\Gtk+\bin\pkg-config.exe --modversion cairo-pdf
d:\Program Files (x86)\Gtk+\bin\pkg-config.exe --modversion cairo-ps
d:\Program Files (x86)\Gtk+\bin\pkg-config.exe --modversion cairo-svg
d:\Program Files (x86)\Gtk+\bin\pkg-config.exe --modversion cairo
setup.exe: Missing dependencies on foreign libraries:
* Missing C libraries: z, cairo
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.
Failed to install cairo-0.12.4
cabal.exe: Error: some packages failed to install:
Chart-0.16 depends on cairo-0.12.4 which failed to install.
cairo-0.12.4 failed during the configure step. The exception was:
ExitFailure 1
splot-0.3.8 depends on cairo-0.12.4 which failed to install.
When I try to install cairo directly, I got the following:
d:\Program Files (x86)\Gtk+\bin\pkg-config.exe --modversion cairo-pdf
d:\Program Files (x86)\Gtk+\bin\pkg-config.exe --modversion cairo-ps
d:\Program Files (x86)\Gtk+\bin\pkg-config.exe --modversion cairo-svg
d:\Program Files (x86)\Gtk+\bin\pkg-config.exe --modversion cairo
setup.exe: Missing dependencies on foreign libraries:
* Missing C libraries: z, cairo
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.
Failed to install cairo-0.12.4
World file is already up to date.
cabal.exe: Error: some packages failed to install:
cairo-0.12.4 failed during the configure step. The exception was:
ExitFailure 1
I am clueless...
If you read the error message:
* Missing C libraries: z, cairo
It is saying you need to install the libraries (and header files) for the libraries libz and cairo. On *nix systems this usually means just installing the -dev versions of these packages with your package manager. On windows I assume you'd download the source version of the library and install.
I got this problem. In my case it was a mismatch between a 64-bit ghc and a 32-bit cairo dll
I moved the Gtk+ library to D:\soft\gtk+\ and everything runs fine. The path to Gtk+ contain space which does not seem to be correctly interpreted by cabal/ghc, although I double-quoted it:
--extra-lib-dirs="d:\Program Files (x86)\Gtk+\lib"
Solution: Put gtk+ in a space-free location.
Update: Now, it fails to install Chart-0.16 with an even more cryptic error:
Loading package Win32-2.2.2.0 ... linking ... done.
Loading package array-0.4.0.0 ... linking ... done.
Loading package deepseq-1.3.0.0 ... linking ... done.
Loading package old-locale-1.0.0.4 ... linking ... done.
Loading package time-1.4 ... linking ... done.
Loading package containers-0.4.2.1 ... linking ... done.
Loading package transformers-0.3.0.0 ... linking ... done.
Loading package data-accessor-0.2.2.3 ... linking ... done.
Loading package pretty-1.1.1.0 ... linking ... done.
Loading package template-haskell ... linking ... done.
Loading package utility-ht-0.0.8 ... linking ... done.
Loading package data-accessor-template-0.2.1.10 ... linking ... done.
Loading package colour-2.3.3 ... linking ... done.
Loading package mtl-2.1.2 ... linking ... done.
*** gcc:
"D:\Program Files (x86)\Haskell Platform\2012.2.0.0\lib/../mingw/bin/gcc.exe" "-fno-stack-protector" "-Wl,--hash-size=31" "-Wl,--r
educe-memory-overheads" "-LC:\Users\abailly\AppData\Roaming\cabal\cairo-0.12.4\ghc-7.4.1" "-Ld:/soft/Gtk+/lib" "--print-file-name"
"libz.dll"
*** gcc:
"D:\Program Files (x86)\Haskell Platform\2012.2.0.0\lib/../mingw/bin/gcc.exe" "-fno-stack-protector" "-Wl,--hash-size=31" "-Wl,--r
educe-memory-overheads" "-LC:\Users\abailly\AppData\Roaming\cabal\cairo-0.12.4\ghc-7.4.1" "-Ld:/soft/Gtk+/lib" "--print-file-name"
"libcairo-2.dll"
Loading package cairo-0.12.4 ... d:\Program Files (x86)\Haskell Platform\2012.2.0.0\bin\ghc.exe returned
ExitFailure 1
Failed to install Chart-0.16
cabal.exe: Error: some packages failed to install:
Chart-0.16 failed during the building phase. The exception was:
ExitFailure 1
splot-0.3.8 depends on Chart-0.16 which failed to install.
I suspect this is due to a linking error as the compilation runs fine when I execute the following command which is what cabal outputs in debug mode:
"D:\\Program Files (x86)\\Haskell Platform\\2012.2.0.0\\bin\\ghc.exe"
"--make" "-v" "-fbuilding-cabal-package" "-O" "-odir" "dist\\build"
"-hidir" "dist\\build" "-stubdir" "dist\\build" "-i" "-idist\\build"
"-i." "-idist\\build\\autogen" "-Idist\\build\\autogen"
"-Idist\\build" "-optP-include"
"-optPdist\\build\\autogen\\cabal_macros.h" "-package-name"
"Chart-0.16" "-hide-all-packages" "-package-conf"
"dist\\package.conf.inplace" "-package-id"
"array-0.4.0.0-3cf1bc3f5cd0078adea24752c18081b9" "-package-id"
"base-4.5.0.0-597748f6f53a7442bcae283373264bb6" "-package-id"
"cairo-0.12.4-f04021ea456c901e8d05395a31f7a861" "-package-id"
"colour-2.3.3-4eaa610bb6d825a7334e1b3de448f6c0" "-package-id"
"data-accessor-0.2.2.3-5477c48e3478339fdff299c536a033c6" "-package-id"
"data-accessor-template-0.2.1.10-28ee96821fd908880f3a49417c4da548"
"-package-id" "mtl-2.1.2-7ec8bbada2af74b49c6e4aeea2889fdc"
"-package-id" "old-locale-1.0.0.4-29bd50ed2bb4a20928338f52e4ab1b71"
"-package-id" "time-1.4-01d7bf22d87e70510fe9ee4c4434b3ab"
"-XHaskell98" "Graphics.Rendering.Chart"
"Graphics.Rendering.Chart.Types" "Graphics.Rendering.Chart.Renderable"
"Graphics.Rendering.Chart.Axis"
"Graphics.Rendering.Chart.Axis.Floating"
"Graphics.Rendering.Chart.Axis.Indexed"
"Graphics.Rendering.Chart.Axis.Int"
"Graphics.Rendering.Chart.Axis.LocalTime"
"Graphics.Rendering.Chart.Axis.Types"
"Graphics.Rendering.Chart.Axis.Unit" "Graphics.Rendering.Chart.Layout"
"Graphics.Rendering.Chart.Legend" "Graphics.Rendering.Chart.Simple"
"Graphics.Rendering.Chart.Simple.Internal"
"Graphics.Rendering.Chart.Grid" "Graphics.Rendering.Chart.Plot"
"Graphics.Rendering.Chart.Plot.Types"
"Graphics.Rendering.Chart.Plot.Annotation"
"Graphics.Rendering.Chart.Plot.AreaSpots"
"Graphics.Rendering.Chart.Plot.Bars"
"Graphics.Rendering.Chart.Plot.Candle"
"Graphics.Rendering.Chart.Plot.ErrBars"
"Graphics.Rendering.Chart.Plot.FillBetween"
"Graphics.Rendering.Chart.Plot.Hidden"
"Graphics.Rendering.Chart.Plot.Lines"
"Graphics.Rendering.Chart.Plot.Pie"
"Graphics.Rendering.Chart.Plot.Points"
"Graphics.Rendering.Chart.SparkLine" "-hide-package" "monads-tf"
I am even more puzzled...
Update (2): When I run cabal install > out 2>&1 it succeeds!

Resources