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

Author Topic: Making a standalone program that uses SFML?  (Read 6380 times)

0 Members and 1 Guest are viewing this topic.

declan

  • Newbie
  • *
  • Posts: 34
    • View Profile
Making a standalone program that uses SFML?
« on: July 03, 2010, 03:45:50 am »
Hey everyone!

I keep wanting to show people that aren't physically near me what my neat program can do. Then I realize that I can't just send them the executable, so I say, ok, they know how to compile source code. And then I realize that they'd also need the SFML libraries to compile this.

Is there any way to send them only what they'd need to run it, to have a standalone little executable?

Thanks!

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Making a standalone program that uses SFML?
« Reply #1 on: July 03, 2010, 12:56:03 pm »
If you link to SFML statically, this is almost possible. On Windows, some DLLs like OpenAL32.dll have to be delivered (if OpenAL isn't installed), and depending on the compiler, you might have to distribute some additional files. For example, in MSVC++, you can't link statically to both the CRT and SFML (or at least you couldn't when I tried it the last time, which was a while ago).
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Svenstaro

  • Full Member
  • ***
  • Posts: 222
    • View Profile
Making a standalone program that uses SFML?
« Reply #2 on: July 03, 2010, 01:26:22 pm »
Your best bet is to distribute everything needed as shared libraries and link your executable completely dynamically as well. Then you can just send a very tiny executable each time you change something and have other people try it out.

If you go the static route, you will note have to distribute any extra files but your executable will be rather huge each time you send it because you're sending all the extra data each time.

IMO, static linking is not worth it (and it's harder too, you will need to recompile your whole linking chain!). You should distribute all extra files and executable in a dynamic/shared fashion.

declan

  • Newbie
  • *
  • Posts: 34
    • View Profile
Making a standalone program that uses SFML?
« Reply #3 on: July 27, 2010, 10:27:36 pm »
Well, it would be on the same OS, if that helps. But I don't understand what to do really. Couldn't I do it (statically I think?) so that I only send them the pieces of the library that my program is using?

Thanks!

Svenstaro

  • Full Member
  • ***
  • Posts: 222
    • View Profile
Making a standalone program that uses SFML?
« Reply #4 on: July 28, 2010, 01:46:30 am »
If you link statically, all your sources and libs will be in the single binary file you provide. This can get you quite a huge file.

If you link dynamically, all libs will be separate and your binary will only contain your own code and links to other libs. This is probably what you want.

declan

  • Newbie
  • *
  • Posts: 34
    • View Profile
Making a standalone program that uses SFML?
« Reply #5 on: July 28, 2010, 02:05:46 am »
Quote from: "Svenstaro"
If you link statically, all your sources and libs will be in the single binary file you provide. This can get you quite a huge file.

If you link dynamically, all libs will be separate and your binary will only contain your own code and links to other libs. This is probably what you want.


Hmmm, ok. But would my friends have to have SFML installed? If I just wanted to send someone the program, would I have to send them the libs too?

Svenstaro

  • Full Member
  • ***
  • Posts: 222
    • View Profile
Making a standalone program that uses SFML?
« Reply #6 on: July 28, 2010, 02:11:43 am »
Indeed, they would have to have SFML and your other libs. If they are on Linux they can simply get them through they package manager. If they are on Windows you should just send them the dlls the first time.

declan

  • Newbie
  • *
  • Posts: 34
    • View Profile
Making a standalone program that uses SFML?
« Reply #7 on: July 28, 2010, 02:37:37 am »
Quote from: "Svenstaro"
Indeed, they would have to have SFML and your other libs. If they are on Linux they can simply get them through they package manager. If they are on Windows you should just send them the dlls the first time.


Hmmm...if I wanted to do it statically, would it include the entire library, or just the ones from it they need?

Svenstaro

  • Full Member
  • ***
  • Posts: 222
    • View Profile
Making a standalone program that uses SFML?
« Reply #8 on: July 28, 2010, 02:39:52 am »
Statically linking would include everything you link against in the executable and you would also have to recompile some deps statically that are only available in dynamic form right now.

dunce

  • Jr. Member
  • **
  • Posts: 77
    • View Profile
Making a standalone program that uses SFML?
« Reply #9 on: July 28, 2010, 08:24:51 am »
Some of SFML dependencies have licenses (LGPL) that dont permit static linking. Thus you have to include those dlls in your distribution at least once anyway.

Svenstaro

  • Full Member
  • ***
  • Posts: 222
    • View Profile
Making a standalone program that uses SFML?
« Reply #10 on: July 28, 2010, 03:14:07 pm »
Of course LGPL permits static linking. But then your application needs to be at least LGPL as well. Is assumed this was the case, was it not?

dunce

  • Jr. Member
  • **
  • Posts: 77
    • View Profile
Making a standalone program that uses SFML?
« Reply #11 on: July 28, 2010, 04:01:54 pm »
I meant closed source applications.

 

anything