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.

OffTopic > HAM adding HAMlib junk

#3105 - peebrain - Tue Feb 18, 2003 8:43 am

So I'm just chilling with my editor and HAM devkit until I randomally decide to check out the actual binary HAM outputs. I do NOT use HAMlib, I never call ham_Init or whatever, I choose to re-invent the wheel. But in my binary I have all this hamlib stuff! What's up with that?! I got a ton of strings like:

Quote:

You cannot use Drawtext in BGMode 3-5 F_DISCNT_BGMODE_GET<3 ham_InitText: you can only run the HAM text system in BGMode 0-2 (F_DISCNT_BGMODE_GET<3) ham_InitText: in this BGMode, the bgno doesnt exist! try a different bgno (ham_GetBgType(bgno)!=0xFF) @ @ @@ @? @?tile.c ham_InitMapSet: Invalid input for map_rot !(map_rot>1) ham_InitMapSet:Invalid input for map_size !(map_size>3) ham_InitMapSet: the Map you want to load is bigger than map_size/map_rot specified. STOP! size_map_u16>=size_u16 ham_InsertMapFragment:You cannot combine a rot map with a non rot map.


I do not want this junk in my binary. Is there a way to remove HAMlib completely from the output file? Edit a make file or something? I love HAM, I hate HAMlib. Or should I just stick to DevKitAdv?

~Sean
_________________
http://www.pbwhere.com

#3107 - tubooboo - Tue Feb 18, 2003 10:25 am

just go into system/master.mak

and remove -lham from the linker configuration, thats all.

Emanuel
_________________
HAM author
http://www.ngine.de

#3130 - peebrain - Tue Feb 18, 2003 8:40 pm

Umm... tried something similiar to that. There is no -lham in master.mak but there is a bunch in standard-targets.mak. I edited one line like so:

From (line 120):
Code:

$(PROGNAME).elf : $(OFILES)
   $(LD) $(LDFLAGS) -o $(PROGNAME).elf $(OFILES) $(ADD_LIBS) -lafm -lham -lm -lc  -lstdc++ -lsupc++ -lgcc
endif


To:
Code:

$(PROGNAME).elf : $(OFILES)
#   $(LD) $(LDFLAGS) -o $(PROGNAME).elf $(OFILES) $(ADD_LIBS) -lafm -lham -lm -lc  -lstdc++ -lsupc++ -lgcc
   $(LD) $(LDFLAGS) -o $(PROGNAME).elf $(OFILES) $(ADD_LIBS) -lafm -lm -lc  -lstdc++ -lsupc++ -lgcc
endif


Then I get the following errors when I try to "make vba" it:
Code:

C:\gbadev\mystuff\pwase30>set PATH=C:\gbadev\ham\gcc-arm;C:\gbadev\ham\tools\win32;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem

C:\gbadev\mystuff\pwase30>set HAMDIR=C:\gbadev\ham

