noob compiling issues

HunterZ
Posts: 19
Joined: Mon Sep 12, 2011 3:58 am
Location: Seattle

noob compiling issues

Post by HunterZ » Mon Sep 12, 2011 4:05 am

I just set up devkitPPC, plus portlibs, libogc, SDL-Wii etc. and am trying to get started on a Wii port of an open-source SDL-based game. I'm currently at the point where it compiles, but I'm getting linker errors that I don't understand:

Code: Select all

/bin/bash ../libtool --tag=CXX   --mode=link powerpc-eabi-g++  -g -O2 -O2 -fno-strength-reduce -fomit-frame-pointer -g -Wall -Wpointer-arith -Wcast-align -Wcast-qual -Wsign-compare   -o abuse matrix.o timer.o specache.o netcfg.o innet.o chat.o endgame.o loadgame.o profile.o cop.o statbar.o compiled.o ant.o sensor.o demo.o lcache.o nfclient.o clisp.o gui.o transp.o collide.o property.o cache.o particle.o objects.o extend.o console.o ability.o items.o dev.o chars.o level.o smallfnt.o automap.o help.o intsect.o loader2.o seq.o points.o fnt6x13.o morpher.o menu.o director.o view.o configuration.o game.o light.o devsel.o crc.o gamma.o volumewindow.o lisp/liblisp.a sdlport/libsdlport.a imlib/libimlib.a net/libnet.a -L/opt/devkitpro/libogc/lib -L/opt/devkitpro/portlibs/ppc/lib -lSDL_net -lSDL_ttf -lSDL_gfx -lSDL_mixer -lSDL_image -lsmpeg -lSDL -ljpeg -lpng -lfreetype -lvorbisidec -lz -lfat -lwiiuse -lbte -logc -lm -lwiikeyboard
libtool: link: warning: library `/opt/devkitpro/portlibs/ppc/lib/libjpeg.la' was moved.
libtool: link: warning: library `/opt/devkitpro/portlibs/ppc/lib/libpng.la' was moved.
libtool: link: warning: library `/opt/devkitpro/portlibs/ppc/lib/libfreetype.la' was moved.
libtool: link: warning: library `/opt/devkitpro/portlibs/ppc/lib/libvorbisidec.la' was moved.
libtool: link: warning: library `/opt/devkitpro/portlibs/ppc/lib/libjpeg.la' was moved.
libtool: link: warning: library `/opt/devkitpro/portlibs/ppc/lib/libpng.la' was moved.
libtool: link: warning: library `/opt/devkitpro/portlibs/ppc/lib/libfreetype.la' was moved.
libtool: link: warning: library `/opt/devkitpro/portlibs/ppc/lib/libvorbisidec.la' was moved.
libtool: link: powerpc-eabi-g++ -g -O2 -O2 -fno-strength-reduce -fomit-frame-pointer -g -Wall -Wpointer-arith -Wcast-align -Wcast-qual -Wsign-compare -o abuse matrix.o timer.o specache.o netcfg.o innet.o chat.o endgame.o loadgame.o profile.o cop.o statbar.o compiled.o ant.o sensor.o demo.o lcache.o nfclient.o clisp.o gui.o transp.o collide.o property.o cache.o particle.o objects.o extend.o console.o ability.o items.o dev.o chars.o level.o smallfnt.o automap.o help.o intsect.o loader2.o seq.o points.o fnt6x13.o morpher.o menu.o director.o view.o configuration.o game.o light.o devsel.o crc.o gamma.o volumewindow.o  lisp/liblisp.a sdlport/libsdlport.a imlib/libimlib.a net/libnet.a -L/opt/devkitpro/libogc/lib -L/opt/devkitpro/portlibs/ppc/lib -lSDL_net -lSDL_ttf -lSDL_gfx -lSDL_mixer -lSDL_image -lsmpeg -lSDL /opt/devkitpro/portlibs/ppc/lib/libjpeg.a /opt/devkitpro/portlibs/ppc/lib/libpng15.a /opt/devkitpro/portlibs/ppc/lib/libfreetype.a -L/opt/devkitpro/ppc/lib /opt/devkitpro/portlibs/ppc/lib/libvorbisidec.a -lz -lfat -lwiiuse -lbte -logc -lm -lwiikeyboard
/opt/devkitpro/libogc/lib/libogc.a(console.o):(.rodata.color_table+0x0): multiple definition of `color_table'
loader2.o:/opt/devkitpro/projects/abuse/abuse-trunk/src/loader2.cpp:78: first defined here
/opt/devkitpro/devkitPPC/lib/gcc/powerpc-eabi/4.6.1/../../../../powerpc-eabi/bin/ld: Warning: size of symbol `color_table' changed from 4 in loader2.o to 64 in /opt/devkitpro/libogc/lib/libogc.a(console.o)
/opt/devkitpro/libogc/lib/libogc.a(ogc_crt0.o): In function `_start':
(.init+0x0): multiple definition of `_start'
/opt/devkitpro/devkitPPC/lib/gcc/powerpc-eabi/4.6.1/../../../../powerpc-eabi/lib/crt0.o:/home/davem/projects/devkitpro/buildscripts/powerpc-eabi/newlib/powerpc-eabi/libgloss/rs6000/crt0.S:62: first defined here
/opt/devkitpro/libogc/lib/libogc.a(ogc_crt0.o): In function `startup':
(.init+0x36): undefined reference to `__isIPL'
/opt/devkitpro/libogc/lib/libogc.a(ogc_crt0.o): In function `startup':
(.init+0x3a): undefined reference to `__isIPL'
/opt/devkitpro/libogc/lib/libogc.a(ogc_crt0.o): In function `startup':
(.init+0x6e): undefined reference to `__bss_end'
/opt/devkitpro/libogc/lib/libogc.a(ogc_crt0.o): In function `startup':
(.init+0x72): undefined reference to `__bss_end'
/opt/devkitpro/libogc/lib/libSDL.a(SDL_wii_main.o): In function `main':
c:\Users\Daryl\Desktop\Projects\sdl-wii\SDL/src/main/wii/SDL_wii_main.c:78: undefined reference to `SDL_main'
view.o: In function `get_login()':
/opt/devkitpro/projects/abuse/abuse-trunk/src/view.cpp:180: undefined reference to `getlogin'
/opt/devkitpro/libogc/lib/libogc.a(lwp.o): In function `__lwp_sysinit':
/Users/davem/projects/devkitpro/libogc/libogc/lwp.c:147: undefined reference to `__stack_end'
/Users/davem/projects/devkitpro/libogc/libogc/lwp.c:147: undefined reference to `__stack_addr'
/Users/davem/projects/devkitpro/libogc/libogc/lwp.c:147: undefined reference to `__stack_end'
/Users/davem/projects/devkitpro/libogc/libogc/lwp.c:147: undefined reference to `__stack_addr'
/Users/davem/projects/devkitpro/libogc/libogc/lwp.c:148: undefined reference to `__crtmain'
/Users/davem/projects/devkitpro/libogc/libogc/lwp.c:148: undefined reference to `__crtmain'
/opt/devkitpro/libogc/lib/libogc.a(irq.o): In function `__irq_init':
/Users/davem/projects/devkitpro/libogc/libogc/irq.c:406: undefined reference to `__intrstack_end'
/Users/davem/projects/devkitpro/libogc/libogc/irq.c:406: undefined reference to `__intrstack_end'
/Users/davem/projects/devkitpro/libogc/libogc/irq.c:407: undefined reference to `__intrstack_addr'
/Users/davem/projects/devkitpro/libogc/libogc/irq.c:407: undefined reference to `__intrstack_addr'
/opt/devkitpro/libogc/lib/libogc.a(system.o): In function `__lowmem_init':
/Users/davem/projects/devkitpro/libogc/libogc/system.c:468: undefined reference to `__gxregs'
/Users/davem/projects/devkitpro/libogc/libogc/system.c:468: undefined reference to `__gxregs'
/Users/davem/projects/devkitpro/libogc/libogc/system.c:470: undefined reference to `__Arena1Lo'
/Users/davem/projects/devkitpro/libogc/libogc/system.c:470: undefined reference to `__Arena1Lo'
/Users/davem/projects/devkitpro/libogc/libogc/system.c:472: undefined reference to `__Arena1Hi'
/Users/davem/projects/devkitpro/libogc/libogc/system.c:472: undefined reference to `__Arena1Hi'
/Users/davem/projects/devkitpro/libogc/libogc/system.c:496: undefined reference to `__gxregs'
/Users/davem/projects/devkitpro/libogc/libogc/system.c:496: undefined reference to `__gxregs'
/Users/davem/projects/devkitpro/libogc/libogc/system.c:502: undefined reference to `__Arena2Lo'
/Users/davem/projects/devkitpro/libogc/libogc/system.c:502: undefined reference to `__Arena2Lo'
/Users/davem/projects/devkitpro/libogc/libogc/system.c:503: undefined reference to `__Arena2Hi'
/Users/davem/projects/devkitpro/libogc/libogc/system.c:503: undefined reference to `__Arena2Hi'
/opt/devkitpro/libogc/lib/libogc.a(system.o): In function `__ipcbuffer_init':
/Users/davem/projects/devkitpro/libogc/libogc/system.c:510: undefined reference to `__ipcbufferLo'
/Users/davem/projects/devkitpro/libogc/libogc/system.c:510: undefined reference to `__ipcbufferLo'
/Users/davem/projects/devkitpro/libogc/libogc/system.c:511: undefined reference to `__ipcbufferHi'
/Users/davem/projects/devkitpro/libogc/libogc/system.c:511: undefined reference to `__ipcbufferHi'
/opt/devkitpro/libogc/lib/libogc.a(gx.o): In function `__GX_FifoLink':
/Users/davem/projects/devkitpro/libogc/libogc/gx.c:164: undefined reference to `__gxregs'
/Users/davem/projects/devkitpro/libogc/libogc/gx.c:164: undefined reference to `__gxregs'
/opt/devkitpro/libogc/lib/libogc.a(gx.o): In function `__GX_WriteFifoIntEnable':
/Users/davem/projects/devkitpro/libogc/libogc/gx.c:176: undefined reference to `__gxregs'
/Users/davem/projects/devkitpro/libogc/libogc/gx.c:176: undefined reference to `__gxregs'
/opt/devkitpro/libogc/lib/libogc.a(gx.o): In function `__GX_FifoReadEnable':
/Users/davem/projects/devkitpro/libogc/libogc/gx.c:182: undefined reference to `__gxregs'
/opt/devkitpro/libogc/lib/libogc.a(gx.o):/Users/davem/projects/devkitpro/libogc/libogc/gx.c:182: more undefined references to `__gxregs' follow
/opt/devkitpro/libogc/lib/libogc.a(argv.o): In function `__CheckARGV':
/Users/davem/projects/devkitpro/libogc/libogc/argv.c:42: undefined reference to `__Arena1Lo'
/Users/davem/projects/devkitpro/libogc/libogc/argv.c:42: undefined reference to `__Arena1Lo'
collect2: ld returned 1 exit status
Any idea what I might be doing wrong, particularly with the "undefined reference" errors? It's almost like the libraries I'm trying to link have additional dependencies that I need to also link, but I wouldn't know what.

