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

Author Topic: [SOLVED] Link error due to object files (I think)  (Read 1313 times)

0 Members and 1 Guest are viewing this topic.

Lowest0ne

  • Newbie
  • *
  • Posts: 11
    • View Profile
[SOLVED] Link error due to object files (I think)
« on: April 24, 2013, 05:32:00 pm »
My friends and I are having some trouble getting a project to statically link to SFML.

I happen to have a different project that links just fine (statically).  So I've been trying to figure out differences.  For my computer (WindowsXP, MinGW), the issue seems to stem from making a .o.

main.cpp:
#include <SFML/Graphics.hpp>
int main()
{
    sf::RenderWindow window;
    return 0;
}

I can compile with this command line:
Code: [Select]
g++ -I../../include main.cpp -o test.exe -DSFML_STATIC -L../../lib/sfml -lsfml-graphics-s -lsfml-window-s -lsfml-system-s
However, if I do this:
Code: [Select]
g++ -I../../include -c main.cpp -o main.o
g++ -I../../include main.o -o test.exe -DSFML_STATIC -L../../lib/sfml -lsfml-graphics-s -lsfml-window-s -lsfml-system-s
I get link errors: Undefined reference to sf::RenderWindow

Is there something that I am missing?

Thanks

« Last Edit: April 24, 2013, 05:47:25 pm by Lowest0ne »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Link error due to object files (I think)
« Reply #1 on: April 24, 2013, 05:42:51 pm »
SFML_STATIC is a compiler flag, not a linker flag (it must be given in your first command line).
Laurent Gomila - SFML developer

Lowest0ne

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Link error due to object files (I think)
« Reply #2 on: April 24, 2013, 05:46:55 pm »
Ah, sweet.  Thank you very much :)

 

anything