0

while I can use several turtle scripts in the same directory (have eg. pretty.hs and srv.hs interpreted), I learned that I can have only have one of them compiled eg. with

ghc -no-user-package-db -package-db .cabal-sandbox/*-packages.conf.d -O2 -threaded -outputdir=. -o srv srv.hs

as this implicitly builds Main.o and Main.hi as well, and and srv and pretty would need two different object files, obviously.

What's the story of Turtle and the Main module anyway: wouldn't it have been nicer, if one could use (and thus choose) a module name, like so

Module Whatever
import Turtle

I tried to compile the .o files separatly, but with no luck:

$ ghc -no-user-package-db -package-db .cabal-sandbox/*-packages.conf.d -O2 -threaded -outputdir=. -c -o MainPretty.o pretty.hs

no complaints so far, but then:

$ ghc -no-user-package-db -package-db .cabal-sandbox/*-packages.conf.d -O2 -threaded -outputdir=. -o pretty MainPretty.o

MainPretty.o: In function `rdyO_info':
(.text+0x40e): undefined reference to `transzuGZZTjP9K5WFq01xC9BAGQpF_ControlziMonadziIOziClass_zdfMonadIOIO_closure'
MainPretty.o: In function `rdyQ_info':
(.text+0x4d6): undefined reference to `transzuGZZTjP9K5WFq01xC9BAGQpF_ControlziMonadziIOziClass_zdfMonadIOIO_closure'
MainPretty.o: In function `cfxy_info':
(.text+0x712): undefined reference to `optpazuFpNJ7fLofFNEy3rK4ZZnBoD_OptionsziApplicativeziTypes_AltP_con_info'
MainPretty.o: In function `cfxy_info':
(.text+0x72e): undefined reference to `systezu0e3pMPmZZzzix21iFp2U03Lc_FilesystemziPathziRules_posixFromText_closure'
MainPretty.o: In function `cfyR_info':
(.text+0x92a): undefined reference to `optpazuFpNJ7fLofFNEy3rK4ZZnBoD_OptionsziApplicativeziTypes_AltP_con_info'

and so on...

Is it possible nevertheless to compile two different turtle scripts in the same dir? how?

Thanks.

1 Answers1

1

Ah, to answer my own question: I saw that I just have to remove these Main.o/Main.hi files after compiling (to have different one created anew then), like so:

ghc -no-user-package-db -package-db .cabal-sandbox/*-packages.conf.d -O2 -threaded -outputdir=. -o pretty pretty.hs
rm -f Main.o Main.hi

Sorry for the noise

  • If you give `ghc` the ` -fforce-recomp ` flag it will get rid of these files before attempting to compile. – Michael Aug 06 '16 at 01:52