I am writing a C++ kernel for my own hobby operating system. I work on a mac, and compiled a working (until now) cross-compiler out of gcc version 4.8.2.
Currently I have a kernel.cpp
file, containing only a main()
function and when I compile and link only this file, everything works fine. However, when I add a class, in a different file, the linker starts complaining:
/opt/cross/gcc-i686-elf/lib/gcc/i686-elf/4.8.2/../../../../i686-elf/bin/ld: cannot find -lstdc++
/opt/cross/gcc-i686-elf/lib/gcc/i686-elf/4.8.2/../../../../i686-elf/bin/ld: cannot find -lm
/opt/cross/gcc-i686-elf/lib/gcc/i686-elf/4.8.2/../../../../i686-elf/bin/ld: cannot find -lc
/opt/cross/gcc-i686-elf/lib/gcc/i686-elf/4.8.2/../../../../i686-elf/bin/ld: cannot find -lc
I found out that these are all missing standard libraries, right?
One interesting detail is, that when I add the same class to the kernel.cpp
instead of to a new file, it works like a charm.
Can anyone help me with where I should find these libraries, and how I can get them if they are not available? Should they have come with the cross-compiler or should they have already be available on my macOS?
This is how I build my code:
i686-elf-g++ -Wall -ffreestanding -m32 vga/vga.cpp kernel.cpp -o kernel.bin
Any help is welcome, thanks!