Linker Errors [Now Code::Blocks]

Started by
6 comments, last by Robo-Link 15 years, 4 months ago
Okay, so I'm trying to port my project from VC++ to Bloodshed, and I've gotten everything down to a few errors. I've taken a screenshot that has my linker list, and build info. Can someone take a look at it and tell me how to correct these errors? [Edited by - Robo-Link on December 17, 2008 5:52:35 PM]
[size=12pt]SoraCross Development"A website dedicated to bringing you high quality games and web designs."
Advertisement
According to the bloodshed site it was last updated nearly 4 years ago. Why are you trying to port to an out of date unsupported unused compiler? Stick with MSVC++ if I were you...
Construct (Free open-source game creator)
If you want a MinGW build environment, you can try Code::Blocks instead.
Quote:Original post by Cantos
If you want a MinGW build environment, you can try Code::Blocks instead.


Thanks. I'm using code blocks now. I have just one error:
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\libmingw32.a(main.o):main.c:(.text+0x104)||undefined reference to `_WinMain@16|

I'm linking to SDL like this:
Build settings -> [project name] -> Linker Settings:
opengl32
GlU32
SDL
SDLmain

And Build settings -> [project name] -> Search Directories -> Compiler:
..\..\SDL-devel-1.2.13-mingw32\SDL-1.2.13\include
And Build settings -> [project name] -> Search Directories -> Linker:
..\..\SDL-devel-1.2.13-mingw32\SDL-1.2.13\lib

Also, I have a Main referenced at main.cpp as int main(int argc, char **argv[])

Can someone please help?
[size=12pt]SoraCross Development"A website dedicated to bringing you high quality games and web designs."
Quote:Original post by Robo-Link
Quote:Original post by Cantos
If you want a MinGW build environment, you can try Code::Blocks instead.


Thanks. I'm using code blocks now. I have just one error:
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\libmingw32.a(main.o):main.c:(.text+0x104)||undefined reference to `_WinMain@16|

I'm linking to SDL like this:
Build settings -> [project name] -> Linker Settings:
opengl32
GlU32
SDL
SDLmain

And Build settings -> [project name] -> Search Directories -> Compiler:
..\..\SDL-devel-1.2.13-mingw32\SDL-1.2.13\include
And Build settings -> [project name] -> Search Directories -> Linker:
..\..\SDL-devel-1.2.13-mingw32\SDL-1.2.13\lib

Also, I have a Main referenced at main.cpp as int main(int argc, char **argv[])

Can someone please help?


Yes, you defined the wrong entrypoint for your program.

Instead of a main(), you need a WinMain according to this specification:
int WINAPI WinMain(          HINSTANCE hInstance,    HINSTANCE hPrevInstance,    LPSTR lpCmdLine,    int nCmdShow);


Toolmaker

Try a block like this around your main() function:

extern "C" {int main(int argc, char *argv[]){     ...}}
IIRC if you specify -lsdlmain _before_ -lsdl in your linker settings it should help
Okay, having SDLmain before SDL and WinMain worked. Thank you all for your help.
[size=12pt]SoraCross Development"A website dedicated to bringing you high quality games and web designs."

This topic is closed to new replies.

Advertisement