This topic is 4526 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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

##### Share on other sites
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.

##### Share on other sites
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?

##### Share on other sites
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[])

##### Share on other sites
That's it, thanks. I'm used to int main(), but adding the parameters fixed it.

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 9
• 9
• 9
• 14
• 12
• ### Forum Statistics

• Total Topics
633302
• Total Posts
3011275
• ### Who's Online (See full list)

There are no registered users currently online

×