GP2X Problem In Ld Stage Of Sdl-heretic Compile


OCA|

Member
Joined
Oct 23, 2005
Messages
105
I'm trying to do a quick, dirty port of sdl-heretic to the gp2x. I have the gp2x dev pack for windows (mentioned in the wiki) and am able to compile the example demo application.

However, when I try to compile sdl-heretic, it makes it to the linker portion and then exits with:

c:\devkitgp2x\bin\..\lib\gcc\arm-linux\4.0.2\..\..\..\..\arm-linux\bin\ld.exe: cannot find /usr/lib/ inside c:\devkitgp2x\arm-linux\bin\../../sysroot
make: *** [sdl] Error 1


The way I read this, its expecting /usr/lib in c:\devkitgp2x\sysroot. That folder does exist, and is populated with a collection of libraries.

I'm really quite confused as to why this is happening... if anyone has any idea what could be causing this, or if I'm reading the error wrong and its expecting usr/lib somewhere else, I'd greatly appriciate the help =)

-OCA|
 
I had a problem with this when trying to do a quick, dirty port of scummvm's sdl backend to the gp2x. The fix I found was to make sure that
Code:
-static
is passed in as a linker flag. This, of course, made for a large executable (running strip on it helped, some). I wasn't able to find much information on the actual reason for the problem, though.
 
I had the same problem compiling my SDL app.

My current guess as to the origin:
  • Without -static, gcc tries to link the SDL library dynamically (meaning not linked into the executable, but loaded at runtime), as opposed to including it in the executable.
  • The tradeoff here is file size vs. reliability: with the libraries linked in, the SDL libraries aren't required on the GP2X, but the executable logically needs to include the libraries so grows bigger.
  • My guess is that with compiling for dynamic linking, the compiler also checks whether the required libraries are available at compile-time. It seems a bit illogical for it to require that, but perhaps it needs to load the dynamic libraries to determine function signatures or something like that.
  • When it does require the dynamic libraries, it checks for libsdl.o in /usr/lib. If you don't have those files there, it will fail to compile. This also goes if you're compiling under MSYS or some other Unix-like Windows environment.
 
The problem is caused by libpthread.so and libc.so in /sysroot/usr/lib. The files are in plain text. Just fix the paths (remove em). This is not a problem when building static binaries since those files are not used.
 
Thank you for your help, removing the libpthread.so and libc.so worked. However, as usual, I'm getting more issues now....

graphics/i_sdl.o: In function `I_SetPalette':
graphics/i_sdl.c:47: undefined reference to `SDL_SetColors'
graphics/i_sdl.o: In function `I_FinishUpdate':
graphics/i_sdl.c:98: undefined reference to `SDL_UpdateRect'
graphics/i_sdl.o: In function `InitGraphLib':
graphics/i_sdl.c:102: undefined reference to `SDL_Init'
graphics/i_sdl.o: In function `I_InitGraphics':
graphics/i_sdl.c:117: undefined reference to `SDL_GetTicks'
graphics/i_sdl.c:124: undefined reference to `SDL_SetVideoMode'
graphics/i_sdl.c:146: undefined reference to `SDL_ShowCursor'
graphics/i_sdl.c:147: undefined reference to `SDL_WM_SetCaption'
graphics/i_sdl.c:130: undefined reference to `SDL_GetError'
graphics/i_sdl.o: In function `I_GetEvent':
graphics/i_sdl.c:270: undefined reference to `SDL_GetMouseState'
graphics/i_sdl.o: In function `I_StartTic':
graphics/i_sdl.c:314: undefined reference to `SDL_PollEvent'
make: *** [sdl] Error 1


It would seem its not getting a hold of SDL somewhere... I'm thinking somewhere my paths may not be set up correctly, but I don't understand where.

... it's late, I'll probably take a look at it again in the morning. Hopefully it'll come to me then. I always have the hardest time just trying to get stuff to compile :p

-OCA|
 
Actually I meant editing the files and fixing the directories defined in them..

Seems your makefile is missing some libraries for the linker. -lSDL, -lSDLmain etc.
 
Okay, putting those files back and changing the GROUP line to:

GROUP ( ./libc.so.6 ./libc_nonshared.a )

for libc.so, and

GROUP ( libpthread.so.0 )

for libpthread.so, and replaced them. That seemed to have the same effect as removing them.

Then, after looking at the demo application's makefile, I tried adding the call to sdl-config --libs at the end of the linker command in the heretic makefile, and it successfuly compiled.

Now to go through the SDL faq on the wiki and see if I can't figure out why it's not working - not like I expected it to just recompile and work :lol:

-OCA|
 
Back
Top