1d returned 1 exit status and winmain@16

when I tried to install SDL onto code blocks I get these error messages.

1d returned 1 exit status

undefined reference to WinMain@16

this is the code:

#include <iostream>
#include <SDL.h>

using namespace std;

main()
{
cout << "Hello world!" << endl;
return 0;
}

any help will be greatly appreciated.
closed account (LA48b7Xj)
Try write main like...

1
2
3
4
int main(int argc, char *argv[])
{
    return 0;
}
that did not do the trick but thanks anyways
closed account (LA48b7Xj)
http://lazyfoo.net/tutorials/SDL/01_hello_SDL/index.php

Follow the instructions here.
Last edited on
https://msdn.microsoft.com/en-us/library/windows/desktop/ff381406(v=vs.85).aspx

tl;dr: Replace main() with this
1
2
3
4
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow)
{
    
}


Don't forget to include Windows.h
Last edited on
integralfx, I did as you said and it solved those problems, but now it says:

error: conflicting declaration of C function 'int WinMain(HINSTANCE, HINSTANCE, PWSTR, int)'

but thank you for your help

krako, I will try the tutorial now
so, I did as both of you said, and it solved those problems, but now I get a:

conflicting declaration of C function 'int WinMain(HINSTANCE, HINSTANCE, PWSTR, int)'

once again I am thankful for all answers and your help thus far
closed account (LA48b7Xj)
https://wiki.libsdl.org/FAQWindows#I_get_.22Undefined_reference_to_.27SDL_main.27.22_...

Make sure you are using main, not WinMain. Also it seems that it is a linker error you were getting so my guess is that you didn't setup the linker settings correctly, Lazy Foo has a excellent tutorial that covers setting SDL up for most platforms.

This is from the SDL FAQ also...

"I get "Undefined reference to 'WinMain@16'"

Under Visual C++, you need to link with SDL2main.lib. Under the gcc build environments including Dev-C++, you need to link with the output of "sdl-config --libs", which is usually: -lmingw32 -lSDL2main -lSDL2 -mwindows"

it is finally solved, I used the setup guide I got from krako and the SDLfaq.

thank you all for the help

note: I did not use the main() replacement intergralfx gave
Topic archived. No new replies allowed.