Link Problem

Fawzi Mohamed fmohamed at mac.com
Thu Apr 2 06:06:32 PDT 2009


On 2009-04-02 14:52:40 +0200, TomD <t_demmer at nospam.web.de> said:

> davidl Wrote:
> 
> [...]
>> You're sure that's a linking problem?
>> GDC only use DMD frontend, so if it's a linking problem it should be ld's.
>> 
>> LD seems to behave absurdly that it expects to resolve symbols.
>> e.g.
>> a.o provides symbol c, and b.o needs symbol c
>> you'd better feed ld with: b.o a.o not a.o b.o
> 
> dmd also uses gcc (and hence ld) as linker, so if it is an ld
> problem, it'll stay. The behavior you mention above is only
> true for library files, AFAIK, not for objects. You should have
> all objects before the libraries, though.
> 
> Ciao
> TomD

simply put ld scans for symbols in libraries in the order they appear, 
if liba uases symbolsy from libb you should like them as -L-la -L-lb.
Normally it is not difficult to achieve this, but as workaround you dan 
also tell the linker to recursively search also in the previous 
libraries, this slows the linking, but will allow any order in the 
libraries, even circular dependencies (that you would otherwise need to 
break liking libraries more than once).

Simply pass --start-group *all the libs* --end-group to the linker 
(i.e. -L--start-group to the compiler)
and (if your problem really came from this) it will go away

Fawzi




More information about the Digitalmars-d mailing list