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

Author Topic: allow to build SFML as a monolithic library  (Read 6906 times)

0 Members and 1 Guest are viewing this topic.

amir ramezani

  • Jr. Member
  • **
  • Posts: 81
  • i'm a programmer who can't see well
    • View Profile
    • download useful software!
    • Email
allow to build SFML as a monolithic library
« on: October 19, 2014, 09:38:59 pm »
hi,
what is your idea to add a variable to cMake and ask the user to build a monolithic library or build SFML as a multi library?
if it builds as a single library, users dont need to think about linking errors in GCC
thanks
if you can't see well, you can't test your applications and operating system well
my game engine:
allegro game creator
my operating system:
AmirOS

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: allow to build SFML as a monolithic library
« Reply #1 on: October 19, 2014, 09:49:30 pm »
hi,
what is your idea to add a variable to cMake and ask the user to build a monolithic library or build SFML as a multi library?
if it builds as a single library, users dont need to think about linking errors in GCC
thanks

I think what you're trying to say is: "Why not release SFML as a single .a/.o/.dll/etc file instead of five separate files?"  If I'm wrong, please try to be more precise.

I don't think the common linking errors on this forum have much to do with whether SFML comes in one library or five.  It's usually things like compiler versions not matching, debug/release not matching, static/dynamic not matching, not copying .dlls to the target folder, etc.  The only user error that could be prevented by having one library instead of five is getting the order of libraries wrong on the linkline.  Though we have seen people get this wrong, it's only one possible error of many, it's a particularly easy one to get right since all of the official build tutorials show you the correct order, and it's a particularly easy one to diagnose since you'll get linker errors for symbols from only one or two of the modules.

In case you weren't aware, the benefit of it being five separate libraries is that users only link against the modules they actually use.  For instance, I never link against the networking library.  Some users may never link against the audio library.  Some users maybe not even need the graphics module because they do raw OpenGL and just want SFML to do the window creation for them.  This is just SFML fitting the general C++ philosophy of only making you pay for the things you actually use.
« Last Edit: October 19, 2014, 09:51:45 pm by Ixrec »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: allow to build SFML as a monolithic library
« Reply #2 on: October 20, 2014, 11:04:13 am »
There's no real advantage in having a monolithic library. Not to mention doing so defeats the whole purpose of SFML being modular. A lot of the projects I've seen so far don't use the network modules and quite a few don't even use the audio module, having them shipped regardless would be a waste.

And as Ixrec said, a monolithic library won't solve most of the current linker errors.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

amir ramezani

  • Jr. Member
  • **
  • Posts: 81
  • i'm a programmer who can't see well
    • View Profile
    • download useful software!
    • Email
Re: allow to build SFML as a monolithic library
« Reply #3 on: October 20, 2014, 08:31:22 pm »
ok, but if you've saw wxWidgets, you probebly see they allow monolithic library building and they provide a way to build a single lib or monolib
if you can't see well, you can't test your applications and operating system well
my game engine:
allegro game creator
my operating system:
AmirOS

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: allow to build SFML as a monolithic library
« Reply #4 on: October 20, 2014, 08:34:48 pm »
You will always find a library that does something. What we need in this discussion are arguments why SFML should do it.

(And wxWidgets is not a particularly good role model in general)
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Gambit

  • Sr. Member
  • ****
  • Posts: 283
    • View Profile
Re: allow to build SFML as a monolithic library
« Reply #5 on: October 22, 2014, 12:21:35 am »
I dont think there is a need for SFML to be able to be built as a singular library as it would benefit only applications who use all modules. Like Nexus said, there arent a whole lot of applications or libraries (at least public ones) that would use all of the modules.

SLC

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: allow to build SFML as a monolithic library
« Reply #6 on: November 03, 2014, 06:27:06 pm »
Honestly, I just made a Code::Blocks project (a while ago) which does (did) exactly what you're asking for. I know it's not recommended but it makes (made) a few things easier for me. And I'm not the kind of person who follows the standard just because "Hey, that's the standard bro!". As long as it makes things easier or makes sense to me, I tend to bend/change things to my advantage.

