cabal and ghc disagree on the name of the module Main

Hello, I have the following directories set : Project/ Project/Language Project/Language/Copilot/ in Project there is the copilot.cabal file. in Project/Language/Copilot there are a bunch of .hs files, including Main.hs All the modules in these files are named Language.Copilot.NameOfTheFile for cabal to work. My issue happened when I chose to add a Main.hs, containing Language.Copilot.Main and to try to compile it with ghc --make. I got the error message "output was redirected with -o, but no output will be generated because there is no Main module." So I replaced Language.Copilot.Main by Main. ghc was happy, but cabal sent me the following error message : "File name does not match module name: Saw: `Main' Expected: `Language.Copilot.Main'" So I finally kept the Language.Copilot.Main module name, and tried to use the -main-is ghc option. The result was an unreadable linker error message : "/usr/lib/ghc-6.12.1/libHSrtsmain.a(Main.o): In function `main': (.text+0x10): undefined reference to `ZCMain_main_closure' /usr/lib/ghc-6.12.1/libHSrtsmain.a(Main.o): In function `main': (.text+0x18): undefined reference to `__stginit_ZCMain' collect2: ld returned 1 exit status" Does anyone know what this last message mean, and how to make both cabal and ghc happy with my module name ? Thank you in advance, Robin

robin morisset
Hello,
I have the following directories set : Project/ Project/Language Project/Language/Copilot/ in Project there is the copilot.cabal file. in Project/Language/Copilot there are a bunch of .hs files, including Main.hs All the modules in these files are named Language.Copilot.NameOfTheFile for cabal to work.
My issue happened when I chose to add a Main.hs, containing Language.Copilot.Main and to try to compile it with ghc --make. I got the error message "output was redirected with -o, but no output will be generated because there is no Main module." So I replaced Language.Copilot.Main by Main. ghc was happy, but cabal sent me the following error message : "File name does not match module name: Saw: `Main' Expected: `Language.Copilot.Main'" So I finally kept the Language.Copilot.Main module name, and tried to use the -main-is ghc option. The result was an unreadable linker error message : "/usr/lib/ghc-6.12.1/libHSrtsmain.a(Main.o): In function `main': (.text+0x10): undefined reference to `ZCMain_main_closure' /usr/lib/ghc-6.12.1/libHSrtsmain.a(Main.o): In function `main': (.text+0x18): undefined reference to `__stginit_ZCMain' collect2: ld returned 1 exit status"
Does anyone know what this last message mean, and how to make both cabal and ghc happy with my module name ?
Why not just have a Main.hs file? As for that error message, do you have a main function? Are you sure you were using --make? -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com

Hello,
(Ivan Lazar Miljenovi)
Why not just have a Main.hs file?
As for that error message, do you have a main function? Are you sure you were using --make?
thank you for taking the time for reply. A friend finally found the issue. The main function in the Main module was ok, the problem was in the cabal file. I did not know it could be specified whether you want to get a library or an executable (before there was only the library specified). Now both are mentionned in the cabal file (the executable depends on the library) and everything is fine. Here is an extract of the cabal file in case someone else has the same problem : library ghc-options: -Wall build-depends: base > 4 && < 5 ... extensions: exposed-modules: Language.Copilot Language.Copilot.Core ... -- Not Main here ! executable copilot executable: copilot hs-source-dirs: . Language/Copilot other-modules: Core ... -- Nor here ! main-is: Main.hs Thank you again, and sorry for bothering you with that issue which was finally only a cabal configuration mistake and not a real haskell issue. Robin
participants (2)
-
Ivan Lazar Miljenovic
-
robin morisset