Why does the order of linked object file with $L d

2019-06-27 09:09发布

I use statically linked sqlite database and in order to compile every next version I sometimes have to do minor changes in the list of object files used. But sometimes the changes I have to make puzzles me. For example prior to version 3_6_10 this order

{$L 'Objs\is.OBJ'}
{$L 'Objs\mbisspc.OBJ'}

was ok, but starting 3_6_12 the linker said

unsatisfied forward or external declaration _isspace

but changing the order to

{$L 'Objs\mbisspc.OBJ'}
{$L 'Objs\is.OBJ'}

helped. As for the changes in sqlite, it really stopped to use c function isspace in 3_6_12 and started to use an internal equivalent so "isspace" keyword even don't appear inside the obj file.

So why does the order of linked object file with $L directive matter and where I can read more about this? I suppose it is something related to cross-usage of the listed obj files, but I will feel more safe if I understand what is going on

Thanks

1条回答
男人必须洒脱
2楼-- · 2019-06-27 09:57

Edit:

As of the comment by David Heffernan linking to his answer to this other question on linking .obj file in Delphi, I replaced linker by compiler, and added a the italic portion below:

C compilers use a multi-pass linker compiler that knows how to resolve forward and circular dependencies between .obj files.

Since the Delphi linker compiler is targeted at the Delphi language, and the Delphi language does not allow for that, the linker compiler does not allow for this either.

Pro: the linker compiler is much faster.

Con: you need to help the linker compiler a bit by placing the .obj files in the right order
, or by manually resolving the dependencies (see the above mentioned answer by David Heffernan) .

--jeroen

查看更多
登录 后发表回答