Difference between revisions of "Cabal/FAQ"

From HaskellWiki
Jump to navigation Jump to search
(add another common question, without an answer yet)
(8 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
[[Category:FAQ]]
 
[[Category:FAQ]]
  +
  +
Before you continue: Don't miss the other FAQ at http://www.haskell.org/cabal/FAQ.html
  +
 
== What is this hidden package? ==
 
== What is this hidden package? ==
   
Line 7: Line 10:
 
Could not find module `Data.Map': it is a member of package
 
Could not find module `Data.Map': it is a member of package
 
containers-0.1.0.0, which is hidden.
 
containers-0.1.0.0, which is hidden.
  +
</pre>
  +
  +
or
  +
  +
<pre>
  +
Failed to load interface for `GHC.Prim':
  +
it is a member of the hidden package `ghc-prim'
  +
Use -v to see a list of the files searched for.
 
</pre>
 
</pre>
   
 
This is because the package has not been updated for ghc-6.8 which has split the base package into lots of smaller packages. The package needs to be updated to say that it depends on these new split base packages, like containers, process and several others.
 
This is because the package has not been updated for ghc-6.8 which has split the base package into lots of smaller packages. The package needs to be updated to say that it depends on these new split base packages, like containers, process and several others.
   
If you just want to get the package to build, add the missing package names to the build-depends: line in the .cabal file. For example given the above error message we would add the 'containers' package to the build-depends.
+
If you just want to get the package to build, add the missing package names to the build-depends: line in the .cabal file. For example given the above error message we would add the 'containers' package to the build-depends. (Alternatively, you can add the switch --ghc-options="-package hidden-package-name" to cabal.)
   
 
Developers of packages who want to know how to update their package properly so that it will continue to work with old and new compilers should see [[Upgrading_packages]].
 
Developers of packages who want to know how to update their package properly so that it will continue to work with old and new compilers should see [[Upgrading_packages]].
 
== How do I handle extensions? ==
 
If your code uses some of the advanced Haskell extensions, you have a number of options.
 
# If you're distributing via Cabal, you can simply add <code>ghc-options: -fglasgow-exts</code> to your .cabal file.
 
# You can use the <code>OPTIONS_GHC</code> pragma to supply the -fglasgow-exts on a per-file basis (as opposed to in the cabal file which would apply to every file), like thus: <haskell>{-# OPTIONS_GHC -fglasgow-exts #-}</haskell>.
 
# The best way to do it, if you know your users are on GHC 6.8.x are the new LANGUAGE pragmas. ie, each extension has a name, and you only list those which you are using (you can find the list in [http://haskell.org/ghc/docs/latest/html/libraries/Cabal/Distribution-Extension.html Distribution.Extension]). So you can enable only those extensions you are using. Like before, you enable them in the cabal file, mention them like <code>extensions: CPP, ForeignFunctionInterface</code>.
 
#Of course, even better is specifying them in only the file using them. A pragma might look like: <haskell>{-# LANGUAGE CPP, ForeignFunctionInterface #-}</haskell> (You'll probably still want to use the extensions field just to make clear at the top level what extensions the project uses.)
 
   
 
== [Windows] I tried to install a Haskell binding to (some external C library), but I get build errors ==
 
== [Windows] I tried to install a Haskell binding to (some external C library), but I get build errors ==
Line 34: Line 38:
 
* Cabal may also need to find object files that need to be statically linked. Again, a future Cabal release will allow you to specify these during the configure state with switches, but for now try adding <code>extra-lib-dirs: "C:\\Program Files\\My External Library\\lib"</code> or similar.
 
* Cabal may also need to find object files that need to be statically linked. Again, a future Cabal release will allow you to specify these during the configure state with switches, but for now try adding <code>extra-lib-dirs: "C:\\Program Files\\My External Library\\lib"</code> or similar.
 
* Assuming you get your library to compile, you may still need to add DLLs or other resources to your PATH variable to get any programs ''using'' the package to actually run. (But the installer for the external library might have done this for you already.)
 
* Assuming you get your library to compile, you may still need to add DLLs or other resources to your PATH variable to get any programs ''using'' the package to actually run. (But the installer for the external library might have done this for you already.)
  +
  +
== My package repository seems to be in an inconsitent state. What can i do? ==
  +
TODO

Revision as of 06:35, 19 August 2010


Before you continue: Don't miss the other FAQ at http://www.haskell.org/cabal/FAQ.html

What is this hidden package?

You build a package and get a message like:

  Could not find module `Data.Map': it is a member of package
  containers-0.1.0.0, which is hidden.

or

    Failed to load interface for `GHC.Prim':
      it is a member of the hidden package `ghc-prim'
      Use -v to see a list of the files searched for.

This is because the package has not been updated for ghc-6.8 which has split the base package into lots of smaller packages. The package needs to be updated to say that it depends on these new split base packages, like containers, process and several others.

If you just want to get the package to build, add the missing package names to the build-depends: line in the .cabal file. For example given the above error message we would add the 'containers' package to the build-depends. (Alternatively, you can add the switch --ghc-options="-package hidden-package-name" to cabal.)

Developers of packages who want to know how to update their package properly so that it will continue to work with old and new compilers should see Upgrading_packages.

[Windows] I tried to install a Haskell binding to (some external C library), but I get build errors

Packages consisting of 100% Haskell code almost always build perfectly on Windows. However, packages which implement bindings to external C libraries (e.g., OpenSSH, libSDL, etc.) sometimes won't build on Windows without prodding.

  1. Check that the external C library is actually installed on your system. (Cabal does not do this for you.)
  2. Check the package contents, package home page, etc., to see if the author has told you how to get this package to work on Windows.

If those two fail to get you any further, proceed as follows:

  • Cabal probably needs to be able to find header files in order to compile the package. In future there will be some switches for the 'configure' step to allow you to specify the path to these. For now, you'll have to manually hack the Cabal information file to tell Cabal where to look. Try adding a line in the 'library' section saying something like include-dirs: "C:\\Program Files\\My External Library\\include" (Note carefully the quotes and double backslashes!) Obviously the actual path varies depending on where you installed the thing.
  • Cabal may also need to find object files that need to be statically linked. Again, a future Cabal release will allow you to specify these during the configure state with switches, but for now try adding extra-lib-dirs: "C:\\Program Files\\My External Library\\lib" or similar.
  • Assuming you get your library to compile, you may still need to add DLLs or other resources to your PATH variable to get any programs using the package to actually run. (But the installer for the external library might have done this for you already.)

My package repository seems to be in an inconsitent state. What can i do?

TODO