[mercury-users] Order of --link-object args
Zoltan Somogyi
zs at csse.unimelb.edu.au
Fri Aug 20 12:30:47 AEST 2010
On 20-Aug-2010, Ondrej Bojar <bojar at ufal.mff.cuni.cz> wrote:
> I'm linking against a library originally implemented in C and against a
> Mercury wrapper library (not "installed"). If I run:
>
> mmc --make \
> ...
> --link-object lib-the-c-one.a \
> --link-object lib-the-wrapper.a \
> target
>
> I get lot of undefined references to symbols actually present in
> lib-the-c-one.a (I double checked with nm).
>
> If I reorder the two --link-object arguments, it links correctly:
>
> mmc --make \
> ...
> --link-object lib-the-wrapper.a \
> --link-object lib-the-c-one.a \
> target
Basically, the order in which you supply things to be linked is the order
in which mmc gives those things to the linker. If the linker has not seen
any reference to any of the symbols defined by lib-the-c-one.a when it
processes lib-the-c-one.a, then it won't pull any object files from
lib-the-c-one.a into the executable. By the time it sees such references
in lib-the-wrapper.a, it is too late; the linker never goes back to process
a previously processed library again.
This behavior is WHY mmc allows you to control the order of libraries to be
linked by naming them in the order you want them to be given to the linker.
Zoltan.
--------------------------------------------------------------------------
mercury-users mailing list
Post messages to: mercury-users at csse.unimelb.edu.au
Administrative Queries: owner-mercury-users at csse.unimelb.edu.au
Subscriptions: mercury-users-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the users
mailing list