On Wed, 27 Jan 2021 at 12:40, Alexander Monakov via Gcc-help <gcc-help@xxxxxxxxxxx> wrote: > > On Wed, 27 Jan 2021, Josef Wolf wrote: > > > $ m68k-unknown-elf-gcc -ansi -std=c89 -pedantic -Wall -Wcast-align \ > > -Wstrict-prototypes \ > > -Wmissing-prototypes -Wnull-dereference \ > > -O2 -g -fno-toplevel-reorder -mcpu32 \ > > -ffreestanding -static-libgcc -lgcc \ > > -Wl,--cref,--section-start=vectors=0 \ > > -nostdlib -Wl,-Ttext=0x400,--entry=entry \ > > -Wl,--oformat,elf32-m68k \ > > -Wl,--cref,-Map,bestd.map \ > > -Wl,-T,ldscript.ld \ > > -o output.elf `cat file.objs` > > > [...] > > What am I missinghere? Any help? > > On the command line, libraries need to come after object files that need them, > because when inspecting the library, the linker unpacks only those archived > object files that would satisfy some undefined symbol already required by > previously linked .o files. > > Therefore, in your command line above, -lgcc needs to come after `cat > file.objs`, not before. See http://c-faq.com/lib/libsearch.html