gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Beginners > A linker error building some GBA examples

#46861 - avelino - Fri Jul 01, 2005 11:52 am

Hi, all, I am ussing devkitpro (release 13) and followed all installation instructions on my Linux box but I am getting a linker error compiling the PCXView example for GBA:

Code:
splash.pcx
pcx_view.c
linking multiboot
pcx_view.o: In function `main':
/root/gba/examples/gba/PCXView/src/pcx_view.c:56: undefined reference to
`splash_pcx'
collect2: ld returned 1 exit status
make[1]: *** [/root/gba/examples/gba/PCXView/PCXView_mb.elf] Error 1
make: *** [build] Error 2


With the PlayBoyScout example there is a simmilar error:

Code:
ScoutSplash.pcx
tune.bgf
PlayBoyScout.c
linking multiboot
PlayBoyScout.o: In function `main':
/root/gba/examples/gba/PlayBoyScout/source/PlayBoyScout.c:74: undefined
reference to `tune_bgf'
/root/gba/examples/gba/PlayBoyScout/source/PlayBoyScout.c:74: undefined
reference to `ScoutSplash_pcx'
collect2: ld returned 1 exit status
make[1]: *** [/root/gba/examples/gba/PlayBoyScout/PlayBoyScout_mb.elf]
Error 1
make: *** [build] Error 2


I think that it could be a bin2o related problem because that program converts pcx/binary files to object ones. By the way, the "mbv2print" example compiles and links ok but when I run the "sprite.gba" generated using que "VisualBoyAdvance", the result is a white screen in the emulator (no text displayed) . Please, help.

Thanks in advance.
_________________
Avelino Herrera Morales
http://avelino.gabiot.com

#46877 - Fatnickc - Fri Jul 01, 2005 5:58 pm

Perhaps, for the second one, try replacing the '_'s with '.'s.

#46908 - tepples - Fri Jul 01, 2005 11:04 pm

Most of the 'bin2*' utilities transform filename dots into underscores because unlike the dot, the underscore works in a C symbol name. And it might be spitting out a symbol name other than what you expect; try using the 'nm' command on the .o file.

What command is executed under 'linking multiboot'?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#47016 - avelino - Sun Jul 03, 2005 2:10 pm

Hi all

tepples wrote:
Most of the 'bin2*' utilities transform filename dots into underscores because unlike the dot, the underscore works in a C symbol name. And it might be spitting out a symbol name other than what you expect; try using the 'nm' command on the .o file.


Thanks very much for the idea :-). I finally found the problem with the "nm": the bin2o generates a symbol name ussing the *ENTIRE* path of the binary file not the file name. I edited the resulting .h, I changed the variable definitions and the code linked and run ok :-). Thank you very much! ^_^
_________________
Avelino Herrera Morales
http://avelino.gabiot.com

#47070 - Quirky - Mon Jul 04, 2005 7:26 pm

I had completely forgotten about that novel effect - it had me stumped for ages a while back. I now use a Makefile in the image directory, so that the symbol names are not path dependent.

#49258 - zazery - Wed Jul 27, 2005 9:52 pm

I decided to build this example to give me an idea of how to include graphic files without converting them into C-arrays. However, I get the following error:
Code:
F:\GBA\Projects\examples\gba\PCXView>make
make[1]: *** No rule to make target `splash.o', needed by `/f/GBA/Projects/examp
les/gba/PCXView/PCXView_mb.elf'.  Stop.
make: *** [build] Error 2

Some more information:
-I installed devkitARM, msys and libgba yesterday using the links from devkitPro's web page.

Environment variables:
-LIBGBA = /c/devkitPro/libgba/include;/c/devkitPro/libgba/lib;
-DEVKITPRO = /c/devkitPro
-DEVKITARM = /c/devkitPro/devkitARM
-Path = C:\msys\1.0\bin;c:\devkitPro\devkitARM\bin; (plus other application paths)

Over the past few days I have been learning a bit more about makefiles, however I haven't quite grasped everything yet. I have noticed that bin2o was changed from darkfader's bin2o program into a rule in the file base_rules so I assume that the makefile in the PCXView folder would automatically generate the splash_pcx.h and the object file. Am I wrong?

