GHC undefined reference to Paths in dependency

533 views Asked by At

I recently made a cabal package which can be seen here It consists of a library and a few small example programs using it. Everything builds and works as expected.

I wanted to build an executable in a new package which uses this library, however I continue to run into a linking error I can't decipher:

/my/path/RandomAgent/.cabal-sandbox/lib/x86_64-linux-ghc-7.8.4/rlglue-0.2.1.1/libHSrlglue-0.2.1.1.a(Agent.o):(.text+0x34f1): undefined reference to `rlgluezm0zi2zi1zi1_Pathszurlglue_version1_closure'

collect2: error: ld returned 1 exit status To make things simpler to diagnose I moved one of the examples programs into my new package and discovered even it won't build properly. You can find that version of the executable here.

From this I've concluded that the problem is likely in something I'm doing in my .cabal files, but I can't see what's wrong. The error also seems to refer to the Paths_rlglue module which cabal automatically generates for the first package.

Can anyone help me understand why I'm getting this error?

2

There are 2 answers

0
Reid Barton On BEST ANSWER

You need to include the Paths_rlglue module in exposed-modules or other-modules like any other module in your project so that Cabal will link it.

Cabal should be better about telling you what is going on, see https://github.com/haskell/cabal/issues/1746.

0
rofer On

Looks like I missed something in the documentation for Paths_pkgname

If you decide to import the Paths_pkgname module then it must be listed in the other-modules field just like any other module in your package.

Adding Paths_rlglue to my library's other-modules fixed the issue. Hope this saves someone all the time I lost on this.