[Beginner]'Undefined reference to __main' error under Vista
Posted: Wed Feb 24, 2010 4:29 am
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) $<
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) $<