CodeBlocks SDL: "ld.exe cannot find -lSDLmain"

I had installed SDL with this tutorial

http://lazyfoo.net/tutorials/SDL/01_hello_SDL/windows/codeblocks/index.php

and as far as I know, everything works except for the -lSDLmain and -lSDL errors I keep getting. Any help?
Bumping thread.
Did you download the SDL libraries?
Are you linking to static or dynamic SDL2 link libraries (.lib or .dll)? SDL2's license permits static linking, unlike SDL1, so you are not required to distribute your application with .dll files; you can simply bake SDL2 as a static library into it.

Have you built SDL2 from source, or simply installed the runtime binaries? Typically, installing precompiled libraries/runtime binaries is a headache. I recommend you manually compile the SDL2 library. There are several ways to do this and one of them is to import one of the SDL2 solutions/projects from the source distribution and build it in CodeBlocks. CodeBlocks is able to import Microsoft Visual Studio projects and solutions and SDL2's source distribution comes packaged with a number of these.

If you are having trouble building SDL2 with CodeBlocks, SDL2's source distribution comes packaged with support for CMake. This will require some fairly simple command line/prompt input. I'm assuming that you are using the GCC compiler and GNU tool chain that is packaged with some CodeBlocks distributions. If this is the case, you already have everything you need to make use of CMake. The CMake website is here: http://www.cmake.org/

The worst case scenario is that you will need to build SDL2 entirely from the command line using the source distribution's configure and Makefiles. Unfortunately, this option caters towards a Linux/Unix environment. Some of the software required for this comes packaged with GCC and the GNU tool chain via MinGW, but you will require MSYS to emulate a Linux/Unix console for this. You can get MSYS here: http://www.mingw.org/wiki/msys

When all is said and done, I recommend you become familiar with command line tools in general. If you snoop around in CodeBlocks' settings and your project/solution's configurations, you will find many options that allow you to modify command line parameters. Try tinkering around with these tools in a command prompt; it's fun and will help you understand how the backend of software development works as compared to the IDE you typically work with.
I simply followed what the tutorial I linked told me to do. I did this before and is worked, and it doesn't seen to want to now. Can someone just tell me why is isn't working this time.
Last edited on
Bump.
From the link you provided: http://lazyfoo.net/tutorials/SDL/01_hello_SDL/windows/codeblocks/index.php#5

Next we are going to tell Code::Blocks to search for library files in the SDL folder we just extracted. All you have to is go to the linker tab and add the lib directory from the folder we extacted to the linker search directories.
If you get an error where the linker complains it can't find -lSDL2 or -lSDL2main, it means you messed up this step.


Apparently you did not tell code::blocks where to find the sdl libraries correctly. You need to review step 5.
I'm an idiot.

I just realized that the global compiler setting were set to the wrong linker tabs/ directories, and those were overriding my project specific setting. Thanks for all the help, anyway.
Topic archived. No new replies allowed.