[mercury-users] Linking problem with type classes

Ondrej Bojar obo at cuni.cz
Mon Dec 4 11:12:13 AEDT 2006


Hi,

I'm facing a strange linking problem related to type classes:

Mercury/asm_fast.gc/i686-pc-linux-gnu/Mercury/os/transl.o(.rodata+0xbb8): 
undefined reference to `<instance declaration for 
treetable:trprovider(treetable:trtabdb/0)>'

The attached files main.m and treetable.m are reduced versions of my 
code. The idea is that treetable.m should define two different 
implementations of a 'translation provider', either a treetable or a 
trtabdb. For both of them, independent constructors are provided. The 
usage is exemplified in main.m: I can use any of the constructors and 
then use the find_translations/3 predicate from the trprovider typeclass 
to actually ask the respective provider.

This minimized sample *compiles and links fine*.

I have searched Mercury/asm_fast.gc/i686-pc-linux-gnu/Mercury/os/*.o 
with 'nm' to figure out the differences between the real code and the 
minized sample, but I do not know mmc's name mangling convention so it 
is hard to see what is missing on purpose and what is missing by mistake.

In the real code, the mmc options are a bit more complex. Maybe this 
might hint where the source of the linking problems is. This is part of 
my Makefile:

MCFLAGS= \
    --search-lib-files-dir $(HOME)/tools/obomerclib/ \
    --link-object 
$(HOME)/tools/obomerclib/Mercury/$(LIBGRADE)/*/Mercury/as/libtools.a \
    --search-lib-files-dir ./irstlm_use/ \
    --link-object irstlm_use/irstlm_cint.o \
    --link-object 
irstlm_use/Mercury/$(LIBGRADE)/*/Mercury/os/irstlm_mint.o \
    --link-object $(IRSTLM)/lib/libirstlm.a \
    --ld-flags -lgdbm

GRADE=--grade asm_fact.gc

%: %.o
         mmc $(MCFLAGS) $(GRADE) --make --use-grade-subdirs $@ \
           --link-executable-command=g++ \
           --verbose
%.o: %.m
         mmc $(MCFLAGS) $(GRADE) --make --use-grade-subdirs $@

Thanks for any suggestions,
   O.

-- 
Ondrej Bojar (mailto:obo at cuni.cz)
http://www.cuni.cz/~obo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: main.m
Type: text/x-objcsrc
Size: 552 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/users/attachments/20061204/db01f405/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: treetable.m
Type: text/x-objcsrc
Size: 1241 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/users/attachments/20061204/db01f405/attachment-0001.bin>


More information about the users mailing list