Linker can't resolve any references

Kai Ruottu kai.ruottu@wippies.com
Wed Jun 23 14:30:00 GMT 2010


23.6.2010 12:19, Bob Cowdery kirjoitti:

> Kai Ruottu wrote:
>> 23.6.2010 10:51, Kai Ruottu kirjoitti:
>>
>>>>> Bob Cowdery<bob@bobcowdery.plus.com>  writes:
>>>>>
>>>>>> This is such a basic problem I must be doing something daft. I have a
>>>>>> set of static libraries which I am linking into a dll. None of the
>>>>>> external references seem to be getting resolved. This is on Win7
>>>>>> and I
>>>>>> have MinGW and msys installed using the msys make.
>>>
>>> I would check the instructions for creating DLLs...
>
> All good ideas but unfortunately the test I did used a standard 'Hello
> World' exe into which I dragged in two static libraries. With no
> references from my main code to the libraries it built and the size was
> 20k. If I then made a call to one of the libraries (call this libA)
> where there were no other dependencies it again built and the size was
> 21k. If I then commented out the call to libA and made a call to the
> second library (call this libB) the size was 30k but I got undefined
> references for all the calls from libB to libA (from the size libA is
> now not being linked in). If I kept in both the calls the size was 31k
> and it built ok. Weird or what!

If I understood you right, you didn't use '-lA' for linking in 'libA.a'
although your 'libB.a' had calls to 'libA.a'. In that case the undefined
references to functions in 'libA.a' are fully normal and expected. In
this case the link command should have '-lB -lA', using '-lA -lB' would
not work. If 'libA.a' needs something from 'libB.a', then the link
command should have '-lB -lA -lB'. If the new link takes more functions
from 'libB' which need more functions from 'libA' then the link command
should have '-lB -lA -lB -lA'... And so on until all the undefined
symbols have been resolved...

So the case was about creating the DLL, not using it after it's
creation, I first saw the error coming from the next phase, that '-v'
caused two 'gcc' commands being seen :(



More information about the Gcc-help mailing list