SDL and codeblocks not properly linking

Hi guys I'm using codeblocks with a 64 bit gcc-mingw compiler

I downloaded the SDL dev libraries and linked it, this has always worked for me in the past the only difference is I'm using a 64 bit version of codeblocks rather than a 32 bit version

here are the steps I took, firstly I moved the SDL include directory into the compilers include directory, I also moved the lib files (.a) files into the lib folder of the compiler, and included the SDL2.dll into the same directory as the codeblocks.exe file

now what I did to link the libraries

I added libSDL2main.a and libSDL2.dll.a in the linker settings under build options, I also specified the following flags -lmingw32 -lSDL2main -lSDL2

I even added the lib folder in the search directory of the linker ( normally I can get away without doing this ) but everything fails to link, the linker gives me the following errors

ld.exe||cannot find -lSDL2main
ld.exe||cannot find -lSDL2

1
2
3
4
5
6
7
8
9
10
11
12
#include <iostream>
#include <SDL2/SDL.h>

using namespace std;

int SDL_main(int argc,char* argv[])
{
    cout << "Hello world!" << endl;
    return 0;
}


*Solved Issue was that it seems even though codeblocks is 64 bits it's using a 32bit version of mingw so I just included the 32 bit libraries instead of the 64 bit ones.
> here are the steps I took, firstly I moved the SDL include directory into the compilers include directory,
You should probably undo all that and put it back how it was.

So that it still works when you next update your compiler (doesn't trash your SDL), or update your SDL (but still secretly use the out of date one copied to your compiler dirs).

Topic archived. No new replies allowed.