C:\gbadev\mystuff\pwase30>make vba
C:/gbadev/ham/gcc-arm/bin/arm-thumb-elf-as.exe   -mthumb-interwork  C:/gbadev/ham/system/crt0.s -ocrt0.o
C:/gbadev/ham/gcc-arm/bin/arm-thumb-elf-gcc.exe    -I C:/gbadev/ham/gcc-arm/include -I C:/gbadev/ham/gcc-arm/arm-thumb-elf/include -I C:/gbadev/ham/include -I C:/gbadev/ham/system  -c -DHAM_HAM  -DHAM_MULTIBOOT  -DHAM_ENABLE_MBV2LIB  -O2  -DHAM_WITH_LIBHAM  -mthumb-interwork -mlong-calls -Wall -save-temps -fverbose-asm  pwase30.cpp
C:/gbadev/ham/gcc-arm/bin/arm-thumb-elf-ld.exe    -L C:/gbadev/ham/gcc-arm/arm-thumb-elf/lib/normal -L C:/gbadev/ham/gcc-arm/lib -L C:/gbadev/ham/gcc-arm/lib/gcc-lib/arm-thumb-elf/3.0.4/normal --script C:/gbadev/ham/system/lnkscript-afm  -o pwase30.elf crt0.o C:/gbadev/ham/gcc-arm/lib/gcc-lib/arm-thumb-elf/3.0.4/normal/crtbegin.o C:/gbadev/ham/gcc-arm/lib/gcc-lib/arm-thumb-elf/3.0.4/normal/crtend.o  pwase30.o  -lafm -lm -lc  -lstdc++ -lsupc++ -lgcc
crt0.o: In function `IntrRet':
crt0.o(.text+0x308): undefined reference to `IntrTable'
C:/gbadev/ham/gcc-arm/lib/gcc-lib/arm-thumb-elf/3.0.4/normal/libgcc.a(__main.o): In function `__do_global_ctors':
__main.o(.text+0xd0): undefined reference to `atexit'
C:/gbadev/ham/gcc-arm/lib/gcc-lib/arm-thumb-elf/3.0.4/normal/libgcc.a(unwind-dw2-fde.o): In function `size_of_encoded_value':
unwind-dw2-fde.o(.text+0x60): undefined reference to `abort'
C:/gbadev/ham/gcc-arm/lib/gcc-lib/arm-thumb-elf/3.0.4/normal/libgcc.a(unwind-dw2-fde.o): In function `read_encoded_value_with_base':
unwind-dw2-fde.o(.text+0x1e0): undefined reference to `abort'
C:/gbadev/ham/gcc-arm/lib/gcc-lib/arm-thumb-elf/3.0.4/normal/libgcc.a(unwind-dw2-fde.o): In function `__register_frame':
unwind-dw2-fde.o(.text+0x284): undefined reference to `malloc'
C:/gbadev/ham/gcc-arm/lib/gcc-lib/arm-thumb-elf/3.0.4/normal/libgcc.a(unwind-dw2-fde.o): In function `__register_frame_table':
unwind-dw2-fde.o(.text+0x348): undefined reference to `malloc'
C:/gbadev/ham/gcc-arm/lib/gcc-lib/arm-thumb-elf/3.0.4/normal/libgcc.a(unwind-dw2-fde.o): In function `__deregister_frame_info_bases':
unwind-dw2-fde.o(.text+0x404): undefined reference to `free'
unwind-dw2-fde.o(.text+0x440): undefined reference to `abort'
C:/gbadev/ham/gcc-arm/lib/gcc-lib/arm-thumb-elf/3.0.4/normal/libgcc.a(unwind-dw2-fde.o): In function `__deregister_frame':
unwind-dw2-fde.o(.text+0x478): undefined reference to `free'
C:/gbadev/ham/gcc-arm/lib/gcc-lib/arm-thumb-elf/3.0.4/normal/libgcc.a(unwind-dw2-fde.o): In function `base_from_object':
unwind-dw2-fde.o(.text+0x4f0): undefined reference to `abort'
C:/gbadev/ham/gcc-arm/lib/gcc-lib/arm-thumb-elf/3.0.4/normal/libgcc.a(unwind-dw2-fde.o): In function `get_cie_encoding':
unwind-dw2-fde.o(.text+0x528): undefined reference to `strlen'
C:/gbadev/ham/gcc-arm/lib/gcc-lib/arm-thumb-elf/3.0.4/normal/libgcc.a(unwind-dw2-fde.o): In function `start_fde_sort':
unwind-dw2-fde.o(.text+0x1314): undefined reference to `malloc'
unwind-dw2-fde.o(.text+0x1338): undefined reference to `malloc'
C:/gbadev/ham/gcc-arm/lib/gcc-lib/arm-thumb-elf/3.0.4/normal/libgcc.a(unwind-dw2-fde.o): In function `end_fde_sort':
unwind-dw2-fde.o(.text+0x13f4): undefined reference to `free'
unwind-dw2-fde.o(.text+0x1434): undefined reference to `abort'
unwind-dw2-fde.o(.text+0x1438): undefined reference to `abort'
make: *** [pwase30.elf] Error 1
> Execution finished.


