Linking woes

Started by
3 comments, last by methinks 17 years, 10 months ago
I'm trying to add SDL support to a project I'm working on, and I've got it to the point where it compiles, but doesn't quite link. What I end up with is the following error: C:\Program Files\CodeBlocks\lib/libmingw32.a(main.o):main.c:(.text+0x106): undefined reference to `WinMain@16' I know that it's a matter of telling the compiler/linker of pointing to certain files, but I don't get the how and where. My personal problem is that most of the books and resources which teach you how to program, only teach you to CODE. While they might explain the theory behind the linking, they never explain what actually has to be done. Other examples only show how to set up and link specific SDKs in specific environments... So I guess I'm asking two things: Could someone explain the whole linking of lib, include, .a, and dlls, or at least point me to a resource that explains it all? Does anybody know how to fix my specific problem? (And don't tell me "just link your ide to x location, that's what brought on this post in the first place) I'm trying to compile SDK on CodeBlocks, running on XP, using GCC (Ming). Thanks
Advertisement
Try linking with "-lmingw32 -lSDLmain -lSDL".

Just copy and paste that, sans the quotation marks, into your linker options. I dont know where that is in code blocks.

Thanks, it got me a bit farther. Now I have a problem linking to SDL_main:
/home/hercules/release/SDL-1.2.10/src/main/win32/SDL_win32_main.c:217: undefined reference to `SDL_main'

While just adding the tags in helps with the problem, it doesn't explain what exactly I'm doing, which leads me back to point #1: could somebody point me to where linker and compiler options, paths and includes are explained properly?
See the question "I get "Undefined reference to 'SDL_main'" ..." on SDL's Windows FAQ

main() needs to look like this:

int main(int argc, char *argv[])
That's it, thanks. I'm used to int main(), but adding the parameters fixed it.

This topic is closed to new replies.

Advertisement