Problem with the object file name of the Main module.

H. The documentation (version 7.6.3) section 7.7.2 Output files says that the source file name of the Main module does not have to be Main.hs making it "possible to have several Main modules in separate source files in the same directory". While this is true and promising it is seems to be unusable since GHC always compiles the main source file into an object file called Main.o.

Christian, have you tried using cabal? People write cabal files with multiple executables being generated all the time. On Sunday, January 12, 2014, Christian Brolin wrote:
H.
The documentation (version 7.6.3) section 7.7.2 Output files says that the source file name of the Main module does not have to be Main.hs making it "possible to have several Main modules in separate source files in the same directory". While this is true and promising it is seems to be unusable since GHC always compiles the main source file into an object file called Main.o.
_______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

No. As a workaround I remove the Main.o file after the executable has been linked. It works, but it has its drawbacks. On 2014-01-12 17:23, Carter Schonwald wrote:
Christian, have you tried using cabal? People write cabal files with multiple executables being generated all the time.
On Sunday, January 12, 2014, Christian Brolin wrote:
H.
The documentation (version 7.6.3) section 7.7.2 Output files says that the source file name of the Main module does not have to be Main.hs making it "possible to have several Main modules in separate source files in the same directory". While this is true and promising it is seems to be unusable since GHC always compiles the main source file into an object file called Main.o.
_______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

i warmly recommend you use cabal for any complicated build processes. if
you're stuck, holler and we or haskell-cafe are happy to help
On Mon, Jan 13, 2014 at 1:22 PM, Christian Brolin
No. As a workaround I remove the Main.o file after the executable has been linked. It works, but it has its drawbacks.
On 2014-01-12 17:23, Carter Schonwald wrote:
Christian, have you tried using cabal? People write cabal files with multiple executables being generated all the time.
On Sunday, January 12, 2014, Christian Brolin wrote:
H.
The documentation (version 7.6.3) section 7.7.2 Output files says that the source file name of the Main module does not have to be Main.hs making it "possible to have several Main modules in separate source files in the same directory". While this is true and promising it is seems to be unusable since GHC always compiles the main source file into an object file called Main.o.
_______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Thanks, but it is not a complicated build process. Just a few simple programs that share some modules. I like to keep it simple. On 2014-01-13 19:28, Carter Schonwald wrote:
i warmly recommend you use cabal for any complicated build processes. if you're stuck, holler and we or haskell-cafe are happy to help
On Mon, Jan 13, 2014 at 1:22 PM, Christian Brolin
mailto:cbrolin@gmail.com> wrote: No. As a workaround I remove the Main.o file after the executable has been linked. It works, but it has its drawbacks.
On 2014-01-12 17:23, Carter Schonwald wrote:
Christian, have you tried using cabal? People write cabal files with multiple executables being generated all the time.
On Sunday, January 12, 2014, Christian Brolin wrote:
H.
The documentation (version 7.6.3) section 7.7.2 Output files says that the source file name of the Main module does not have to be Main.hs making it "possible to have several Main modules in separate source files in the same directory". While this is true and promising it is seems to be unusable since GHC always compiles the main source file into an object file called Main.o.
_______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

I'd like to repeat the suggestion to use cabal. It's very well suited
for simple programs. In addition, you get the ability to specify
dependencies, you can upload to hackage, etc.
Erik
On Mon, Jan 13, 2014 at 11:10 PM, Christian Brolin
Thanks, but it is not a complicated build process. Just a few simple programs that share some modules. I like to keep it simple.
On 2014-01-13 19:28, Carter Schonwald wrote:
i warmly recommend you use cabal for any complicated build processes. if you're stuck, holler and we or haskell-cafe are happy to help
On Mon, Jan 13, 2014 at 1:22 PM, Christian Brolin
wrote: No. As a workaround I remove the Main.o file after the executable has been linked. It works, but it has its drawbacks.
On 2014-01-12 17:23, Carter Schonwald wrote:
Christian, have you tried using cabal? People write cabal files with multiple executables being generated all the time.
On Sunday, January 12, 2014, Christian Brolin wrote:
H.
The documentation (version 7.6.3) section 7.7.2 Output files says that the source file name of the Main module does not have to be Main.hs making it "possible to have several Main modules in separate source files in the same directory". While this is true and promising it is seems to be unusable since GHC always compiles the main source file into an object file called Main.o.
_______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
_______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

The main module doesn't have to be called Main. You can specify a different name with the -main-is option. That seems like the easiest way to avoid the object file name clash. By the way, this problem only seems to arise when the -odir flag is used. If my Main module is in A.hs and I compile it with "ghc --make A.hs", I get "A.o", "A.hi" and an executable file "A". (Tested with GHC 7.6.3.) Thomas H On 2014-01-13 19:22, Christian Brolin wrote:
No. As a workaround I remove the Main.o file after the executable has been linked. It works, but it has its drawbacks.
On 2014-01-12 17:23, Carter Schonwald wrote:
Christian, have you tried using cabal? People write cabal files with multiple executables being generated all the time.
On Sunday, January 12, 2014, Christian Brolin wrote:
H.
The documentation (version 7.6.3) section 7.7.2 Output files says that the source file name of the Main module does not have to be Main.hs making it "possible to have several Main modules in separate source files in the same directory". While this is true and promising it is seems to be unusable since GHC always compiles the main source file into an object file called Main.o.
_______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
_______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Thanks. Strange feature! Yes, I'm using -outputdir. It seems the -main-is MyProg is the best work around for me. But for it to work I also have to declare that MyProg is the name of the main module in the source (of course) which I otherwise don't have to. I also like to name my main modules with initial lowercase (myProg.hs) to get Unix sounded executables so my makefile has to adjust for this too. On 2014-01-13 21:18, Thomas Hallgren wrote:
The main module doesn't have to be called Main. You can specify a different name with the -main-is option. That seems like the easiest way to avoid the object file name clash.
By the way, this problem only seems to arise when the -odir flag is used. If my Main module is in A.hs and I compile it with "ghc --make A.hs", I get "A.o", "A.hi" and an executable file "A". (Tested with GHC 7.6.3.)
Thomas H
On 2014-01-13 19:22, Christian Brolin wrote:
No. As a workaround I remove the Main.o file after the executable has been linked. It works, but it has its drawbacks.
On 2014-01-12 17:23, Carter Schonwald wrote:
Christian, have you tried using cabal? People write cabal files with multiple executables being generated all the time.
On Sunday, January 12, 2014, Christian Brolin wrote:
H.
The documentation (version 7.6.3) section 7.7.2 Output files says that the source file name of the Main module does not have to be Main.hs making it "possible to have several Main modules in separate source files in the same directory". While this is true and promising it is seems to be unusable since GHC always compiles the main source file into an object file called Main.o.
_______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
_______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
_______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
participants (4)
-
Carter Schonwald
-
Christian Brolin
-
Erik Hesselink
-
Thomas Hallgren