WinterMute
Site Admin
Posts: 1986
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: noob compiling issues

Post by WinterMute » Mon Sep 12, 2011 8:37 pm

You've installed the toolchain incorrectly - libogc.a should not be in /opt/devkitpro/libogc/lib/. The release tarball has cube and wii folders in there which both contain their own version of libogc.a.I haven't looked recently but I'm pretty sure that the SDL install instructions also require wii and cube specific versions installed in those folders.

There's a perl script in SVN which might help get you setup with the base tools - http://devkitpro.svn.sourceforge.net/vi ... lupdaters/

From the output you show it looks like you used configure to get things started so you'll need to clean that or ideally start again from a fresh copy. make distclean may work, depending on the project. You need a few more options than are shown for the portlibs when building actual applications

The -mrvl option builds code for wii and, when supplied at link time, selects the appropriate linkscript and crt0. For gamecube code you need to change this to -mogc and use lib/cube instead of lib/wii

-lwiikeyboard shouid be before -logc in the link line - order of libraries is important.

Code: Select all

PATH=$DEVKITPPC/bin:$PATH
CPPFLAGS=-mrvl -I$DEVKITPRO/libogc/include -I$DEVKITPRO/portlibs/ppc/include
LDFLAGS=-mrvl -L$DEVKITPRO/libogc/lib/wii -L$DEVKITPRO/portlibs/ppc/lib
 <path/to/>configure --host=powerpc-eabi --disable-shared --enable-static
