Linking trouble with Grubs' example kernel

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
gablooky

Linking trouble with Grubs' example kernel

Post by gablooky »

I've been experimenting with using the example multiboot 'kernel' that comes with Grub (the files are boot.S, kernel.c and multiboot.h, available here: http://savannah.gnu.org/cgi-bin/viewcvs/grub/grub/docs/) as a basis for my own developments, but I've snagged on a fairly simple thing. I've moved the printf, putchar, atoi and cls functions in the kernel.c file to a stdio.c file and written a header to accompany it. I include the header in the kernel.c file to access the functions, compile the lot with these:

   gcc -I. -c boot.S
   gcc -I. -fno-builtin -c stdio.c
   gcc -I. -fno-builtin -c kernel.c
   ld boot.o stdio.o kernel.o -o kernel -nostdlib -N -Ttext 0x100000

But I get this when compiling and ld executes:
   [stdio.c]
   stdio.c:11: warning: `cls' defined but not used

   [kernel.c]
   stdio.h:33: warning: `cls' used but never defined
   stdio.h:34: warning: `itoa' declared `static' but never defined
   stdio.h:35: warning: `putchar' declared `static' but never defined

   kernel.o(.text+0x7): In function 'cmain':
   : undefined reference to 'cls'

Any ideas what this is?
Moose

RE:Linking trouble with Grubs' example kernel

Post by Moose »

function cls is now referenced
you need to have something like global cls in the file holding it, and another one, extern cls maybe, in the file referencing it.

Moose.
Post Reply