[Haskell-cafe] Compiling with NHC98

David Menendez zednenem at psualum.com
Sat May 7 15:36:17 EDT 2005


Daniel Carrera writes:

> Hello,
> 
> After days of effort, I finally managed to compile and install a
> Haskell compiler. The one I have is NHC98.
> 
> So now, with my new toy, I am eager to compile my very first Haskell 
> program (I've been using 'runhugs' so far). But I'm having problems:
> 
> ---<quote>----
> $ nhc98 prng.hs -o prng
> I/O error (user-defined), call to function `userError':
>    In file ./RC4.hi:
> 1:1-1:6 Found _module_ but expected a interface
> ---<quote>----

*.hi files are analogous to C's *.h files, except that the compiler
generates them.

You mentioned later that you don't have any *.hi files, so I'm guessing
you didn't compile RC4.hs before you compiled prng.hs.

If I'm right, you need to do something like this first:

    $ nhc98 -c RC4.hs

This will create an object file (probably RC4.o) containing compiled
code and an interface file (RC4.hi) that the compiler will use when it
compiles prng.hs. The -c option tells nhc that you don't want to link
anything yet.

Once that step is done, you should be able to compile prng.hs.

Incidentally, if you aren't already familiar with "make" or some other
build system, I strongly recommend looking into one. Even for a project
with only two files, having a build system keep track of compilation
dependencies makes things a lot less tedious.
-- 
David Menendez <zednenem at psualum.com> <http://www.eyrie.org/~zednenem/>


More information about the Haskell-Cafe mailing list