User forums > Using Code::Blocks
undefined reference to 'WinMain@16 error message
stahta01:
Example of posting code in code tags.
NOTICE: The main function is "int main(int, char**)" instead of "int main()" this makes a difference; but, my prior note of this was NOT understood by you. Edti2: If you do NOT fix that you will in time get. "undefined reference to `SDL_main'"
Edit: This is the simplest SDL2 code I know about it does nothing besides inits and quits SDL2.
Tim S.
--- Code: ---#include <iostream>
#include <SDL2/SDL.h>
int main(int, char**){
if (SDL_Init(SDL_INIT_VIDEO) != 0){
std::cout << "SDL_Init Error: " << SDL_GetError() << std::endl;
return 1;
}
SDL_Quit();
return 0;
}
--- End code ---
Edit3: Added build and run logs.
--- Code: ----------------- Build: Release in SDL2_Test (compiler: GNU GCC Compiler)---------------
mingw32-g++.exe -Wall -O2 -IC:\SDL2-2.0.5\i686-w64-mingw32\include -c C:\Devel\open_source_code\no_version_control\Test\SDL2_Test\main.cpp -o obj\Release\main.o
mingw32-g++.exe -LC:\SDL2-2.0.5\i686-w64-mingw32\lib -LC:\SDL2-2.0.5\i686-w64-mingw32\bin -o bin\Release\SDL2_Test.exe obj\Release\main.o -lmingw32 -lSDL2main -lSDL2 -s
Output file is bin\Release\SDL2_Test.exe with size 544.50 KB
Process terminated with status 0 (0 minute(s), 2 second(s))
0 error(s), 0 warning(s) (0 minute(s), 2 second(s))
--- End code ---
--- Code: ----------------- Run: Release in SDL2_Test (compiler: GNU GCC Compiler)---------------
Checking for existence: C:\Devel\open_source_code\no_version_control\Test\SDL2_Test\bin\Release\SDL2_Test.exe
Executing: "C:\Program Files\CodeBlocks/cb_console_runner.exe" "C:\Devel\open_source_code\no_version_control\Test\SDL2_Test\bin\Release\SDL2_Test.exe" (in C:\Devel\open_source_code\no_version_control\Test\SDL2_Test\.)
Process terminated with status 0 (0 minute(s), 2 second(s))
--- End code ---
jerryd:
stahta01,
Progress!!
Following your suggestion I changed my SDL location to
"C:\SDL2-2.0.5\i686-w64-mingw32\include" and updated all
the compiler and build options.
I no longer get the error message but when I try to run I get:
"The application was unable to start correctly(0x00000007b)"
I know this probably means a mismatch between 32 bit and 64 bit
as you suggested.
My system is Windows 7 Professional 64 bit.
The SDL download was SDL2-2.0.5-win32-x64.zip
The Code:Blocks download was from codeblocks-16.01mingw-setup.
I'm new to this forum and Code:Blocks so I don't understand of
what you mean by "Please try to use code tags that is the "#"
button in the menu.
Jerry D.
stahta01:
--- Quote from: jerryd on December 10, 2016, 02:57:59 am --- My system is Windows 7 Professional 64 bit.
The SDL download was SDL2-2.0.5-win32-x64.zip
The Code:Blocks download was from codeblocks-16.01mingw-setup.
--- End quote ---
The codeblocks-16.01mingw-setup means you likely are using TDM's MinGW32 GCC which is 32 bit.
I downloaded SDL2-devel-2.0.5-mingw.tar.gz which contained both 32 bit and 64 bit files.
I tried the "SDL2-2.0.5-win32-x86.zip" first; but, it only had the 32 bit DLL which is NOT enough to build a SDL project from source code.
Edit: I am NOT good with images and to me I see no way to tell you where the # button is without posting an image.
Too tired to search for another poster who did the image in the past. Will try to test this tomorrow on my 64 bit Laptop;
not certain where the problem is.
The # button just adds this to your post [ code ][ /code ] without the spaces before and after the square brackets.
Tim S.
Jenna:
I merged the two threads.
Please do not start two threads if you update your own topic.
jerryd:
stahta01,
Got a late start on this problem today because I was up past 2AM.
I found a 64 bit mingw32 that took a long time to download and
then I had to figure how to set it up in Code:Blocks for compiling
and Debugging.
I Also had to update all the project's build options and properties.
After all that was complete everything worked. I went back and
removed -mwindows from the project settings and it still worked.
I see it still shows up in the Build Log so it may be in the
makefile.
Thanks much for your interest and all your suggestions. I'm sure
I'll be back with more questions as I get deeper into SDL code.
FYI here's the latest Build log:
-------------- Build: Debug in SDL (compiler: Copy of GNU GCC Compiler(64))---------------
x86_64-w64-mingw32-g++.exe -Wall -fexceptions -std=c++11 -g -mwindows -std=c++11 -mwindows -IC:\SDL2-2.0.5.64\x86_64-w64-mingw32\include\SDL2 -IC:\SDL2-2.0.5.64\x86_64-w64-mingw32\include\SDL2 -I"C:\Program Files\CodeBlocks\SDL" -c "C:\Program Files\CodeBlocks\SDL\main.cpp" -o obj\Debug\main.o
x86_64-w64-mingw32-g++.exe -LC:\SDL2-2.0.5.64\x86_64-w64-mingw32\lib -LC:\SDL2-2.0.5\lib -o bin\Debug\SDL.exe obj\Debug\main.o -lmingw32 -lSDL2main -lSDL2
Output file is bin\Debug\SDL.exe with size 2.61 MB
Process terminated with status 0 (0 minute(s), 1 second(s))
0 error(s), 0 warning(s) (0 minute(s), 1 second(s))
Didn't see a way to mark this post as SOLVED.
Jerry D.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version