Linking executables and the library of a Cabal package description

John D. Ramsdell ramsdell at
Mon Oct 15 14:32:44 EDT 2007

I'm sure this will be an easy question for those on this list.  What
do you need to add to a Cabal package description so as to allow an
executable in the description to be built from the library it also
describes?  I searched the Cabal documentation many times, but came up
empty handed.


$ make
runhaskell Setup.hs build
Preprocessing library a-1.0...
Preprocessing executables for a-1.0...
Building a-1.0...
[1 of 1] Compiling A                ( A.hs, dist/build/A.o )
/usr/bin/ar: creating dist/build/libHSa-1.0.a

    Could not find module `A':
      Use -v to see a list of the files searched for.
make: *** [all] Error 1
$ : after cleaning...
$ more `find . -type f ` > ../a.txt
$ cat ../a.txt
Name:			a
Version:		1.0
Build-Depends:		base
Exposed-Modules:	A

Executable:		b
Main-Is:		Main.hs
Other-Modules:		A
Hs-Source-Dirs:		exec
import Distribution.Simple
main = defaultMain
SETUP	= runhaskell Setup.hs

	if test ! -f .setup-config; then $(SETUP) configure; fi
	$(SETUP) build

	@echo make $@

%:	force
	$(SETUP) $@

.PHONY:	all force
module A where

a :: Int
a = 3
module Main (main) where

import A

main :: IO ()
main =
    print a
$ ghc -h
ghc-6.6.1: unrecognised flags: -h
Usage: For basic information, try the `--help' option.
$ uname -a
Linux goo #1 SMP Thu Sep 27 23:10:59 EDT 2007 i686 i686 i386 GNU/Linux

More information about the Libraries mailing list