G++ driver missing option when sending to collect2

Yeting Kuo fakepaper56@gmail.com
Fri Feb 26 01:57:34 GMT 2021


There is a command like 'g++ -nostartfiles -Wl,--start-group arduino.ar -lc
-Wl,--end-group ...' would go wrong. `-nostartfiles` makes libc needs some
implements like _init in arduino.ar, but also arduino.ar depends on libc
too. G++ will output an error 'FAIL: undefined reference to _init' when g++
removes the `-lc`.

Jonathan Wakely <jwakely.gcc@gmail.com> 於 2021年2月25日 週四 下午3:23寫道:

>
>
> On Thu, 25 Feb 2021, 02:46 Yeting Kuo via Gcc-help, <gcc-help@gcc.gnu.org>
> wrote:
>
>> Hi all,
>> I have a compiler driver issue when using g++. I want to check whether it
>> is a bug.
>> I send '-Wl,--start-group x.o -lc -Wl,--end-group' to g++, but the command
>> collect2 received is '--start-group x.o --end-group' like the following
>> commands:
>>
>
>
> Does it cause a problem? The g++ driver automatically links to libstdc++
> and that depends on libc, so the -lc argument has to be after -lstdc++.
> Otherwise for static linking the linker could open libc.a before it knows
> about the symbols that libstdc++.a needs from it.
>
>
>
>


More information about the Gcc-help mailing list