You can also convert the final elf output to a dol - this basically flattens the binary, removing debug symbols and is the preferred format for distribution.
Help keep devkitPro toolchains free, Donate today

Personal Blog

HunterZ
Posts: 19
Joined: Mon Sep 12, 2011 3:58 am
Location: Seattle

Re: noob compiling issues

Post by HunterZ » Mon Sep 12, 2011 9:05 pm

WinterMute wrote:You've installed the toolchain incorrectly - libogc.a should not be in /opt/devkitpro/libogc/lib/. The release tarball has cube and wii folders in there which both contain their own version of libogc.a.I haven't looked recently but I'm pretty sure that the SDL install instructions also require wii and cube specific versions installed in those folders.
They actually are installed to those folders (I was meticulous in following the wiibrew.org instructions and the additional ones that it links to), but I made symbolic links in lib/ to the libraries in lib/wii specifically because configure was not smart enough to figure out the special directory structure (and I was not smart enough to figure out a better way to work around that, plus I have absolutely zero interest in Gamecube development).
The -mrvl option builds code for wii and, when supplied at link time, selects the appropriate linkscript and crt0. For gamecube code you need to change this to -mogc and use lib/cube instead of lib/wii
Aha! That's almost definitely what I was missing. I'll give that a shot.
-lwiikeyboard shouid be before -logc in the link line - order of libraries is important.
I guess the SDL-Wii page on the wiibrew.org wiki is in error then: http://wiibrew.org/wiki/SDL_Wii#Usage (as are most of the SDL-Wii sub-pages on there, as many list similar library orders).

