Hi, I have read the article "Genesis" at http://www.jamesmolloy.co.uk/tutorial_h ... nesis.html
When I try to link the two files boot.o and main.o, I got the following infomation:
C:\users\sharlith\backup\nasm\nasm -f elf boot.s
gcc -nostdlib -nostdinc -fno-builtin -fno-stack-protector -c main.c
main.c:1: warning: 'struct multiboot' declared inside parameter list
main.c:1: warning: its scope is only this definition or declaration, which is probably not what you want
ld Link.ld -o kernel boot.o main.o
main.o:main.c:(.text+0x7): undefined reference to `__main'
make: *** [link] Error 1
Can anyone tell me how to solve this problem? Thanks!
Here is the version info of my gcc:
Built by Equation Solution <http://www.Equation.com>.
Using built-in specs.
Target: i386-pc-mingw32
Configured with: ../gcc-4.4.0-mingw/configure --host=i386-pc-mingw32 --build=x86_64-unknown-linux-gnu --target=i386-pc-mingw32 --prefix=/home/gfortran/gcc-home/binary/mingw32/native/x86_32/gcc/4.4.0 --with-gcc --with-gnu-ld --with-gnu-as --disable-shared --disable-nls --disable-tls --with-gmp=/home/gfortran/gcc-home/binary/mingw32/native/x86_32/gmp --with-mpfr=/home/gfortran/gcc-home/binary/mingw32/native/x86_32/mpfr --enable-languages=c,fortran,c++ --with-sysroot=/home/gfortran/gcc-home/binary/mingw32/cross/x86_32/gcc/4.4.0 --enable-libgomp --enable-threads=win32 --disable-win32-registry
Thread model: win32
gcc version 4.4.0 (GCC)
And my Makefile:
SOURCES = boot.o main.o
CFLAGS = -nostdlib -nostdinc -fno-builtin -fno-stack-protector
LDFLAGS = Link.ld
ASFLAGS = -f elf
main.o: main.c
gcc $(CFLAGS) -c main.c
all: $(SOURCES) link
clean:
-del *.o kernel
link:
ld $(LDFLAGS) -o kernel $(SOURCES)
.s.o:
C:\users\sharlith\backup\nasm\nasm $(ASFLAGS) $<
[Beginner]'Undefined reference to __main' error under Vista
- thepowersgang
- Member
- Posts: 734
- Joined: Tue Dec 25, 2007 6:03 am
- Libera.chat IRC: thePowersGang
- Location: Perth, Western Australia
- Contact:
Re: [Beginner]'Undefined reference to __main' error under Vista
Simple answer, you forgot a semicolon before the definition of struct multiboot
(Either that, or you used "struct multiboot *mb" in the arguments to your main)
With the linker error, check the underscore settings and try doing an objdump on the object files to find out what the true name of the main function is.
(Either that, or you used "struct multiboot *mb" in the arguments to your main)
With the linker error, check the underscore settings and try doing an objdump on the object files to find out what the true name of the main function is.
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: [Beginner]'Undefined reference to __main' error under Vista
There goes the frequently asked question: GCC Cross-Compiler