Search code examples
ats

How to solve undefined reference to dynloadflag?


My exact error link-time error is:

print.o: In function `_057_home_057_brandon_057_workspace_057_fsh_057_print_056_dats__dynload':
/home/brandon/workspace/fsh/print_dats.c:315: undefined reference to `_057_home_057_brandon_057_workspace_057_fsh_057_print_056_dats__dynloadflag' 

The contents of print.dats is simply:

typedef FormatStruct = $extype"Format"

vtypedef Format(ll: addr) = (FormatStruct @ ll | ptr ll)

extern fun fmtputc{ll: addr}(fmt: Format(ll), cc: int): void = "mac#"

I have another dats file (main.dats) that doesn't seem to cause this issue. Is there some ATS library that needs to be added to LDFLAGS?


Solution

  • Every DATS file in ATS is considered a module of some sort, which needs to be initialized. If no initialization is needed, then you need to add the following line in this DATS file

    #define ATS_DYNLOADFLAG 0

    Otherwise, you need to have a line like the following one

    #dynload "/path/to/foo.dats"

    in the main file where this module is used.