After writing a bootloader and getting it to jump to a Hello World "kernel" written in assembly, I want to give it a go with a "kernel" written in D. I'm using GDC because I didn't have much luck with making DMD skip the D runtime and standard libs.

Starting with this code:

    void main() { }

Compiling it like this:

i686-gdcproject-mingw32-gdc.exe kernel.d -o "../bin/kernel.bin" -nophoboslib -nostdlib -s


This is the output:
kernel.d:(.text+0xa): undefined reference to `__main'
kernel.d:(.text+0x24): undefined reference to `_d_run_main'
(.text+0x38): undefined reference to `_Dmodule_ref'
(.text+0x43): undefined reference to `_Dmodule_ref'

According to http://stackoverflow.com/questions/13573289/how-to-compile-d-application-without-the-d-runtime I need something more like this:

    extern(C) __gshared void* _Dmodule_ref;
    extern(C) int main() { return 0; }

Now this is the output:
kernel.d:(.text+0x7): undefined reference to `__main'

So I have two problems here. The first one is that it's not working. The second one is that I'm copy pasting code, and perhaps by trying a bunch of variations I'll manage to get something that compiles, but I probably still won't understand what I'm doing and why it does or does not work.

Now I'm hoping that someone can give me a hand with working code, and also explain the reasoning behind it.

Reply via email to