[Haskell-cafe] Linking failing due to Control.Monad.State.Strict?

Daniel Peebles pumpkingod at gmail.com
Thu Aug 6 21:46:58 EDT 2009


Sorry, I missed that you'd tried that. Why would you not want to use
--make? The issue is that when you import a module in your standard
library, you need to link to it, and ghc --make takes care of figuring
out what to link to for you. Otherwise, you'll need to go digging in
your library for the .o files to link to by hand. There's nothing
stopping you from using ghc --make along with a makefile, if you have
various other complex things to do in your build.

Also, people in the Haskell community tend to not use makefiles much,
instead opting for the much more "Haskellish" cabal build and
packaging system. If you haven't tried it, I recommend it :)

Hope this helps (more than my previous email at least!),
Dan

On Thu, Aug 6, 2009 at 9:43 PM, Daniel Peebles<pumpkingod at gmail.com> wrote:
> Try with ghc --make ?
>
> On Thu, Aug 6, 2009 at 9:38 PM, <phil at beadling.co.uk> wrote:
>> Hi,
>>
>> I'm getting a linker error when generating makefile dependencies on the
>> below library for a program I'm using.  It links fine under 'ghc --make'.
>>  I'm using (more or less) the makefile from the haskell docs.  I am using
>> the Strict State Monad in the object files it is complaining about, the
>> compile is fine, just the linker which is blowing up. Any ideas what is
>> causing this?
>>
>> I'm using GHC 6.10.4 on PPC Mac OS X 10.5.
>>
>> I've included the makefile below the error.
>>
>> Cheers!
>>
>> Phil.
>>
>>
>> ghc -o OptionCalculator -O2 -Wall  ./FrameworkInterface.o ./Maths/Prime.o
>> ./Misc/Debug.o ./MonteCarlo/DataStructures.o ./MonteCarlo/European.o
>> ./MonteCarlo/Framework.o ./MonteCarlo/Interface.o ./MonteCarlo/Lookback.o
>> ./Normal/Acklam.o ./Normal/BoxMuller.o ./Normal/Framework.o
>> ./Normal/Interface.o ./OptionCalculator.o ./Random/Framework.o
>> ./Random/Halton.o ./Random/Interface.o ./Random/Ranq1.o
>> Undefined symbols:
>>  "_mtlzm1zi1zi0zi2_ControlziMonadziStateziStrict_a29_info", referenced from:
>>      _r1hl_info in Acklam.o
>>      _rGL_info in BoxMuller.o
>>  "_mtlzm1zi1zi0zi2_ControlziMonadziStateziStrict_a29_closure", referenced
>> from:
>>      _r1hl_srt in Acklam.o
>>      _rGL_srt in BoxMuller.o
>>  "___stginit_mtlzm1zi1zi0zi2_ControlziMonadziStateziStrict_", referenced
>> from:
>>      ___stginit_FrameworkInterface_ in FrameworkInterface.o
>>      ___stginit_FrameworkInterface_ in FrameworkInterface.o
>>      ___stginit_MonteCarloziEuropean_ in European.o
>>      ___stginit_MonteCarloziEuropean_ in European.o
>>      ___stginit_MonteCarloziFramework_ in Framework.o
>>      ___stginit_MonteCarloziFramework_ in Framework.o
>>      ___stginit_MonteCarloziLookback_ in Lookback.o
>>      ___stginit_MonteCarloziLookback_ in Lookback.o
>>      ___stginit_NormalziAcklam_ in Acklam.o
>>      ___stginit_NormalziAcklam_ in Acklam.o
>>      ___stginit_NormalziBoxMuller_ in BoxMuller.o
>>      ___stginit_NormalziBoxMuller_ in BoxMuller.o
>>      ___stginit_NormalziFramework_ in Framework.o
>>      ___stginit_NormalziFramework_ in Framework.o
>>      ___stginit_RandomziFramework_ in Framework.o
>>      ___stginit_RandomziFramework_ in Framework.o
>>      ___stginit_RandomziHalton_ in Halton.o
>>      ___stginit_RandomziHalton_ in Halton.o
>>      ___stginit_RandomziRanq1_ in Ranq1.o
>>      ___stginit_RandomziRanq1_ in Ranq1.o
>> ld: symbol(s) not found
>> collect2: ld returned 1 exit status
>> make: *** [OptionCalculator] Error 1
>>
>>
>>
>>
>> Makefile:
>>
>>
>> HC      = ghc
>> HC_OPTS = -O2 -Wall $(EXTRA_HC_OPTS)
>>
>> SRCS := $(shell find . -name "*.hs" -print)
>> OBJS = $(SRCS:.hs=.o)
>> PROG = OptionCalculator
>>
>> .SUFFIXES : .o .hs .hi .lhs .hc .s
>>
>> ${PROG} : $(OBJS)
>>          rm -f $@
>>          $(HC) -o $@ $(HC_OPTS) $(OBJS)
>>
>> # Standard suffix rules
>> .o.hi:
>>        @:
>>
>> .lhs.o:
>>        $(HC) -c $< $(HC_OPTS)
>>
>> .hs.o:
>>        $(HC) -c $< $(HC_OPTS)
>>
>> .o-boot.hi-boot:
>>        @:
>>
>> .lhs-boot.o-boot:
>>        $(HC) -c $< $(HC_OPTS)
>>
>> .hs-boot.o-boot:
>>        $(HC) -c $< $(HC_OPTS)
>>
>> clean :
>>        find . -name "*.hi" -exec rm -f {} \;
>>        find . -name "*.o" -exec rm -f {} \;
>>        rm -f ${PROG}
>>
>> depend :
>>        ghc -M $(HC_OPTS) $(SRCS)
>>
>>
>> _______________________________________________
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>>
>


More information about the Haskell-Cafe mailing list