Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Linker problems; mingw gcc, Windows  (Read 10327 times)

0 Members and 1 Guest are viewing this topic.

burton

  • Newbie
  • *
  • Posts: 3
    • View Profile
Linker problems; mingw gcc, Windows
« 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

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
Linker problems; mingw gcc, Windows
« Reply #1 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.
I use the latest build of SFML2

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Linker problems; mingw gcc, Windows
« Reply #2 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...
Laurent Gomila - SFML developer

burton

  • Newbie
  • *
  • Posts: 3
    • View Profile
Linker problems; mingw gcc, Windows
« Reply #3 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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Linker problems; mingw gcc, Windows
« Reply #4 on: February 02, 2010, 07:35:53 pm »
Ah, you're using CSFML? Then link to csfml-xxx ;)
Laurent Gomila - SFML developer

burton

  • Newbie
  • *
  • Posts: 3
    • View Profile
Linker problems; mingw gcc, Windows
« Reply #5 on: February 02, 2010, 08:06:09 pm »
Oh dear, I should have noticed. :)

Thanks!

michelsteeve

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Linker problems; mingw gcc, Windows
« Reply #6 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??

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Linker problems; mingw gcc, Windows
« Reply #7 on: March 30, 2010, 09:06:48 am »
What error do you get?
Laurent Gomila - SFML developer