... any tips?

~Sean
_________________
http://www.pbwhere.com

#3133 - CoolMan - Tue Feb 18, 2003 9:35 pm

crt0.o(.text+0x308): undefined reference to `IntrTable' - Crt0 refers to a function pointer array which contains pointers to the various interrupt funcs. This array is called `IntrTable'. I guess HamLib defines IntrTable? (You can get an example of an IntrTable from www.thepernproject.com)

As for the other stuff... It looks like you can link in libc (newlib) to fix that. (libc should definately define 'malloc', 'free', and 'strlen'. I'm not sure about 'abort'.)

Hope that helps.
--Alex

(Feel free to correct me if I'm wrong.) :-)
_________________
Moron! You don't herd chickens with a shotgun!

--CoolMan

#3136 - peebrain - Tue Feb 18, 2003 9:46 pm

What if I don't want all that crap? I just want basic C/C++. No malloc, no free, no strlen, I can code those myself.

~Sean
_________________
http://www.pbwhere.com

#3144 - tepples - Tue Feb 18, 2003 11:04 pm

There is no such thing as "C/C++". Do you want basic C, or do you want basic C++? If you want basic C++, you're going to need some sort of malloc() to support operator 'new'.

The other stuff that's getting linked in seems to be called from the crt0. If you're not going to be using HAMlib, I'd suggest using Jeff F's crt0 instead of the one that comes with HAMlib.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#3148 - CoolMan - Wed Feb 19, 2003 1:55 am

According to thoes link errors...

The only thing that crt0 is referencing is IntrTable. This is as per Jeff's crt0 standard.

The other things are being referenced by libgcc. (the switch is "-lgcc")

If you get more link errors after taking out -lgcc, then your gonna need to figure out which lib is the culprit, and oust it. Unfortunately, methinks that this process will leave you with nothing in the lines of object oriented programming, or anything else externally useful. (Of course, if you truely want to 're-invent' the 'wheel', then you won't mind not having sin or cos, or any string manipulation funcs, etc.) :-\

Hope you get it working...
--Alex
_________________
Moron! You don't herd chickens with a shotgun!

--CoolMan

#3170 - Quirky - Wed Feb 19, 2003 11:42 am

Is this not partly the infamous "lib order matters" problem? I don't know why removing libham would make that much of a difference, but try placing -lm at the end. Could be wrong though.

#3178 - peebrain - Wed Feb 19, 2003 1:13 pm

Ok, something is really screwed up... I tried re-installing HAM and now it doesn't work at all. I don't know what I did wrong so I'm checking everything... *eyes wide open*

~Sean
_________________
http://www.pbwhere.com

#3179 - peebrain - Wed Feb 19, 2003 1:22 pm

Ooook, this is odd...:

If I leave in -lham and never declare IntrTable, no errors.

If I leave in -lham and declare an array IntrTable, I get the "malloc" errors, etc...

If I take out -lham and never declare IntrTable, I get the "malloc" errors, along with the: crt0.o(.text+0x308): undefined reference to `IntrTable'

If I take out -lham and declare an array IntrTable, I get the "malloc" errors.

~Sean
_________________
http://www.pbwhere.com

#3183 - CoolMan - Wed Feb 19, 2003 2:32 pm

Sounds like I'm very happy to be using devkitadv... :-\
_________________
Moron! You don't herd chickens with a shotgun!

--CoolMan

#3188 - Quirky - Wed Feb 19, 2003 4:03 pm

Just a thought: try linking with gcc instead of ld. i.e. test out "LD = gcc" in your make file...

#3190 - CoolMan - Wed Feb 19, 2003 5:44 pm

Using gcc (as a linker) is simply a frontend for ld.
_________________
Moron! You don't herd chickens with a shotgun!

--CoolMan