I intend to remove keyboard support once I iron out these toolchain issues, as I think the game is ideally suited to a Wiimote+Nunchuk control style.

Code: Select all

PATH=$DEVKITPPC/bin:$PATH
CPPFLAGS=-mrvl -I$DEVKITPRO/libogc/include -I$DEVKITPRO/portlibs/ppc/include
LDFLAGS=-mrvl -L$DEVKITPRO/libogc/lib/wii -L$DEVKITPRO/portlibs/ppc/lib
 <path/to/>configure --host=powerpc-eabi --disable-shared --enable-static
Thanks for this, it will definitely come in handy. I was already pretty sure that not explicitly enabling static linking was going to bite me after resolving the issues in my original post.
You can also convert the final elf output to a dol - this basically flattens the binary, removing debug symbols and is the preferred format for distribution.
Yeah, I noticed that most people distribute .dol binaries. I actually wondered what the .elf binary was for when I compiled a different project (WiiDoom) that produced both!


Thanks for the reply and the suggestions!

HunterZ
Posts: 19
Joined: Mon Sep 12, 2011 3:58 am
Location: Seattle

Re: noob compiling issues

Post by HunterZ » Tue Sep 13, 2011 4:28 am

Okay, now I'm just down to a weird SDL error:

Code: Select all

libtool: link: powerpc-eabi-g++ -g -O2 -O2 -fno-strength-reduce -fomit-frame-pointer -g -Wall -Wpointer-arith -Wcast-align -Wcast-qual -Wsign-compare -mrvl -o abuse matrix.o timer.o specache.o netcfg.o innet.o chat.o endgame.o loadgame.o profile.o cop.o statbar.o compiled.o ant.o sensor.o demo.o lcache.o nfclient.o clisp.o gui.o transp.o collide.o property.o cache.o particle.o objects.o extend.o console.o ability.o items.o dev.o chars.o level.o smallfnt.o automap.o help.o intsect.o loader2.o seq.o points.o fnt6x13.o morpher.o menu.o director.o view.o configuration.o game.o light.o devsel.o crc.o gamma.o volumewindow.o  -L/opt/devkitpro/libogc/lib/wii -L/opt/devkitpro/portlibs/ppc/lib lisp/liblisp.a sdlport/libsdlport.a imlib/libimlib.a net/libnet.a -lm -L/usr/lib -lSDL -lSDL_mixer
/opt/devkitpro/libogc/lib/wii/libSDL.a(SDL_wii_main.o): In function `main':
c:\Users\Daryl\Desktop\Projects\sdl-wii\SDL/src/main/wii/SDL_wii_main.c:53: multiple definition of `main'
game.o:game.cpp:(.text.startup.main+0x0): first defined here
/opt/devkitpro/devkitPPC/lib/gcc/powerpc-eabi/4.6.1/../../../../powerpc-eabi/bin/ld: warning: cannot find entry symbol _start; defaulting to 0000000080004024
I've tried scouring the Internet for some hints on this and am stumped.