Most of the developers don't even bother with the Sound, Network and sometimes Graphics modules. All they need is a cross platform window api. Which is why I prefer GLFW over SFML (does what it promises and nothing more). But it sucks that GLFW doesn't support mobile platforms. Feel free to try making your own project (for your IDE) that includes the needed modules and as long as you have the proper files included and define the proper macros then you're good to go. My project made a static library and for some reason the overall size of my executable was smaller :-\ (way more smaller)

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: allow to build SFML as a monolithic library
« Reply #7 on: November 03, 2014, 07:50:19 pm »
And I'm not the kind of person who follows the standard just because "Hey, that's the standard bro!".
There is no standard on how to structure libraries...

As long as it makes things easier or makes sense to me, I tend to bend/change things to my advantage.
This is the problem. It makes sense to you. Don't forget that SFML is a library that many people use. Instead of arguing in favour of this suggestion by stating that it would benefit you, try to convince us that it will benefit a lot of other users as well. Also, just because it makes sense to you now, does not mean it will make sense to you in the future. Requirements change, bad habits stick around for much longer.

Most of the developers don't even bother with the Sound, Network and sometimes Graphics modules.
What is your source? I normally don't ask people this question, however given that that statement is the main point of your argument, it would be nice if we could verify if it is indeed a fact or just an argumentum ad populum. If you are referring to developers in general, and not just those who use SFML, then it could be true. However, if you are referring to those who already chose to use SFML, then I can tell you that what you said is far from the truth.

Which is why I prefer GLFW over SFML (does what it promises and nothing more).
I don't know if you are aware of this... but you can use sfml-window on its own. And judging by the APIs of GLFW and sfml-window, they are very similar. I don't know what you are referring to when you imply that sfml-window does more than it promises.

Feel free to try making your own project (for your IDE) that includes the needed modules and as long as you have the proper files included and define the proper macros then you're good to go.
You need to define one thing, SFML_STATIC if you are linking statically. And you need to include only the necessary headers for your own project, in your code. I don't know why you think that what you are doing is advantageous in any way...

My project made a static library and for some reason the overall size of my executable was smaller :-\ (way more smaller)
Of course it's smaller. If you understand what the compiler and linker does, then you would know that it can optimize a lot more if you compile everything into a single library. However: if you do this, you will potentially reduce the optimization opportunities when building your own project, and your own project might end up larger when linking against your monolithic library then if linking against the modules that you really make use of. This depends heavily on how you use the library of course, and without providing this library of yours for us to examine or showing us the code that you used to test your executable size, we won't be able to check if this is just an obvious case of a very generous optimization scenario.

I still don't really understand how these discussions about monolithic libraries can last for so long... If you ask me, the people who favour monolithic libraries over modular libraries solely for convenience (i.e. less typing/clicking) reasons don't know how to work efficiently. If you spend so much more time configuring your project than actually... you know... writing code, you are clearly doing something wrong. Disregarding the fact that I have a bit of experience, it takes me seconds to add the extra dependencies that I need to my linker settings. If you compare this to the hundreds of hours I spend writing code you can see why this makes absolutely no difference. In fact, the time we spend writing these posts alone is enough to last at least 100 projects worth of dependencies.
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

SLC

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: allow to build SFML as a monolithic library
« Reply #8 on: November 03, 2014, 09:08:04 pm »
Just to be clear on my previous post (because it might have been interpreted wrong). I wasn't saying that my ways are better or that there is an actual standard. By standard I mean how most developers do it, recommend you to do it and tell you to do it.

I was just saying that if the O.P. wants a monolithic library then he's free to make a project for it. And that it's not the end of the world to try something like that.

About the projects. There's not much to show. There's just some code that I've been experimenting with it and come to the conclusion that GLFW might be more suitable for someone who needs a "whole in one" library. (SDL tries to take too much control over things)

The Sound, Network and Graphics modules are good for simple things and what I found them to be great at is to provide a base for implementing your own and learning something in the process.

I'm not some expert and was just a personal opinion. Sorry for not placing an "Off topic" at the top :)