I'm trying to build hCsound-0.4.2 on Debian-linux machine, it seems, that since 2012 (latest version) there were some changes in csound.h file, but I'm not sure.
When trying cabal install hcsound I get following
Configuring hCsound-0.4.2...
cabal: Missing dependency on a foreign library:
* Missing (or bad) header file: csound.h
I have libcsound64-dev of version 1:6.02~dfsg-2, which installs csound.h into /usr/include/csound/, so I did following:
cabal unpack hcsound
cd hCsound-0.4.2
cabal configure --extra-include-dirs=/usr/include/csound
cabal build
In that case, configuring is done nicely, but I get errors on build stage:
Preprocessing library hCsound-0.4.2...
c2hs: Error limit of 20 errors has been reached.
src/Sound/Csound/Foreign.chs:1224: (column 14) [ERROR] >>> Unknown identifier!
Cannot find a definition for `csoundSetControlChannelParams' in the header file.
src/Sound/Csound/Foreign.chs:1118: (column 11) [ERROR] >>> Unknown identifier!
Cannot find a definition for `CsoundChannelListEntry' in the header file.
src/Sound/Csound/Foreign.chs:1113: (column 22) [ERROR] >>> Unknown identifier!
Cannot find a definition for `CsoundChannelListEntry' in the header file.
src/Sound/Csound/Foreign.chs:1111: (column 23) [ERROR] >>> Unknown identifier!
Cannot find a definition for `CsoundChannelListEntry' in the header file.
...
Some of the mentioned function names are present in /usr/include/csound/csound.h, some are not. Is there a possibility that c2hs processes wrong header?
What can be done to find out possible reasons for incorrect (?) behaviour? Has someone experience of building hCsound recently?
My intention is to use the library go produce sound output from Haskell program, so if anyone suggests better solution, it would also be great. I already failed to install haskore-supercollider, I have haskore package, but did not managed to get if it can produce sound in real time.
Related
I try to build qhull from hackage and get the error
fatal error: qhull_ra.h: No such file or directory
2 | #include "qhull_ra.h"
`gcc' failed in phase `C Compiler'. (Exit code: 1)
The file is in the Cdir and the relevant parts of the cabal file are
include-dirs: ./Cdir
C-sources: ./Cdir/libqhull_r.c
, ./Cdir/geom_r.c
, ...
The file qhull_ra.h is not listed as C-sources, because it is a header file.
I did not write the code and are not experienced with including C code into haskell packages. The failure occurs sometimes and sometimes not, but I cannot tell when. What is wrong? I want to upload the package (authorized by the author); what do I have to change to make it compile with cabal install?
I've noticed that cabal install is (since recently) much more strict than cabal build when looking for files. So, I believe here the problem is that your include files are not being picked up by cabal.
I think you can fix that by listing your header files in a includes: field. So at least:
include-dirs: Cdir
includes: qhull_ra.h
c-sources: Cdir/libqhull_r.c
, ...
I saw a possible solution for an utf8 problem here: Read file with UTF-8 in Haskell as IO String. I wanted to try that out, but I'm having a problem I can't resolve.
When I run the command cabal v2-install encoding --lib almost everything works but fails in the end with these lines:
[8 of 8] Compiling Main ( /tmp/cabal-install.-169090/dist-newstyle/tmp/src-169090/encoding-0.8.5/dist/setup/setup.hs, /tmp/cabal-install.-169090/dist-newstyle/tmp/src-169090/encoding-0.8.5/dist/setup/Main.o )
Linking /tmp/cabal-install.-169090/dist-newstyle/tmp/src-169090/encoding-0.8.5/dist/setup/setup ...
Configuring encoding-0.8.5...
Preprocessing library for encoding-0.8.5..
arithmetic overflow
cabal: Failed to build encoding-0.8.5. See the build log above for details.
If I add --verbose=3 to the command line the last few output lines are
creating dist/build/Data
creating dist/build/Data/Encoding
Data/Encoding/ISO88592.hs generated from mapping
Data/Encoding/ISO88592.mapping
arithmetic overflow
CallStack (from HasCallStack):
die', called at ./Distribution/Client/ProjectOrchestration.hs:1041:55 in main:Distribution.Client.ProjectOrchestration
cabal: Failed to build
encoding-0.8.5-aa69e7dd952ebb6bcbe7b0947ad7f87838ecbfac327d0aa020c7f7f0f19b3e18.
I'm using cabal 3.2 and GHC 8.10.2 under Linux Mint 20.
I've looked "all over the place" for a solution, and the only trace of something similar is that the error is confirmed in Gentoo's Bugzilla.
Any help is appreciated!
This is apparently a bug in the library encoding (I could reproduce it), and there's a fix available as a PR on the source repository:
https://github.com/dmwit/encoding/pull/11
I'm trying to cabal install binary-strict and I get this error:
src/Data/Binary/BitBuilder.hs:205:37:
Ambiguous occurrence `unsafePerformIO'
It could refer to either `Foreign.unsafePerformIO',
imported from `Foreign' at src/Data/Binary/BitBuilder.hs:38:1-14
or `System.IO.Unsafe.unsafePerformIO',
imported from `System.IO.Unsafe' at src/Data/Binary/BitBuilder.hs:42:26-40
(and originally defined in `GHC.IO')
Failed to install binary-strict-0.4.8.1
cabal: Error: some packages failed to install:
binary-strict-0.4.8.1 failed during the building phase. The exception was:
ExitFailure 1
I'm running ghc 7.6.3. If it's relevant, I have binary-0.7.2.3 installed too.
As written, binary-strict only works for base >= 4.7. GHC 7.6.3 uses base = 4.6.* so it will not work. You should file a bug with the maintainer and work around the issue by adding hiding (unsafePerformIO) to the import Foreign line of the file in question.
I only just found out about this. It is now fixed. Also I have listed the git repo in the package details so you can now raise issues and I will know about them. Thanks to Thomas for suggesting the fix.
There have been multiple tricks in the past to compile haskell libraries that are hard to find.
The webkitgtk3 library fails to build.
ERROR:
cabal install webkitgtk3
Resolving dependencies...
[1 of 2] Compiling SetupWrapper ( /tmp/webkitgtk3-0.12.5-28865/webkitgtk3-0.12.5/SetupWrapper.hs, /tmp/webkitgtk3-0.12.5-28865/webkitgtk3-0.12.5/dist/setup/SetupWrapper.o )
/tmp/webkitgtk3-0.12.5-28865/webkitgtk3-0.12.5/SetupWrapper.hs:118:28: Warning:
In the use of `configCompiler'
(imported from Distribution.Simple.Configure):
Deprecated: "'configCompiler' is deprecated. Use 'configCompilerEx' instead."
[2 of 2] Compiling Main ( /tmp/webkitgtk3-0.12.5-28865/webkitgtk3-0.12.5/Setup.hs, /tmp/webkitgtk3-0.12.5-28865/webkitgtk3-0.12.5/dist/setup/Main.o )
Linking /tmp/webkitgtk3-0.12.5-28865/webkitgtk3-0.12.5/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 webkitgtk3-0.12.5...
Building webkitgtk3-0.12.5...
Preprocessing library webkitgtk3-0.12.5...
gtk2hsC2hs: Errors during expansion of binding hooks:
./Graphics/UI/Gtk/WebKit/Types.chs:1100: (column 12) [ERROR]
>>> Unknown identifier!
Cannot find a definition for `WebKitDOMBarInfo' in the header file.
./Graphics/UI/Gtk/WebKit/Types.chs:1865: (column 12) [ERROR]
>>> Unknown identifier!
Cannot find a definition for `WebKitDOMMemoryInfo' in the header file.
Failed to install webkitgtk3-0.12.5
cabal: Error: some packages failed to install:
webkitgtk3-0.12.5 failed during the building phase. The exception was:
ExitFailure 1
Any tips how to solve fix the error?
As mentioned in the comments, it just installed correctly for me, so I can only guess what went wrong on your machine, but the error message you gave does have some clues....
The important lines seem to be here
./Graphics/UI/Gtk/WebKit/Types.chs:1100: (column 12) [ERROR]
>>> Unknown identifier!
Cannot find a definition for `WebKitDOMBarInfo' in the header file.
./Graphics/UI/Gtk/WebKit/Types.chs:1865: (column 12) [ERROR]
>>> Unknown identifier!
Cannot find a definition for `WebKitDOMMemoryInfo' in the header file.
I downloaded the source code for webkitgtk3 by typing in "cabal unpack webkitgtk3" and cd'ing into the subdir. Looking at Graphics/UI/Gtk/WebKit/Types.chs, line 1100, I see the following
{#pointer *WebKitDOMBarInfo as BarInfo foreign newtype #} deriving (Eq,Ord)
Haskell ".chs" files are used to bind Haskell to c header files. This line is telling the compiler build tools to create a data object based on the structure found in the webkit c header file, called WebKitDOMBarInfo.
As few places to check-
Do you have the appropriate header files? On my machine, the WebKitDOMBarInfo structure is defined in a file called /usr/include/webkitgtk-3.0/webkit/WebKitDOMBarInfo.h. (the location may differ on your machine, but the file should have the same basename, WebKitDOMBarInfo.h)
If you have the file, verify that the structure is defined (actually, the struct is called _WebKitDOMBarInfo, and the version without the underscore is a typedef).
Verify that your gtk2hsC2hs is the latest version. This is the program that converts the c header files to haskell code. An older version may get confused by certain features (possibly like the typedef thing). See How to upgrade gtk2hsC2hs? to upgrade to the newest version of gtk2hsC2hs.
Verify that your system is set up properly to find the header files.
Again, because it works for me, I don't know that any of these things will solve the problem, but if you look at these things and post the results here, we can iterate again.
This is the output from cabal install codec-image-devil:
Resolving dependencies...
Configuring Codec-Image-DevIL-0.2.3...
cabal: Missing dependency on a foreign library:
* Missing C library: IL
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.
cabal: Error: some packages failed to install:
Codec-Image-DevIL-0.2.3 failed during the configure step. The exception was:
ExitFailure 1
I tried --extra-include-dirs and --extra-lib-dirs. but they didn't work. so I edited the .cabal in Codec-Image-DevIL-0.2.3.tar.gz. I don't know if I'm even supposed to change that. but it worked for pthread.
I added these two lines:
include-dirs: C:\Users\Rumbold\Documents\libs\IL\include, C:\Users\Rumbold\Documents\libs\pthread\include, .
extra-lib-dirs: C:\Users\Rumbold\Documents\libs\IL\lib, C:\Users\Rumbold\Documents\libs\pthread\lib, .
They are indented so they are in the Library section. I don't know if I got the format for lists right, just something i stumbled upon while googling. The libs and `header files are all in the correct place, I think.
any clue how i can get it to work?
Edit_1:
I got it to work with --extra-include-dirs and --extra-lib-dirs, so I don't need to edit the cabal anymore. but IL still doesn't work. is there a way to find out which files it's looking for?
Wdit_2:
Alright it works. I had to rename DevIL.lib and DevIL.dll to libIL.lib and libIL.dll. (not sure if I had to do both, but that's what I did. also kept them under their old names)
Edit_3:
Getting lots of errors like:
"cabal\Codec-Image-DevIL-0.2.3\ghc-6.12.3/libHSCodec-Image-DevIL-0.2.3.a(DevIL.o):fake:(.text+0x2379):
undefined reference to `ilGetInteger#4'"