Skip to content

Error message: Undefined reference to `XXX_closure'

When I try to compile the following test case:

import System.IO
import Text.XML.HXT.Arrow

main = do
 runX $ application

application =
 readDocument [(a_validate, v_0)] "url"
   >>> generateItemsXml
   -- >>. takeLast
   >>. \t -> [last t]
   >>> getErrStatus
 where
   takeLast xs = [last xs]

generateItemsXml = root [] []

the compilation fails because of the line ">>. \t -> [last t]". If I extract this line into a separate function (here takeLast) or take it into parentheses, the compilation proceeds. For this test case compilation actually fails later with more sensible error message, but the original full program compiles after this fix successfully. I can provide the full program if necessary. It is not very big. Contact me at c at hlsoft com.

The GHC compilation failure is:

~/prj/pubStats$ ./run.sh
[123 of 123] Compiling Main             ( src/testGhc.hs, src/testGhc.o )
Linking src/testGhc ...
src/testGhc.o: In function `Main_lvl3_info':
ghc26321_0.hc:(.text+0x166): undefined reference to `Main_application_closure'
src/testGhc.o:(.rodata+0x10): undefined reference to `Main_application_closure'
collect2: ld returned 1 exit status

The GHCi fails with following message:

During interactive linking, GHCi couldn't find the following symbol:
 Main_application_closure
This may be due to you not asking GHCi to load extra object files,
archives or DLLs needed by your current session.  Restart GHCi, specifying
the missing library using the -L/path/to/object/dir and -lmissinglibname
flags, or simply by naming the relevant files on the GHCi command line.
Alternatively, this link failure might indicate a bug in GHCi.
If you suspect the latter, please send a bug report to:
 glasgow-haskell-bugs@haskell.org

The GHC version: "The Glorious Glasgow Haskell Compilation System, version 6.6" on Ubuntu Linux 7.04. Currently I don't have time to try to reproduce the problem on the latest version of the compiler.

I compile my program with the HXT library using the following command:

ghc --make -O -fglasgow-exts -farrows -iinc src/testGhc.hs

where the inc directory contains the HXT library. Sorry if it is not a bug, or it is already fixed. I could not decide whether other occurrences of this error indicate the same problem. Decided that submitting an invalid bug is better than missing it completely.

Trac metadata
Trac field Value
Version 6.6
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture x86
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information