Search code examples
c++ld

ld: unrecognized -a option `tic-libstdc++' when using -static-libstdc++ in Makefile?


I am trying to link the "fstream" library to my kernel in C++. But linker has to have -static-libstdc++ in order for this to work (And G++). But when I go to compile, it says:

ld: unrecognized -a option `tic-libstdc++'

PS: I typed the whole thing (-static-libstdc++)

Does anybody know why this is happening? Here is my linker command:

ld -z max-page-size=0x1000 -Ttext=0x01000000 -static -Bsymbolic -static-libstdc++ -o $(TARGET) $(OBJS) build/GDT/GDTASM.o

Solution

  • -static-libstdc++ is a compiler option, not a linker option. You already set the linker to link the object files with static libraries (-static). Use -lstdc++:

    ld -z max-page-size=0x1000 -Ttext=0x01000000 -static -Bsymbolic -o $(TARGET) $(OBJS) build/GDT/GDTASM.o -lstdc++
    

    Libraries must be listed after object files.

    It is better if you do not use ld:

    g++ -static-libstdc++ -Wl,-z -Wl,max-page-size=0x1000 -Wl,-Ttext=0x01000000 -Wl,-Bsymbolic -o $(TARGET) $(OBJS) build/GDT/GDTASM.o