So I have been learning C++ for about 6 months now and just purchased a copy of "The Black Art of Multiplatform Game Programming".
This book recommends code::blocks, which I have not used before but I am willing to give it a go. I have gone through the process of linking and including and such for SDL. The first task is to make sure everything is set up correctly, which it appears to be.
E:\SDLcodeblocks\SDL-1.2.15\lib\x86/SDLmain.lib(./Release/SDL_win32_main.obj):(.text[_main]+0x7): undefined reference to `__security_cookie'
E:\SDLcodeblocks\SDL-1.2.15\lib\x86/SDLmain.lib(./Release/SDL_win32_main.obj):(.text[_main]+0x99): undefined reference to `_alloca_probe_16'
E:\SDLcodeblocks\SDL-1.2.15\lib\x86/SDLmain.lib(./Release/SDL_win32_main.obj):(.text[_main]+0x14e): undefined reference to `@__security_check_cookie@4'
Can anyone tell me what these errors are and how I fix them?
If it shows undefined reference errors, that means you have a linker error. I know this from editing cmd apps, and i would get the same errors for not linking properly.
What I'm saying is to relink your libraries and check again.
Except that is not what is going on here. The libraries are linked properly. I know this because I had a problem with that and fixed it. These security cookies and security checks are related to buffer overflow (at least according to about 30 forums I found with google).
The only solution I have found seems to be to link it to bufferoverflowu, but I have not found anything beyond "Its an easy fix! just link bufferoverflowu!"....I have no idea where to find bufferoverflowu, or exactly how to link it if I do. I am at a complete loss.
Also, everything on the subject seems to be about 10 years old and I am using the newest codeblocks so I have no idea how why this is happening.
Here's a copy of the .cbp <linker> section for one of my more recent sdl games, compare with yours, order matters in the SDL string. If you're using a direct directory instead of SDL options like I am yours will be different.
Notice I'm using 1.2 SDL- this will also be different with SDL2 (nevermind you're using 1.2)
If you would like to post the relevant section from your .cbp project file maybe I will be able to point you in the right direction. Have you added any additional libraries?
An undefined reference means you're missing a .a or it is in the wrong order (I have included several extras you wouldn't need)
Looking at that particular error it looks like one that comes from a GS flag in visual studio, if you want to find those libraries they would be in the win32 microsoft SDK or the driver SDK. Both of which can be downloaded via microsoft's website.
I hope this is what you are asking for, and thank you for taking the time to reply. I have been learning c++ for about six months and so far the IDEs have been harder than learning the code.
I downloaded the Microsoft SDK, and added bufferoverflowu to Link Libraries under Linker Settings and that cleared two of the errors!
The two errors remaining now are:
E:\SDLcodeblocks\SDL-1.2.15\lib\x86/SDLmain.lib(./Release/SDL_win32_main.obj):(.text[_main]+0x99): undefined reference to `_alloca_probe_16'
and
collect2.exe: error: ld returned 1 exit status
From several of the forums (and what you are saying above) I have looked at in regards to this it seems I need to link to Winmm.a, but i don't have any .a files, only .lib files.
winmm.a and winmm.lib are the same (almost) .lib is usually used for the microsoft compiler whereas .a is generally used for gcc/g++
I don't know what compiler you've chosen to use with code::blocks, but go ahead and try your winmm.lib or if you're using mingw it will be in the mingw lib subfolder.
I have tried both of them about a dozen different ways.
I am using Mingw.
I am still fairly new to this so its possible i could be doing something incorrectly, and the more descriptive an answer the better. Thanks for helping so far.
Any idea what I might be doing wrong at this point? Or is there a best way I should do the linking to prevent errors?
I have a couple ideas, the most likely issue is the version of SDL you're using. Shoot me a PM and we can get it figured out from here and post the results here for others to follow.
In case Detoxifier forgets: he was using a version of SDL built for Visual Studio instead of the mingw version.