HunterZ
Posts: 19
Joined: Mon Sep 12, 2011 3:58 am
Location: Seattle

Re: noob compiling issues

Post by HunterZ » Tue Sep 13, 2011 5:19 am

Please disregard the previous post; I realized that I wasn't pointing configure at my custom sdl-config, and that my sdl-config had some issues.

Unfortunately, the linker errors are still almost the same - if not worse:

Code: Select all

endgame.o loadgame.o profile.o cop.o statbar.o compiled.o ant.o sensor.o demo.o lcache.o nfclient.o clisp.o gui.o transp.o collide.o property.o cache.o particle.o objects.o extend.o console.o ability.o items.o dev.o chars.o level.o smallfnt.o automap.o help.o intsect.o loader2.o seq.o points.o fnt6x13.o morpher.o menu.o director.o view.o configuration.o game.o light.o devsel.o crc.o gamma.o volumewindow.o lisp/liblisp.a sdlport/libsdlport.a imlib/libimlib.a net/libnet.a -mrvl -L/opt/devkitpro/libogc/lib/wii -L/opt/devkitpro/portlibs/ppc/lib -lSDL_net -lSDL_ttf -lSDL_gfx -lSDL_mixer -lSDL_image -lsmpeg -lSDL -ljpeg -lpng -lfreetype -lvorbisidec -lz -lfat -lwiiuse -lbte -lwiikeyboard -logc -lm
libtool: link: warning: library `/opt/devkitpro/portlibs/ppc/lib/libjpeg.la' was moved.
libtool: link: warning: library `/opt/devkitpro/portlibs/ppc/lib/libpng.la' was moved.
libtool: link: warning: library `/opt/devkitpro/portlibs/ppc/lib/libfreetype.la' was moved.
libtool: link: warning: library `/opt/devkitpro/portlibs/ppc/lib/libvorbisidec.la' was moved.
libtool: link: warning: library `/opt/devkitpro/portlibs/ppc/lib/libjpeg.la' was moved.
libtool: link: warning: library `/opt/devkitpro/portlibs/ppc/lib/libpng.la' was moved.
libtool: link: warning: library `/opt/devkitpro/portlibs/ppc/lib/libfreetype.la' was moved.
libtool: link: warning: library `/opt/devkitpro/portlibs/ppc/lib/libvorbisidec.la' was moved.
libtool: link: powerpc-eabi-g++ -g -O2 -O2 -fno-strength-reduce -fomit-frame-pointer -g -Wall -Wpointer-arith -Wcast-align -Wcast-qual -Wsign-compare -o abuse matrix.o timer.o specache.o netcfg.o innet.o chat.o endgame.o loadgame.o profile.o cop.o statbar.o compiled.o ant.o sensor.o demo.o lcache.o nfclient.o clisp.o gui.o transp.o collide.o property.o cache.o particle.o objects.o extend.o console.o ability.o items.o dev.o chars.o level.o smallfnt.o automap.o help.o intsect.o loader2.o seq.o points.o fnt6x13.o morpher.o menu.o director.o view.o configuration.o game.o light.o devsel.o crc.o gamma.o volumewindow.o -mrvl  lisp/liblisp.a sdlport/libsdlport.a imlib/libimlib.a net/libnet.a -L/opt/devkitpro/libogc/lib/wii -L/opt/devkitpro/portlibs/ppc/lib -lSDL_net -lSDL_ttf -lSDL_gfx -lSDL_mixer -lSDL_image -lsmpeg -lSDL /opt/devkitpro/portlibs/ppc/lib/libjpeg.a /opt/devkitpro/portlibs/ppc/lib/libpng15.a /opt/devkitpro/portlibs/ppc/lib/libfreetype.a -L/opt/devkitpro/ppc/lib /opt/devkitpro/portlibs/ppc/lib/libvorbisidec.a -lz -lfat -lwiiuse -lbte -lwiikeyboard -logc -lm
/opt/devkitpro/libogc/lib/wii/libSDL.a(SDL_wii_main.o): In function `main':
c:\Users\Daryl\Desktop\Projects\sdl-wii\SDL/src/main/wii/SDL_wii_main.c:53: multiple definition of `main'
game.o:game.cpp:(.text.startup.main+0x0): first defined here
/opt/devkitpro/libogc/lib/wii/libogc.a(console.o):(.rodata.color_table+0x0): multiple definition of `color_table'
loader2.o:/opt/devkitpro/projects/abuse/abuse-trunk/src/loader2.cpp:78: first defined here
/opt/devkitpro/devkitPPC/lib/gcc/powerpc-eabi/4.6.1/../../../../powerpc-eabi/bin/ld: Warning: size of symbol `color_table' changed from 4 in loader2.o to 64 in /opt/devkitpro/libogc/lib/wii/libogc.a(console.o)
view.o: In function `get_login()':
/opt/devkitpro/projects/abuse/abuse-trunk/src/view.cpp:180: undefined reference to `getlogin'
collect2: ld returned 1 exit status
I think that maybe porting is still over my head (at least on Wii) and that I should stick to trying to help improve existing ports until I have things figured out a little bit better :(

WinterMute
Site Admin
Posts: 1986
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: noob compiling issues

Post by WinterMute » Tue Sep 13, 2011 11:29 am

HunterZ wrote:
WinterMute wrote:You've installed the toolchain incorrectly - libogc.a should not be in /opt/devkitpro/libogc/lib/. The release tarball has cube and wii folders in there which both contain their own version of libogc.a.I haven't looked recently but I'm pretty sure that the SDL install instructions also require wii and cube specific versions installed in those folders.
They actually are installed to those folders (I was meticulous in following the wiibrew.org instructions and the additional ones that it links to), but I made symbolic links in lib/ to the libraries in lib/wii specifically because configure was not smart enough to figure out the special directory structure (and I was not smart enough to figure out a better way to work around that, plus I have absolutely zero interest in Gamecube development).
You'll be better off removing those symlinks - sadly bodges like that have a habit of spreading around the community & need to be stomped on otherwise we end up with projects that only build on the machine they were originally created on. Adding -L$DEVKITPRO/libogc/lib/wii to LDFLAGS during configure is the proper way to do it.

Don't give up just yet, you're very, very close and, most impressively, you've actually used configure instead of the usual mess people create by bodging Makefiles.

The multiple definition of `main' is caused by the project you're porting expecting to have main redefined to SDL_main on the fly, I believe this is usually done by sdl-config outputting -Dmain=SDL_main for --cflags.

It looks like there's a collision for the color_table symbol which can be resolved by either renaming it in the project or I can rename it in libogc, it should probably be internal anyway. Actually I've just rolled a release which makes that array static, it's only used by the console stuff anyway.

The code that uses getlogin needs to be rewritten - obviously the wii has no login shell so you can probably just ifdef it out. devkitPPC will define __wii__ when -mrvl is used and __gamecube__ for -mogc. Ideally you should probably check for both and leave things open - even if you have no interest in gamecube someone else probably will.

Great work doing this port the right way using the existing autotools setup, I look forward to seeing whatever it is :D
Help keep devkitPro toolchains free, Donate today

Personal Blog

HunterZ
Posts: 19
Joined: Mon Sep 12, 2011 3:58 am
Location: Seattle

Re: noob compiling issues

Post by HunterZ » Tue Sep 13, 2011 3:39 pm

WinterMute wrote:
HunterZ wrote:
WinterMute wrote:You've installed the toolchain incorrectly - libogc.a should not be in /opt/devkitpro/libogc/lib/. The release tarball has cube and wii folders in there which both contain their own version of libogc.a.I haven't looked recently but I'm pretty sure that the SDL install instructions also require wii and cube specific versions installed in those folders.
They actually are installed to those folders (I was meticulous in following the wiibrew.org instructions and the additional ones that it links to), but I made symbolic links in lib/ to the libraries in lib/wii specifically because configure was not smart enough to figure out the special directory structure (and I was not smart enough to figure out a better way to work around that, plus I have absolutely zero interest in Gamecube development).
You'll be better off removing those symlinks - sadly bodges like that have a habit of spreading around the community & need to be stomped on otherwise we end up with projects that only build on the machine they were originally created on. Adding -L$DEVKITPRO/libogc/lib/wii to LDFLAGS during configure is the proper way to do it.
Already took those suggestions to heart from your previous reply, including blowing away the symlinks :)
Don't give up just yet, you're very, very close and, most impressively, you've actually used configure instead of the usual mess people create by bodging Makefiles.
The source for this project actually came with only autoconf-level stuff, so I had to generate even the configure script before I could then have that generate a set of Makefiles. I didn't expect to get this far either, especially after setting the anti-configure attitude of the SDL-Wii team.

Speaking of which, I also hit an incompatibility between devkitPPC and SDL-Wii that was dismissed out-of-hand by the SDL-Wii team because they spotted my use of configure: http://code.google.com/p/sdl-wii/issues/detail?id=43 . I resolved this by commenting out SDL-Wii's definition of uintptr_t. Why doesn't SDL-Wii include the toolchain's definitions instead of defining its own? Seems improper to me.
The multiple definition of `main' is caused by the project you're porting expecting to have main redefined to SDL_main on the fly, I believe this is usually done by sdl-config outputting -Dmain=SDL_main for --cflags.
I tried hacking -Dmain=SDL_main into the Makefiles last night, but it didn't help. I don't remember if I did a make clean first, or if I went straight to the linker stage; I'll have to try again tonight.
It looks like there's a collision for the color_table symbol which can be resolved by either renaming it in the project or I can rename it in libogc, it should probably be internal anyway. Actually I've just rolled a release which makes that array static, it's only used by the console stuff anyway.
Thanks. If I can get past the SDL_main issue then I'll update libogc and let you know how it goes.
The code that uses getlogin needs to be rewritten - obviously the wii has no login shell so you can probably just ifdef it out. devkitPPC will define __wii__ when -mrvl is used and __gamecube__ for -mogc. Ideally you should probably check for both and leave things open - even if you have no interest in gamecube someone else probably will.
Will do, thanks.

That reminds me that I also had to disable the network code in this game to eliminate some other compiling issues, but they allowed me to do that via an argument to configure. I think they're still working on that part of the code, so the problems may be on their end rather than an issue with the toolchain.
Great work doing this port the right way using the existing autotools setup, I look forward to seeing whatever it is :D
Thanks for the encouragement. It's good to know that hatred of autotools isn't a community-wide thing. I am still struggling a bit with configure, as it seems to like to mysteriously tack extra -lSDL_Mixer tags onto the end of LIBS and such, but I've managed to get by with minor post-configure Makefile massaging so far.

HunterZ
Posts: 19
Joined: Mon Sep 12, 2011 3:58 am
Location: Seattle

Re: noob compiling issues

Post by HunterZ » Wed Sep 14, 2011 2:15 am

Okay, recompiled with -DSDL_main=main, and now I'm getting an undefined reference error instead of a multiple definition error:

Code: Select all

libtool: link: powerpc-eabi-g++ -g -O2 -fno-strength-reduce -fomit-frame-pointer -Wall -Wpointer-arith -Wcast-align -Wcast-qual -Wsign-compare -o abuse matrix.o timer.o specache.o netcfg.o innet.o chat.o endgame.o loadgame.o profile.o cop.o statbar.o compiled.o ant.o sensor.o demo.o lcache.o nfclient.o clisp.o gui.o transp.o collide.o property.o cache.o particle.o objects.o extend.o console.o ability.o items.o dev.o chars.o level.o smallfnt.o automap.o help.o intsect.o loader2.o seq.o points.o fnt6x13.o morpher.o menu.o director.o view.o configuration.o game.o light.o devsel.o crc.o gamma.o volumewindow.o -mrvl  lisp/liblisp.a sdlport/libsdlport.a imlib/libimlib.a net/libnet.a -L/opt/devkitpro/libogc/lib/wii -L/opt/devkitpro/portlibs/ppc/lib -lSDL_net -lSDL_ttf -lSDL_gfx -lSDL_mixer -lSDL_image -lsmpeg -lSDL /opt/devkitpro/portlibs/ppc/lib/libjpeg.a /opt/devkitpro/portlibs/ppc/lib/libpng15.a /opt/devkitpro/portlibs/ppc/lib/libfreetype.a -L/opt/devkitpro/ppc/lib /opt/devkitpro/portlibs/ppc/lib/libvorbisidec.a -lz -lfat -lwiiuse -lbte -lwiikeyboard -logc -lm
/opt/devkitpro/libogc/lib/wii/libogc.a(console.o):(.rodata.color_table+0x0): multiple definition of `color_table'
loader2.o:/opt/devkitpro/projects/abuse/abuse-trunk/src/loader2.cpp:78: first defined here
/opt/devkitpro/devkitPPC/lib/gcc/powerpc-eabi/4.6.1/../../../../powerpc-eabi/bin/ld: Warning: size of symbol `color_table' changed from 4 in loader2.o to 64 in /opt/devkitpro/libogc/lib/wii/libogc.a(console.o)
/opt/devkitpro/libogc/lib/wii/libSDL.a(SDL_wii_main.o): In function `main':
c:\Users\Daryl\Desktop\Projects\sdl-wii\SDL/src/main/wii/SDL_wii_main.c:78: undefined reference to `SDL_main'
collect2: ld returned 1 exit status
I did notice that game.cpp (which has main() defined) was not doing #include <SDL.h>, so I added that - but no dice. Tried adding #include <SDL_main.h> as well (whatever that does), but that didn't help either.

I checked the signature of main(), and it looks reasonable:

Code: Select all

int main(int argc, char *argv[])
After some more Google-fu, I tried adding extern "C" out of desperation:

Code: Select all

extern "C" int main(int argc, char *argv[])
...and it worked! WTF? That's a ridiculous and nonsensical hoop to have to jump through, and I don't understand why it is necessary.

Time to update my copy of libogc to pick up your color_table fix, and then see where that leads me. I suspect I will be inserting lots of "#if (defined(__wii__) || defined(__gamecube__))" statements around lots of Wii-specific code :)

