Linking executables and the library of a Cabal package
description
John D. Ramsdell
ramsdell at mitre.org
Wed Oct 17 11:33:31 EDT 2007
I have a solution to the linking problem, at least for ghc users.
I added the -v option to my "runhaskell Setup.hs build" command, and
tried adding various properties. The break came when I realized ghc
was being given the --make option, and with this option, one cannot
satisfy it only with an interface file. Ghc either gets the
information it needs from a source file, or from a package. So the
trick is to include a package.conf file in your distribution that
specifies only relative paths (dist/build). You then add ghc specific
options to your Cabal package description.
a.cabal
---------------------
Name: a
Version: 1.0
Build-Depends: base
Exposed-Modules: A
Executable: b
Main-Is: Main.hs
Hs-Source-Dirs: exec
ghc-options: -package-conf package.conf -package a
---------------------
package.conf
---------------------
[InstalledPackageInfo {package = PackageIdentifier {pkgName = "a", pkgVersion = Version {versionBranch = [1,0], versionTags = []}}, license = AllRightsReserved, copyright = "", maintainer = "", author = "", stability = "", homepage = "", pkgUrl = "", description = "", category = "", exposed = True, exposedModules = ["A"], hiddenModules = [], importDirs = ["dist/build"], libraryDirs = ["dist/build"], hsLibraries = ["HSa-1.0"], extraLibraries = [], extraGHCiLibraries = [], includeDirs = ["dist/build/include"], includes = [], depends = [PackageIdentifier {pkgName = "base", pkgVersion = Version {versionBranch = [2,1,1], versionTags = []}}], hugsOptions = [], ccOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [], haddockInterfaces = ["/home/ramsdell/proj/b/goo/share/a-1.0/doc/html/a.haddock"], haddockHTMLs = ["/home/ramsdell/proj/b/goo/share/a-1.0/doc/html"]}]
---------------------
So it's not a Cabal bug after all!
In my package.conf file, can I get away with just specifying the
pkgName, exposed, exposedModules, importDirs, libraryDirs, and
hsLibraries fields?
John
More information about the Libraries
mailing list