It's probably something very obvious but I haven't been able to figure it out. Below are some other errors when building the other examples:

mbv2print & XbooLoad: no problems.

PlayBoyScout:
Code:
F:\GBA\Projects\examples\gba\PLAYBO~1>make
make[1]: *** No rule to make target `ScoutSplash.o', needed by `/f/GBA/Projects/
examples/gba/PLAYBO~1/PlayBoyScout_mb.elf'.  Stop.
make: *** [build] Error 2


SimpleBGScroll:
Code:
F:\GBA\Projects\examples\gba\SIMPLE~1>make
main.c
f:/GBA/Projects/examples/gba/SIMPLE~1/source/main.c:47:32: r6502_portfont_bin.h:
 No such file or directory
f:/GBA/Projects/examples/gba/SIMPLE~1/source/main.c: In function `main':
f:/GBA/Projects/examples/gba/SIMPLE~1/source/main.c:215: error: `r6502_portfont_
bin' undeclared (first use in this function)
f:/GBA/Projects/examples/gba/SIMPLE~1/source/main.c:215: error: (Each undeclared
 identifier is reported only once
f:/GBA/Projects/examples/gba/SIMPLE~1/source/main.c:215: error: for each functio
n it appears in.)
make[1]: *** [main.o] Error 1
make: *** [build] Error 2

#49312 - strager - Thu Jul 28, 2005 1:14 pm

zazery wrote:
Some more information:
-I installed devkitARM, msys and libgba yesterday using the links from devkitPro's web page.


Did you download the base rules fix? There was a little problem with the b2o (the entire path was being put into the variable) and was fixed a few days after r13 of DevKitARM.

And try a 'make clean'. It worked for me when I tried it with the GBA examples (for some reason).

#49330 - zazery - Thu Jul 28, 2005 7:54 pm

Edit: I have created a quick html page outlining the steps I took to completely install everything on a computer with no prior gba development tools. The issue wasn't resolved and I recieved the same errors. Click here to see the html file. I have also included the example, gba_rules, and base_rules files at the bottom of the page.
[end of edit]

strager wrote:
Did you download the base rules fix? There was a little problem with the b2o (the entire path was being put into the variable) and was fixed a few days after r13 of DevKitARM.


I remember reading that post, however I have devkitARM r14 installed. To make sure it wasn't the problem I have just downloaded devkitARM r14 4.0.1 (had just devkitARM 14 before), libgba-20050615 and the examples(from the CVS), same problem.

Here is the bin2o rule of base_rules: (file last modified: Thursday, July 21, 2005, 3:18:20 PM)
Code:
define bin2o
   padbin 4 $(<)
   $(OBJCOPY) -I binary -O elf32-littlearm -B arm \
   --rename-section .data=.rodata,readonly,data,contents,alloc \
   --redefine-sym _binary_`(echo $(<) | sed -e 's/^\/\([a-zA-Z]\/\)/\1_/' | tr . _ | tr / _)`_start=`(echo $(<F) | tr . _)`\
   --redefine-sym _binary_`(echo $(<) | sed -e 's/^\/\([a-zA-Z]\/\)/\1_/' | tr . _ | tr / _)`_end=`(echo $(<F) | tr . _)`_end\
   --redefine-sym _binary_`(echo $(<) | sed -e 's/^\/\([a-zA-Z]\/\)/\1_/' | tr . _ | tr / _)`_size=`(echo $(<F) | tr . _)`_size\
   $(<) $(@)
   echo "extern const u32" `(echo $(<F) | tr . _)`"_end[];" > `(echo $(<F) | tr . _)`.h
   echo "extern const u8" `(echo $(<F) | tr . _)`"[];" >> `(echo $(<F) | tr . _)`.h
   echo "extern const u32" `(echo $(<F) | tr . _)`_size[]";" >> `(echo $(<F) | tr . _)`.h
endef

strager wrote:
And try a 'make clean'. It worked for me when I tried it with the GBA examples (for some reason).

I tried to 'make clean', however all that does for me is clean out the o files etc. is it supposed to do something else?