SFML community forums

Help => General => Topic started by: Lowest0ne on April 24, 2013, 05:32:00 pm

Title: [SOLVED] Link error due to object files (I think)
Post by: Lowest0ne 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

Title: Re: Link error due to object files (I think)
Post by: Laurent 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).
Title: Re: Link error due to object files (I think)
Post by: Lowest0ne on April 24, 2013, 05:46:55 pm
Ah, sweet.  Thank you very much :)