[Haskell-cafe] can GHC build an executable from a C source file?
Hi. I'm checking if it possible to build an executable from C source files only. As an example: #include stdio.h int main () { printf(hello world\n); return 0; } $ghc --make foo.c However this only produces the object file, foo.o; it does not build the executable file. What is the reason for this behaviour? I have tested with GHC 6.8.2. Thanks Manlio ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] can GHC build an executable from a C source file?
Works for me without the --make, as `ghc foo.c` --A On Tue, Mar 17, 2009 at 6:32 PM, Manlio Perillo manlio_peri...@libero.it wrote: Hi. I'm checking if it possible to build an executable from C source files only. As an example: #include stdio.h int main () { printf(hello world\n); return 0; } $ghc --make foo.c However this only produces the object file, foo.o; it does not build the executable file. What is the reason for this behaviour? I have tested with GHC 6.8.2. Thanks Manlio ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] can GHC build an executable from a C source file?
Anton Tayanovskyy ha scritto: Works for me without the --make, as `ghc foo.c` For me, too, thanks. Manlio ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] can GHC build an executable from a C source file?
You know, I hear theres this brilliant program for compiling C code -- gcd? ccg? gcc, yah gcc... Anyone tried it? In all seriousness though, why do you need to compile c with ghc? I'm curious, it seems a bit pointless... /Joe Manlio Perillo wrote: Anton Tayanovskyy ha scritto: Works for me without the --make, as `ghc foo.c` For me, too, thanks. Manlio ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe begin:vcard fn:Joseph Fredette n:Fredette;Joseph adr:Apartment #3;;6 Dean Street;Worcester;Massachusetts;01609;United States of America email;internet:jfred...@gmail.com tel;home:1-508-966-9889 tel;cell:1-508-254-9901 x-mozilla-html:FALSE url:lowlymath.net, humbuggery.net version:2.1 end:vcard ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] can GHC build an executable from a C source file?
Yhc used to do this (when you could still build it). Turns out that on Windows using gcc that gets installed with ghc isn't particularly fun, while ghc makes a very pleasant build experience. Something to do with directory layouts, head file searching, and what is on the %PATH% by default. Thanks Neil 2009/3/17 Joe Fredette jfred...@gmail.com: You know, I hear theres this brilliant program for compiling C code -- gcd? ccg? gcc, yah gcc... Anyone tried it? In all seriousness though, why do you need to compile c with ghc? I'm curious, it seems a bit pointless... /Joe Manlio Perillo wrote: Anton Tayanovskyy ha scritto: Works for me without the --make, as `ghc foo.c` For me, too, thanks. Manlio ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] can GHC build an executable from a C source file?
Joe Fredette ha scritto: You know, I hear theres this brilliant program for compiling C code -- gcd? ccg? gcc, yah gcc... Anyone tried it? In all seriousness though, why do you need to compile c with ghc? I'm curious, it seems a bit pointless... It's for a possible extension I'm planning for Cabal. The idea is to add support for configuration features. A configuration feature is similar to a configuration flag, but with some important differences. data Feature = Bool | String A feature block: Feature HaveURandom action: execute include-dirs: ... c-sources: features/urandom.c -- other possible properties, as listed in -- Build information chapter, excluding `buildable` and -- `other-modules` -- The `action` property can have values `compile` (default`) -- or `execute` This means that I'm testing for a feature named HaveURandom, and the testing requires to compile/build and then execute some code. In this case there is only a C source file that needs to be compiled; this is the reason why I have asked if GHC supports compilation for C source files only, and the creation of an executable. Here I'm asking Cabal to execute the generated program. If the executable returns 0, then HaveURandom will have value `Feature True`; if it returns 1, then HaveURandom will have value `Feature False`. If the executable write something on stdout, then HaveURandom will have value `Feature string`. If compilation fails, HaveURandom will have value `Feature False`. If `action` property is compile, then a successful compilation will result in HaveURandom having a value of `Feature True`. Regards Manlio ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe