Code:Blocks forum,
Here's the information I left out in my original post.
I am running Code::Blocks version 16.01 on Windows 7 Professional SP1
The compiler I use is Mingw32 and search directories set to
C:\SDL2-2.0.5\include\SDL. There are no relative paths in my setup.
When I build a simple "Hello World" program there are no errors and
it runs successfully. If I add #include <SDH.h> and try to build it
again I get the error message 'undefined reference to 'WinMain@16'
File name is main.cpp
#include <SDL.h>
#include <iostream>
using namespace std;
int main()
{
cout << "Hello world!" << endl;
return 0;
}
BUILD LOG WITHOUT #include <SDL.h>
-------------- Build: Debug in SDL (compiler: GNU GCC Compiler)---------------
mingw32-g++.exe -Wall -std=c++11 -fexceptions -g -mwindows -std=c++11 -mwindows -IC:\SDL2-2.0.5\include\SDL2 -I"C:\Program Files\CodeBlocks\SDL" -IC:\SDL2-2.0.5\include\SDL2 -I"C:\Program Files\CodeBlocks\SDL" -c "C:\Program Files\CodeBlocks\SDL\main.cpp" -o obj\Debug\main.o
mingw32-g++.exe -LC:\SDL2-2.0.5\lib -LC:\SDL2-2.0.5\lib -o bin\Debug\SDL.exe obj\Debug\main.o -lmingw32 -lSDL2main -lSDL2 -lmingw32 -lSDL2main -lSDL2
Output file is bin\Debug\SDL.exe with size 1.01 MB
Process terminated with status 0 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))
BUILD LOG WITH #include <SDL.h>
-------------- Build: Debug in SDL (compiler: GNU GCC Compiler)---------------
mingw32-g++.exe -Wall -std=c++11 -fexceptions -g -mwindows -std=c++11 -mwindows -IC:\SDL2-2.0.5\include\SDL2 -I"C:\Program Files\CodeBlocks\SDL" -IC:\SDL2-2.0.5\include\SDL2 -I"C:\Program Files\CodeBlocks\SDL" -c "C:\Program Files\CodeBlocks\SDL\main.cpp" -o obj\Debug\main.o
mingw32-g++.exe -LC:\SDL2-2.0.5\lib -LC:\SDL2-2.0.5\lib -o bin\Debug\SDL.exe obj\Debug\main.o -lmingw32 -lSDL2main -lSDL2 -lmingw32 -lSDL2main -lSDL2
C:/Program Files (x86)/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/4.9.2/../../../libmingw32.a(main.o):main.c:(.text.startup+0xa7): undefined reference to `WinMain@16'
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
2 error(s), 0 warning(s) (0 minute(s), 0 second(s))
OTHER THINGS I HAVE TRIED
There was a suggestions on the web regarding placing -mwindows as compiler
flag which you can see in the Build logs.
Select the checkbox in Settings-> Compiler > Build options "Explicitly add currently compiling file's directory to compiler search dirs".
Closing and reopening Code:Blocks.
Go to project > build option and put a check mark on "Have g++ follow the C++11 ISO C++ language standard [-std=c++11]".
project --> build option Put check mark on " Have g++ follow the C++11 ISO C++ language standard [-std=c++11]"
Any suggestions?
Jerry D.