"undefined references" when using package

Hi! I try to generate a package out of some haskell sources. Everything looks to work fine but when I try to compile a program using this package I get a linking error. It reports "undefined reference" to seemingly everything that is accessible form outside the package. I'm using ghc-6.2.1 and I would be very grateful for a hint. Gruss Jan

Jan Christiansen wrote:
I try to generate a package out of some haskell sources. Everything looks to work fine but when I try to compile a program using this package I get a linking error. It reports "undefined reference" to seemingly everything that is accessible form outside the package. I'm using ghc-6.2.1 and I would be very grateful for a hint.
This sounds like missing dependencies in your package configuration file. Most package mention e.g. at least the "base" package: package_deps = [ "base" ] Looking at the undefined references will probably help to figure out what should be mentioned in your case. You don't have to do this transitively, BTW, GHC(i) is cunning enough to do this itself, e.g. the "base" package depends on the "rts" package, but you don't have to specify this in your configuration file. Cheers, S.

On Saturday 17 April 2004 12:48, Sven Panne wrote:
This sounds like missing dependencies in your package configuration file. Most package mention e.g. at least the "base" package:
package_deps = [ "base" ]
Looking at the undefined references will probably help to figure out what should be mentioned in your case. You don't have to do this transitively, BTW, GHC(i) is cunning enough to do this itself, e.g. the "base" package depends on the "rts" package, but you don't have to specify this in your configuration file.
In fact I hadn't defined the dependencies. The package needs the TclHaskell package and this one needs lang which needs base. The conf file for my package now is as follows: Package {name = "CHD", auto = False, import_dirs = ["/usr/local/lib/ghc-6.2.1/hslibs-imports"], source_dirs = [], library_dirs = ["/usr/local/lib/ghc-6.2.1"], hs_libraries = ["HSCHD"], extra_libraries = [], include_dirs = [], c_includes = [], package_deps = ["TclHaskell"], extra_ghc_opts = [], extra_cc_opts = [], extra_ld_opts = [], framework_dirs = [], extra_frameworks = [] } Sadly defining the dependencies didn't solve the problem. I get this error message: Preprocess/PhilsLine.o(.text+0x13e): In function `s2We_entry': : undefined reference to `CHDziBaseTypes_CodePosition_con_info' Preprocess/PhilsLine.o(.text+0x25e): In function `s2W6_entry': : undefined reference to `CHDziBaseTypes_CodePosition_con_info' Preprocess/PhilsLine.o(.text+0x382): In function `s2VY_entry': : undefined reference to `CHDziBaseTypes_CodePosition_con_info' Preprocess/PhilsLine.o(.text+0x49e): In function `s2VP_entry': : undefined reference to `CHDziBaseTypes_CodePosition_con_info' Preprocess/PhilsLine.o(.text+0x6a1): In function `s2Yz_entry': : undefined reference to `CHDziBaseTypes_CodePosition_con_info' Preprocess/PhilsLine.o(.text+0x809): more undefined references to `CHDziBaseTypes_CodePosition_con_info' follow /usr/local/lib/ghc-6.2.1/libHSCHD.a(Concurrent.o)(.text+0x22): In function `__stginit_CHDziControlziConcurrent_': : undefined reference to `__stginit_CHDziBaseTypes_' /usr/local/lib/ghc-6.2.1/libHSCHD.a(Concurrent.o)(.text+0x36): In function `__stginit_CHDziControlziConcurrent_': : undefined reference to `__stginit_CHDziGuiMsgChan_' /usr/local/lib/ghc-6.2.1/libHSCHD.a(Concurrent.o)(.text+0x40): In function `__stginit_CHDziControlziConcurrent_': : undefined reference to `__stginit_CHDziGuiMain_' /usr/local/lib/ghc-6.2.1/libHSCHD.a(Concurrent.o)(.text+0x4a): In function `__stginit_CHDziControlziConcurrent_': : undefined reference to `__stginit_CHDziDebugMain_' /usr/local/lib/ghc-6.2.1/libHSCHD.a(Concurrent.o)(.text+0x54): In function `__stginit_CHDziControlziConcurrent_': : undefined reference to `__stginit_CHDziDebugMsgChan_' /usr/local/lib/ghc-6.2.1/libHSCHD.a(Concurrent.o)(.text+0x5e): In function `__stginit_CHDziControlziConcurrent_': : undefined reference to `__stginit_CHDziDebugInterface_' /usr/local/lib/ghc-6.2.1/libHSCHD.a(Concurrent.o)(.text+0xb8): In function `__stginit_CHDziControlziConcurrent_': : undefined reference to `CHDziDebugInterface_sendDebugMsg_closure' /usr/local/lib/ghc-6.2.1/libHSCHD.a(Concurrent.o)(.text+0x1c1): In function `s1jRH_entry': : undefined reference to `CHDziBaseTypes_CHD_con_info' /usr/local/lib/ghc-6.2.1/libHSCHD.a(Concurrent.o)(.text+0x1ce): In function `s1jRH_entry': : undefined reference to `CHDziBaseTypes_Identity_con_info' /usr/local/lib/ghc-6.2.1/libHSCHD.a(Concurrent.o)(.text+0x1db): In function `s1jRH_entry': : undefined reference to `CHDziDebugMsgChan_ThreadFork_con_info' /usr/local/lib/ghc-6.2.1/libHSCHD.a(Concurrent.o)(.text+0x1f7): In function `s1jRH_entry': : undefined reference to `CHDziDebugInterface_sendDebugMsg_closure' /usr/local/lib/ghc-6.2.1/libHSCHD.a(Concurrent.o)(.text+0x369): In function `s1jRv_entry': : undefined reference to `CHDziBaseTypes_Identity_con_info' /usr/local/lib/ghc-6.2.1/libHSCHD.a(Concurrent.o)(.text+0x376): In function `s1jRv_entry': : undefined reference to `CHDziDebugMsgChan_ThreadForkSuspend_con_info' /usr/local/lib/ghc-6.2.1/libHSCHD.a(Concurrent.o)(.text+0x38c): In function `s1jRv_entry': : undefined reference to `CHDziDebugInterface_sendDebugMsg_closure' /usr/local/lib/ghc-6.2.1/libHSCHD.a(Concurrent.o)(.text+0x472): In function `s1jR5_entry': ... [many more of these] ... collect2: ld returned 1 exit status

Jan Christiansen wrote:
[...] Sadly defining the dependencies didn't solve the problem. I get this error message:
Preprocess/PhilsLine.o(.text+0x13e): In function `s2We_entry': : undefined reference to `CHDziBaseTypes_CodePosition_con_info' Preprocess/PhilsLine.o(.text+0x25e): In function `s2W6_entry': : undefined reference to `CHDziBaseTypes_CodePosition_con_info' Preprocess/PhilsLine.o(.text+0x382): In function `s2VY_entry': : undefined reference to `CHDziBaseTypes_CodePosition_con_info' Preprocess/PhilsLine.o(.text+0x49e): In function `s2VP_entry': : undefined reference to `CHDziBaseTypes_CodePosition_con_info' Preprocess/PhilsLine.o(.text+0x6a1): In function `s2Yz_entry': : undefined reference to `CHDziBaseTypes_CodePosition_con_info' Preprocess/PhilsLine.o(.text+0x809): more undefined references to `CHDziBaseTypes_CodePosition_con_info' follow /usr/local/lib/ghc-6.2.1/libHSCHD.a(Concurrent.o)(.text+0x22): In function `__stginit_CHDziControlziConcurrent_': : undefined reference to `__stginit_CHDziBaseTypes_' [...]
All these undefined references ("zi" => ".") seem to be within your own package "CHD", but guessing what goes wrong exactly is a bit hard without further information. A complete log of what you are doing might help, a tar file including your sources would be even better (when building is as simple as "make" or the like). This is a general hint for people reporting non-trivial problems: Whenever possible, package up everything necessary for reproducing the problem in a way that a plain "make" suffices, and attach it to your problem report. Remember: This is a "lazy" mailing list... :-) Cheers, S.

On Sunday 18 April 2004 21:36, Sven Panne wrote:
All these undefined references ("zi" => ".") seem to be within your own package "CHD", but guessing what goes wrong exactly is a bit hard without further information. A complete log of what you are doing might help, a tar file including your sources would be even better (when building is as simple as "make" or the like). This is a general hint for people reporting non-trivial problems: Whenever possible, package up everything necessary for reproducing the problem in a way that a plain "make" suffices, and attach it to your problem report. Remember: This is a "lazy" mailing list... :-)
Here is the sourcecode and the Makefile I use. Just decompress the file and adjust LIBDIR and IMPORTS in the Makefile. "make" compiles the sources, "make install" copies the library and the interface files to the directories defined in LIBDIR and IMPORTS. A "make pkg" creates a CHD.conf and adds it to the package.conf by using ghc-pkg. A "make uninstall" and "make unpkg" removes all files and restores the original state, I hope. In the Test directory is a sourcefile called PhilsCHD.hs which uses the CHD package. A "ghc --make -package CHD PhilsCHD.hs -o PhilsCHD" causes the linking errors. Gruss Jan
participants (2)
-
Jan Christiansen
-
Sven Panne