Is it me, or is it GNU?
Posted: Fri Oct 22, 2010 1:48 pm
Hello everybody!
This is my first post, so please be gentle with me . I guess it's a nice gesture to briefly introduce myself, since I hope I will spend a lot of time here in the future. I'm not very good with forums.
My name is Jacob and I come from the, hopefully, well known country Sweden. I study games programming and would like to consider myself as a fairly good programmer. I have an arguably good insight in many fields of technology, though I have a quite limited knowledge in hardware. That is why I've started a little hobby kernel/OS project(the quantity, and quality, of the information here is tremendously great).
I will now try and get to the point.
I'm using Cygwin in windows 7 and everything is compiled, assembled and linked using makefiles, gcc, ar, ld, and nasm.
I've gone through the process of making a cross-compiler. I've made a good(good enough for me anyway) directory structure and followed Bran's kernel tutorial loosely, but I've done things my own way. I've not finished the hole tutorial, but the problem isn't the programming it's the linking.
I'm using a recursive makefile structure, and found the concept of archiving my sub-directories into dirname.a files easier to handle in lower-level makefiles(I don't yet know if this is a good strategy). I don't know if my problem is cygwin, gnu or me-being-better-at-cpp-than-c.
I'm very sorry for this very bad and long description of my problem. I think it is because of my bad English
/********THE PROBLEM IS DOWN BELOW IF YOU ARE ALREADY BORED TO DEATH*******/
I have a file src/drivers/char/screen.c which defines and implements the puts(const char*) function and the init_screen_d() function, amongst others. In my main I try to call those functions. screen.c has a header file which declares those functions with the keyword extern.
When I try to link all my made object files and my single archive i get this error:
At first i thought it was some sort of a symbol problem because of the composed archive(I used the $(TARGET)-ar archiver to archive the screen.o, for future ease of use). But turning the --verbose mode on the linker it said it read both the archive and the containing .o file correctly. The archive is listed last when linking, and I've also tried the flags --start-group archive --end-group, thinking it still wasn't reading it correctly. This produces another error:
The strangest part is that the function init_screen_d() links perfectly fine(commenting out puts()), even though they are declared and implemented similarly. I've of course checked endlessly for typos.
Running ld with the flag --trace-symbol=puts, ld says that it finds the declarations and the definition.
What could be wrong/is wrong? Your help will force my endless gratitude!
This is my first post, so please be gentle with me . I guess it's a nice gesture to briefly introduce myself, since I hope I will spend a lot of time here in the future. I'm not very good with forums.
My name is Jacob and I come from the, hopefully, well known country Sweden. I study games programming and would like to consider myself as a fairly good programmer. I have an arguably good insight in many fields of technology, though I have a quite limited knowledge in hardware. That is why I've started a little hobby kernel/OS project(the quantity, and quality, of the information here is tremendously great).
I will now try and get to the point.
I'm using Cygwin in windows 7 and everything is compiled, assembled and linked using makefiles, gcc, ar, ld, and nasm.
I've gone through the process of making a cross-compiler. I've made a good(good enough for me anyway) directory structure and followed Bran's kernel tutorial loosely, but I've done things my own way. I've not finished the hole tutorial, but the problem isn't the programming it's the linking.
I'm using a recursive makefile structure, and found the concept of archiving my sub-directories into dirname.a files easier to handle in lower-level makefiles(I don't yet know if this is a good strategy). I don't know if my problem is cygwin, gnu or me-being-better-at-cpp-than-c.
I'm very sorry for this very bad and long description of my problem. I think it is because of my bad English
/********THE PROBLEM IS DOWN BELOW IF YOU ARE ALREADY BORED TO DEATH*******/
I have a file src/drivers/char/screen.c which defines and implements the puts(const char*) function and the init_screen_d() function, amongst others. In my main I try to call those functions. screen.c has a header file which declares those functions with the keyword extern.
When I try to link all my made object files and my single archive i get this error:
Code: Select all
main.c:(.text+0x1f): undefined reference to 'puts'
Code: Select all
drivers/char/char.a: could not read symbols: Bad value
Running ld with the flag --trace-symbol=puts, ld says that it finds the declarations and the definition.
What could be wrong/is wrong? Your help will force my endless gratitude!