Ld.exe cannot find -lSDLmain Code::Blocks 8.02

This is getting me a bit annoyed. I started learning C/C++ a month ago and nailed down all the basics and decided to try out LazyFoo’s tutorial series. So I go to lesson 1, setting up SDL and try configuring CodeBlocks/Dev C++/etc. Each compiler gives errors. I finally figured out all the errors except this one:
Code:
-------------- Build: Debug in SDLTest ---------------

Linking executable: bin\Debug\SDLTest.exe
C:\Program Files (x86)\CodeBlocks\MinGW\bin\ld.exe: cannot find -lSDLmain
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
1 errors, 0 warnings

I’ve spent about 16 hours on this one problem so far. Googled and all… I found one source on a french website, the google translation of it was so bad I couldn’t understand it fully, but they suggested manually linking to libSDLmain.a and libSDL.a

Any help is much appreciated!

I am running 64-bit Windows 7 by the way…

main.cpp:

Code:
#include “SDL/SDL.h”

int main( int argc, char* args[] )
{
//Start SDL
SDL_Init( SDL_INIT_EVERYTHING );

//Quit SDL
SDL_Quit();

return 0;

}

This is getting me a bit annoyed. I started learning C/C++ a month ago
and nailed down all the basics and decided to try out LazyFoo’s tutorial
series. So I go to lesson 1, setting up SDL and try configuring
CodeBlocks/Dev C++/etc. Each compiler gives errors. I finally figured out
all the errors except this one:

Code:

-------------- Build: Debug in SDLTest ---------------

Linking executable: bin\Debug\SDLTest.exe
C:\Program Files (x86)\CodeBlocks\MinGW\bin\ld.exe: cannot find -lSDLmain
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
1 errors, 0 warnings

I’ve spent about 16 hours on this one problem so far. Googled and all… I
found one source on a french website, the google translation of it was so
bad I couldn’t understand it fully, but they suggested manually linking to
libSDLmain.a and libSDL.a

Any help is much appreciated!

I am running 64-bit Windows 7 by the way…

Try these setup instructions –
http://www.noquarterarcade.com/setting-up-a-codeblocks-project-with-sdl-on-windowsOn Fri, Nov 6, 2009 at 7:57 PM, Otoris wrote:

main.cpp:

Code:

#include “SDL/SDL.h”

int main( int argc, char* args[] )
{
//Start SDL
SDL_Init( SDL_INIT_EVERYTHING );

//Quit SDL
SDL_Quit();

return 0;

}


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Try building under MinGW/MSys instead.

After building and installing SDL like this:
svn co http://svn.libsdl.org/trunk/SDL
cd SDL
./autogen.sh
./configure --prefix=/mingw
make
make install

or extracting the mingw development package to c:\MinGW

do this:
gcc -o out.exe in.c sdl-config --cflags --libs

or this:
g++ -o out.exe in.cpp sdl-config --cflags --libs

You may need to install some additional packages from the MinGW/MSys
project to get SDL to build without errors. It should be obvious
which ones you need from the error messages.

That message means that the linker can’t find the libSDLmain.a file. If you
do have it, you should copy it to the compiler’s ‘lib’ directory (something
like C:\Program Files (x86)\CodeBlocks\MinGW\lib) or, alternatively, add the
path to the file to CodeBlocks’ linker search directories: Project->Build
options…->[Search directories]->[Linker]

Jonny DOn Fri, Nov 6, 2009 at 7:57 PM, Otoris wrote:

This is getting me a bit annoyed. I started learning C/C++ a month ago
and nailed down all the basics and decided to try out LazyFoo’s tutorial
series. So I go to lesson 1, setting up SDL and try configuring
CodeBlocks/Dev C++/etc. Each compiler gives errors. I finally figured out
all the errors except this one:

Code:

-------------- Build: Debug in SDLTest ---------------

Linking executable: bin\Debug\SDLTest.exe
C:\Program Files (x86)\CodeBlocks\MinGW\bin\ld.exe: cannot find -lSDLmain
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
1 errors, 0 warnings

I’ve spent about 16 hours on this one problem so far. Googled and all… I
found one source on a french website, the google translation of it was so
bad I couldn’t understand it fully, but they suggested manually linking to
libSDLmain.a and libSDL.a

Any help is much appreciated!

I am running 64-bit Windows 7 by the way…

main.cpp:

Code:

#include “SDL/SDL.h”

int main( int argc, char* args[] )
{
//Start SDL
SDL_Init( SDL_INIT_EVERYTHING );

//Quit SDL
SDL_Quit();

return 0;

}


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

You’re checking out SDL 1.3, which I believe no longer has a need for SDLmain.
Since the tutorial you’re using is most likely for SDL 1.2, just download the newest SDL 1.2 source archive from the main page. That, or remove SDLmain from the linker and use the backwards compatibility layer.

That said, there was a known issue with that release (it’s not still findable on the Code::Blocks forums?) that the SDL project did not have the correct library paths set up and so wouldn’t find the libs in the SDL subdirectory. As another poster has already written, adding the library path or copying the libs from the SDL subdirectory to the top libs directory are two possible solutions.

Asides from this, if you can bother with the techicalities, getting a more recent build of C::B should also fix this as well as adding a whole bunch of improvements but there’s no friendly installer.— On Sun, 11/8/09, nfries88 wrote:

From: nfries88
Subject: Re: [SDL] ld.exe cannot find -lSDLmain Code::Blocks 8.02
To: sdl at lists.libsdl.org
Date: Sunday, November 8, 2009, 12:34 AM

You’re checking out SDL 1.3,
which I believe no
longer has a need for SDLmain.

Since the tutorial you’re using is most likely for SDL
1.2, just download the newest SDL 1.2 source archive from
the main page. That, or remove SDLmain from the linker and
use the backwards compatibility layer.

-----Inline Attachment Follows-----


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org