[Haskell-cafe] #include path

Duncan Coutts duncan.coutts at googlemail.com
Thu Oct 8 05:17:21 EDT 2009


On Thu, 2009-10-08 at 00:37 -0400, Sean McLaughlin wrote:
> Hi,
> 
> 
>   I'm trying to compile some code using Cabal.  One of the files has a
> CPP directive
> 
> 
> #include "undefined.h"
> 
> 
> The file undefined.h is in the same directory as the file with the
> directive.

That works fine for me.

I've got:

foo.cabal
Foo/Bar.hs
Foo/undefined.h

Bar.hs has the #include "undefined.h" directive. This works because cpp
looks first in the directory containing the file it is processing at the
time, ie the directory containing Foo/Bar.hs.

> If I use the full path name, cabal can compile it.  However, if I use
> the relative path, it complains about not being able to find the file.

Do you mean cpp (invoked by cabal/ghc) cannot find the undefined.h file
when compiling? If this is the case we'll need more details.

When you say full path name do you mean the full absolute path name all
the way from /, or do you mean relative to the root of the project (ie
the dir with the .cabal file)?

> I tried adding it to extra-source-files, but that didn't help.

Or do you mean it does not get included into the sdist tarball, and thus
is missing when you build from the tarball? That would be a use case for
extra-source-files.

>  I see that Hackage packages like Agda use this trick, so I know it's
> possible.  How can I get these paths worked out correctly?
> There isn't much comment in the Cabal docs.

I'm not clear about which stage is failing.

Duncan




More information about the Haskell-Cafe mailing list