Mysterious SDL linker error

Started by
4 comments, last by mattd 14 years, 5 months ago
I am getting an undefined reference error when linking my SDL application. The exact error is: undefined reference to `_SDL_UpperBlit' with a reference to a line where I am calling SDL_BlitSurface. I am using CodeBlocks with gcc, and linking to SDL.dll, 1.2.13. I am not getting any other undefined reference errors, despite using several other SDL functions. I don't think there is an error in my library, as I've built several other applications with the same libraries and headers. Could anyone offer any advice as to what the problem might be?
Advertisement
Have you tried SDL 1.2.14? If you're on Windows 7 there were some problems reported with that on earlier versions of SDL.
I'm running XP 32-bit, and I've previously built other applications with 1.2.13, but I went ahead and tried it. No luck, same problem.
I believe SDL_Blitsurface is just a macro wrapper for SDL_Upperblit (yuk i hate macros). So that is why you're getting upperblit there. As to why it's not linking, no clue. Just make sure it's linking with SDL properly. the only reason you'd get undefined ref is if the SDL library isn't visible to the linker.
If it was a problem actually linking a header, then the error would probably complain about SDL_BlitSurface rather than _SDL_UpperBlit, so I doubt this is the problem.

If your other SDL calls work then it's probably a problem with that particular SDL_BlitSurface call. Are you calling it with the correct number and types of arguments?
Quote:Original post by The Archon
If it was a problem actually linking a header, then the error would probably complain about SDL_BlitSurface rather than _SDL_UpperBlit, so I doubt this is the problem.

Careful there: you don't link a header, you include it. Linking is for libraries. That said, you are correct in saying that it would be looking for SDL_BlitSurface if SDL.h or whatever the relevant header wasn't being included. (You'd however get another more explicit error if SDL.h couldn't be found at all!)

Quote:If your other SDL calls work then it's probably a problem with that particular SDL_BlitSurface call. Are you calling it with the correct number and types of arguments?

Note that the OP is getting a linker error - it's not even got to making a finished binary yet. If the invocation of the function was incorrect, they'd be receiving a compiler error instead.

That said, this thread is kinda old now - OP, have you figured it out yourself yet? :)

This topic is closed to new replies.

Advertisement