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

Author Topic: How to link SFML statically (GCC/MinGW)?  (Read 10449 times)

0 Members and 1 Guest are viewing this topic.

Tenry

  • Full Member
  • ***
  • Posts: 120
  • Experienced Programmer
    • View Profile
    • Simon-Burchert.com
How to link SFML statically (GCC/MinGW)?
« on: August 13, 2010, 01:55:38 am »
I use MinGW (GCC) on Windows Vista and I don't use a real IDE. I always either type the commands on the command line or I create makefiles.

When compiling and linking a project, it might look something like this:
Code: [Select]
g++ main.cpp -o test.exe -lsfml-window -lsfml-system
In this case test.exe will always need the required DLLs of SFML (e.g. sfml-system.dll).

By searching in the internet I thought -static would be the solution:
Code: [Select]
g++ main.cpp -o test.exe -static -lsfml-window -lsfml-system
But also this result needs the DLLs.

I'm wondering how, if it is possible at all, I can link against the static sfml libraries.  :(
Please note that my previous display name was "Shy Guy".

Dig

  • Newbie
  • *
  • Posts: 31
    • View Profile
How to link SFML statically (GCC/MinGW)?
« Reply #1 on: August 13, 2010, 03:58:13 am »
the static libraries have -s at the end of their name,

so maybe:

Code: [Select]
g++ main.cpp -o test.exe -lsfml-window-s -lsfml-system-s

would work?

Tenry

  • Full Member
  • ***
  • Posts: 120
  • Experienced Programmer
    • View Profile
    • Simon-Burchert.com
How to link SFML statically (GCC/MinGW)?
« Reply #2 on: August 13, 2010, 03:48:56 pm »
Quote from: "Dig"
the static libraries have -s at the end of their name,

so maybe:

Code: [Select]
g++ main.cpp -o test.exe -lsfml-window-s -lsfml-system-s

would work?

That doesn't work. Compiling a little program using sf::Clock gives me the following errors:
Code: [Select]
/mingw/lib/libsfml-system-s.a(Clock.o):Clock.cpp:(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
And some more undefined references.

Btw, where is it documented / "told" me about the usage with "-s", and "-d" after lib name? Does d mean "debug"?
Please note that my previous display name was "Shy Guy".

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
How to link SFML statically (GCC/MinGW)?
« Reply #3 on: August 13, 2010, 03:56:40 pm »
Quote
That doesn't work. Compiling a little program using sf::Clock gives me the following errors:

That's a compiler problem, it's not related to SFML. Make sure that you use the right version of gcc (as described in the Code::Blocks tutorial).

Quote from: "tutorial"
Btw, where is it documented / "told" me about the usage with "-s", and "-d" after lib name?

In the "getting started" tutorial, of course...
Quote
For the Debug configuration, you can link with the debug versions of the libraries, which have the "-d" suffix ("-lsfml-system-d" in this case).
This is for the dynamic version of the libraries, the one using the DLLs. If you want to link with the static version of the libraries, add the "-s" suffix : -lsfml-system-s, or -lsfml-system-s-d for the debug version.
Laurent Gomila - SFML developer

Tenry

  • Full Member
  • ***
  • Posts: 120
  • Experienced Programmer
    • View Profile
    • Simon-Burchert.com
How to link SFML statically (GCC/MinGW)?
« Reply #4 on: August 13, 2010, 04:41:13 pm »
Quote from: "Laurent"
Quote
Btw, where is it documented / "told" me about the usage with "-s", and "-d" after lib name?

In the "getting started" tutorial, of course...

Oh, but I was looking at the "gcc (Linux)" tutorial and not the "Code::Blocks (MinGW)" tutorial as I am not using Code::Blocks or any other IDE, just MinGW on Windows. :roll:
Any how may I link statically on Linux? Or is it always linked statically there?


Quote from: "Laurent"
Quote
That doesn't work. Compiling a little program using sf::Clock gives me the following errors:

That's a compiler problem, it's not related to SFML. Make sure that you use the right version of gcc (as described in the Code::Blocks tutorial).

Okay, so I will read the Code::Blocks tutorial now, too and download the newer version of MinGW.

Thanks so far ^^
Please note that my previous display name was "Shy Guy".

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
How to link SFML statically (GCC/MinGW)?
« Reply #5 on: August 13, 2010, 04:48:43 pm »
Quote
Any how may I link statically on Linux? Or is it always linked statically there?

There's no static version on Linux, static libraries are useless and are not recommended on this OS.
Laurent Gomila - SFML developer