Reputation: 104
I am following a tutorial to create an operating system in C (and a little assembly), and since most of this stuff is done on linux I am having a hard time getting the various tools to work on windows. So far I am just trying to compile the code from the tutorial, and I haven't made any changes yet. This is the kernel (which gets loaded by an asm bootsector):
void dummy_test_entrypoint() {
}
void main() {
char* video_memory = (char*) 0xb8000;
*video_memory = 'X';
}
I am instructed to compile this using a gcc cross-compiler. And when I try to use the i386-elf-gcc windows binaries: link using the command:
i386-elf-gcc -ffreestanding -c kernel.c -o kernel.o
it gives me the error:
i386-elf-gcc: error: spawn: No such file or directory
This issue seems to be known, though I have no idea what that means. Any help would be appreciated.
Upvotes: 1
Views: 1630
Reputation: 11
It might be best to install WSL2 on Windows. WSL2 is Linux running on Windows, and is completely compatible with gcc
(and i386-elf-gcc
). I have personally used it myself and have found no issues using it once I installed it.
Then, you can build i386-elf-gcc
and i386-elf-ld
using this shell script. i386-elf-g++
will also be built, so you can also write your OS in C++.
Make sure whenever you restart WSL2, you have /usr/local/i386elfgcc/bin/
added to you path. If it is not, you will get -bash: i386-elf-gcc: command not found
. You can make sure this never happens by adding the following line to ~/.bashrc
:
export PATH="/usr/local/i386elfgcc/bin/:$PATH"
EDIT: Remember to use the -nostdlib
flag when compiling C source files!
Upvotes: 0