SFML community forums

Bindings - other languages => C => Topic started by: burton on February 02, 2010, 03:19:29 pm

Title: Linker problems; mingw gcc, Windows
Post by: burton on February 02, 2010, 03:19:29 pm
Hi, everyone.

I was compiling my very first C code using this multimedia library, but instead of seeing an image of a muppet on the screen, my compiler gave me this error:
Code: [Select]
C:\user\mingw\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\mingw32\bin\
ld.exe: cannot find -lsfml-graphics
collect2: ld returned 1 exit status


My compiler of choice is mingw's gcc. I'm running Windows XP.

The command line:
Code: [Select]
C:\user\tests>gcc sfml.c -o sfml.exe -lsfml-graphics -lsfml-window -lsfml-system
Title: Linker problems; mingw gcc, Windows
Post by: OniLinkPlus on February 02, 2010, 03:40:15 pm
It's simple. You haven't installed the SFML .lib files(might be .a) to your MinGW/lib directory.
Title: Linker problems; mingw gcc, Windows
Post by: Laurent on February 02, 2010, 03:59:38 pm
Or cleaner: add -L<path/to/sfml/lib/mingw> to your linker options.

This is all explained in the "getting started" tutorial...
Title: Linker problems; mingw gcc, Windows
Post by: burton on February 02, 2010, 06:43:17 pm
But that's the thing: I've installed them to /mingw/lib/

I put the .a files to lib, .dll files to bin and include folder to include.

edit.
Code: [Select]
gcc -c sfml.c
gcc -o sfml.exe sfml.o -Lc:\user\downloads\SFML-1.5\CSFML\lib\mingw\ -lsfml-graphics -lsfml-window -lsfml-system

gives me the same errors.
Title: Linker problems; mingw gcc, Windows
Post by: Laurent on February 02, 2010, 07:35:53 pm
Ah, you're using CSFML? Then link to csfml-xxx ;)
Title: Linker problems; mingw gcc, Windows
Post by: burton on February 02, 2010, 08:06:09 pm
Oh dear, I should have noticed. :)

Thanks!
Title: Linker problems; mingw gcc, Windows
Post by: michelsteeve on March 30, 2010, 09:00:00 am
If we have installed all necessary header files then after if linker error come then what does it mean?? It can possible that file has been corrupted and that's why the linker error occur??
Title: Linker problems; mingw gcc, Windows
Post by: Laurent on March 30, 2010, 09:06:48 am
What error do you get?