but why is dynamically linking libraries dumb? |
It's personal opinion. But my logic is as follows:
1) Nobody (or at least very few people) have SFML installed on their system already, so if you want your program to work, you have to bundle the DLL with your exe when you distribute it anyway.
2) Even if they already do have sfml on their system, it might be a different version and therefore incompatible with your exe... so you'd still have to distribute the dll with the exe
3) The combined filesize of the dll + exe will be larger than just the statically linked exe
4) There's more risk of the user misplacing the dll and/or replacing it with an incorrect version of of the dll. If it's statically linked the risk is zero.
5) It contributes to the user's computer getting riddled with dozens of copies of sfml dlls.
6) Statically linking allows for possible optimizations that dynamically linking does not.
Note that most of these problems are due to the way Windows handles shared libs (ie: it doesn't really). On other platforms (for example, many Linux distros), shared libs are common because there's support for managing them built in. In those cases, the opposite is true, and dynamically linking is preferred.
But yeah... on Windows... save yourself and your user some headaches and just statically link.
So when I actually start coding and I #include <sfml.h> do I just write:
#DEFINE DEBUG |
No. Do not #define DEBUG. MSVS does this automatically for debug builds. The reason those #ifdefs are in there is so that the header can identify whether it's a Debug or Release build, and link to the appropriate build of SFML.
then #DEFINE SFML_STATIC if I want static libs, or leave out the line if I want debug? |
The header already kind of #define's SFML_STATIC. If you want dynamic libs, you'll have to comment out or delete lines 6-8 of that header.
or leave out the line if I want debug? |
Statically linking has absolutely nothing to do with debugging. Don't worry about debug/release stuff. MSVS will do that automatically. The only option you really have here is static vs. dynamic linkage.
If you want static:
- do nothing. The header is already set up for statically linking.
If you want dynamic:
- comment out or delete lines 6-8 of that header.
Once you make that decision... all you have to do is
#include <sfml.h>
. Nothing more.