How to fix "undefined reference" error with getDataDir?

Hi all,
I have two package A and B, and B depend A.
I use below code snippets in package A:
------------------------------> code start <------------------------------
...
import Paths_manatee_ircclient
import System.FilePath
...
dir <- getDataDir
let imagePath imageName = dir > "icons" > (imageName ++ ".png")
...
------------------------------> code end <------------------------------
Anyway, package A compile fine, but when i compile package B, i got
below error:
------------------------------> error start <------------------------------
Linking dist/build/manatee/manatee ...
/home/andy/.cabal/lib/manatee-ircclient-0.0.1/ghc-6.12.3/libHSmanatee-ircclient-0.0.1.a(Smile.o): In function `s6sP_info':
(.text+0x3bea): undefined reference to `manateezmircclientzm0zi0zi1_Pathszumanateezuircclient_getDataDir3_closure'
/home/andy/.cabal/lib/manatee-ircclient-0.0.1/ghc-6.12.3/libHSmanatee-ircclient-0.0.1.a(Smile.o): In function `s6sP_info':
(.text+0x3bf0): undefined reference to `manateezmircclientzm0zi0zi1_Pathszumanateezuircclient_getDataDir2_closure'
/home/andy/.cabal/lib/manatee-ircclient-0.0.1/ghc-6.12.3/libHSmanatee-ircclient-0.0.1.a(Smile.o): In function `s6Uf_info':
(.text+0x560f): undefined reference to `__stginit_manateezmircclientzm0zi0zi1_Pathszumanateezuircclient_'
/home/andy/.cabal/lib/manatee-ircclient-0.0.1/ghc-6.12.3/libHSmanatee-ircclient-0.0.1.a(Smile.o): In function `r5Mp_closure':
(.data+0x9d8): undefined reference to `manateezmircclientzm0zi0zi1_Pathszumanateezuircclient_getDataDir3_closure'
/home/andy/.cabal/lib/manatee-ircclient-0.0.1/ghc-6.12.3/libHSmanatee-ircclient-0.0.1.a(Smile.o): In function `r5Mp_closure':
(.data+0x9e0): undefined reference to `manateezmircclientzm0zi0zi1_Pathszumanateezuircclient_getDataDir2_closure'
collect2: ld returned 1 exit status
cabal: Error: some packages failed to install:
manatee-0.0.1 failed during the building phase. The exception was:
ExitFailure 1
------------------------------> error end <------------------------------
How to fix above error?
Thanks!
-- Andy
Below is .cabal file for package A:
------------------------------> A.cabal start <------------------------------
name: manatee-ircclient
version: 0.0.1
Cabal-Version: >= 1.6
license: GPL-3
license-file: LICENSE
copyright: (c) 2009 ~ 2010 Andy Stewart
synopsis: IRC client extension for Manatee.
description: manatee-ircclient is IRC client extension for Manatee (Haskell/Gtk+ Integrated Live Environment)
author: Andy Stewart
maintainer: Andy Stewart

Andy Stewart schrieb:
Hi all,
I have two package A and B, and B depend A.
I use below code snippets in package A:
------------------------------> code start <------------------------------ ... import Paths_manatee_ircclient import System.FilePath ... dir <- getDataDir let imagePath imageName = dir > "icons" > (imageName ++ ".png") ... ------------------------------> code end <------------------------------
Anyway, package A compile fine, but when i compile package B, i got below error:
------------------------------> error start <------------------------------ Linking dist/build/manatee/manatee ... /home/andy/.cabal/lib/manatee-ircclient-0.0.1/ghc-6.12.3/libHSmanatee-ircclient-0.0.1.a(Smile.o): In function `s6sP_info': (.text+0x3bea): undefined reference to `manateezmircclientzm0zi0zi1_Pathszumanateezuircclient_getDataDir3_closure'
Often these linker problems arise if A was altered and recompiled and not all depending parts of B were recompiled. However, 'cabal install' which in turn calls 'ghc --make' should automatically find and compile the affected modules of B. Maybe it fails in trying to do so. I would try to remove dist/build of packages A and B and then compile and install the packages again.

Henning Thielemann
Andy Stewart schrieb:
Hi all,
I have two package A and B, and B depend A.
I use below code snippets in package A:
------------------------------> code start <------------------------------ ... import Paths_manatee_ircclient import System.FilePath ... dir <- getDataDir let imagePath imageName = dir > "icons" > (imageName ++ ".png") ... ------------------------------> code end <------------------------------
Anyway, package A compile fine, but when i compile package B, i got below error:
------------------------------> error start <------------------------------ Linking dist/build/manatee/manatee ... /home/andy/.cabal/lib/manatee-ircclient-0.0.1/ghc-6.12.3/libHSmanatee-ircclient-0.0.1.a(Smile.o): In function `s6sP_info': (.text+0x3bea): undefined reference to manateezmircclientzm0zi0zi1_Pathszumanateezuircclient_getDataDir3_closure'
Often these linker problems arise if A was altered and recompiled and not all depending parts of B were recompiled. However, 'cabal install' which in turn calls 'ghc --make' should automatically find and compile the affected modules of B. Maybe it fails in trying to do so. I would try to remove dist/build of packages A and B and then compile and install the packages again. Hi Henning, thanks for reply.
I have fix this problem: I forgot add 'Paths_manatee_ircclient' in "other-modules" of A.cabal , then package A compile fine, but package B can't found path of module ''Paths_manatee_ircclient', then link failed. After i add "Paths_manatee_ircclient" in A.cabal, problem fix. Cheer, -- Andy
participants (2)
-
Andy Stewart
-
Henning Thielemann