HunterZ
Posts: 19
Joined: Mon Sep 12, 2011 3:58 am
Location: Seattle

Re: noob compiling issues

Post by HunterZ » Wed Sep 14, 2011 4:02 am

After updating libogc, the color_table issue is gone, but the undefined reference to SDL_main issue is back :(

Edit: And I am using -Dmain=SDL_main, not the other way around as stated in my previous post. So strange that it worked and now doesn't.

Edit 2: Never mind, I think I see the problem - it's compiling a tool on the side that also uses SDL, and that probably needs to be modified similarly to game.cpp.

WinterMute
Site Admin
Posts: 1986
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: noob compiling issues

Post by WinterMute » Wed Sep 14, 2011 5:38 pm

There's a note in the SDL headers that you need to extern "C" your main to get it to work with C++, it's basically because it supplies it's own main that does some setup before running the user's main.

I've been attempting to get the SDL wii guys to switch to using the autotools setup for years without much success. Sadly it seems to scare people which is a bit of a shame considering how well it works and how much work I put into the toolchain setup so it's possible to do with devkitPPC & devkitARM. I'm still not 100% sure how to deal with tools that are meant for the build system when you're cross compiling, often setting --host builds them for the target system instead which might lead to some problems with what you're porting.

You did inspire me to have a look at using configure && make to build wii SDL though, I've managed to get it to build & install but I'm not yet sure if I've managed to get all the changes that were done for wii. I'm trying to figure out how to get the configure for the tests to ignore build system libraries atm. Right now it's decided to pick up openGL which is a bit annoying.
Help keep devkitPro toolchains free, Donate today

Personal Blog

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 3 guests