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

Author Topic: Will a SFML program run on "ALL" PCs?  (Read 10915 times)

0 Members and 1 Guest are viewing this topic.

Raptor88

  • Full Member
  • ***
  • Posts: 111
    • View Profile
    • Email
Will a SFML program run on "ALL" PCs?
« on: June 04, 2012, 07:45:05 pm »
Will a .exe that is compiled using a stock Visual C++ 2010 that uses SFML 2 run on all PCs without having to load the net framework or anything else on the user's PC?  If not, is there a different "free" C++ compiler that I should use?

I did a search and found this thread titled:  "Compatibility to other computers"
http://en.sfml-dev.org/forums/index.php?topic=318.msg1842#msg1842

That thread seems to indicate that one has to jump through hoops and do all sorts of things (that I don't understand) to be able to have the .exe program run on other PCs that don't have VC++ installed.  For me, the whole purpose of using SFML is to end up with a .exe that does not require any user to have the .net framework or VC++ or anything else installed to run 100% correctly. 

Any answers to my questions above will be sincerely appreciated.  I'm just a beginner C++ programmer, though I did program using Basic, C and Assembler many years ago.

Thanks,
Raptor

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10282
    • View Profile
    • development blog
    • Email
Re: Will a SFML program run on "ALL" PCs?
« Reply #1 on: June 04, 2012, 08:00:18 pm »
You should read more about how applications work and what libraries are etc.

To answer your question: If you compile the application with the Visusal C++ compiler and link the runtime library dynamically you'll have to ship also the C++ redistrubitions. If you also link SFML dynamically you'll have to ship the SFML dlls too ofcourse.
If you ship everything that's needed it should run on all (newer = XP >) Windows systems. But it won't run on all 'PCs', since PC just means personal computer which can also run a Mac OS or a Linux for which you'd have to compile again with an apropriate compiler.

But you'll never need to install the .NET framework as long as you stick to pure C++.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://dev.my-gate.net/

Raptor88

  • Full Member
  • ***
  • Posts: 111
    • View Profile
    • Email
Re: Will a SFML program run on "ALL" PCs?
« Reply #2 on: June 04, 2012, 11:00:15 pm »
You should read more about how applications work and what libraries are etc.

To answer your question: If you compile the application with the Visusal C++ compiler and link the runtime library dynamically you'll have to ship also the C++ redistrubitions. If you also link SFML dynamically you'll have to ship the SFML dlls too ofcourse.
If you ship everything that's needed it should run on all (newer = XP >) Windows systems. But it won't run on all 'PCs', since PC just means personal computer which can also run a Mac OS or a Linux for which you'd have to compile again with an apropriate compiler.

But you'll never need to install the .NET framework as long as you stick to pure C++.

What I meant by "PCs" is IBM compatible PCs running Windows XP, Vista or Win7.  Sorry for not clarifying that.

You mentioned linking the runtime library dynamically and also linking SFML dynamically.  Is there a way to just have all of the code needed compiled into the one .exe file?  If not, is is just a matter of my install program copying files off the distribution CD into appropriate folders on the user's PC?

Thanks much for taking the time to help,
Raptor

Acrobat

  • Full Member
  • ***
  • Posts: 153
    • View Profile
Re: Will a SFML program run on "ALL" PCs?
« Reply #3 on: June 05, 2012, 08:20:06 am »
Quote
Is there a way to just have all of the code needed compiled into the one .exe file?
static linkage

Raptor88

  • Full Member
  • ***
  • Posts: 111
    • View Profile
    • Email
Re: Will a SFML program run on "ALL" PCs?
« Reply #4 on: June 05, 2012, 09:04:03 am »
Quote
Is there a way to just have all of the code needed compiled into the one .exe file?
static linkage

The terms I need to do research on.  Thanks much,
Raptor

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10282
    • View Profile
    • development blog
    • Email
Re: Will a SFML program run on "ALL" PCs?
« Reply #5 on: June 05, 2012, 06:46:55 pm »
Is there a way to just have all of the code needed compiled into the one .exe file?

Yes you need to link statically as mentioned by Acrobat.
To do so is fairly simple although not always adviced...
You'll need to build SFML on your own though.

In CMake just uncheck 'BUILD_SHARED_LIBS' and check 'SFML_USE_STATIC_STD_LIBS' then build SFML.
Afterwards you need to change settings in your own project. Add 'SFML_STATIC' to the project definitions (Porject->Settings->C++->Preprocessor) and change the runtime library to 'multithreaded-debug' (or release: Project->Settings->C++->Code generation->Runtime library).
That's it.

But keep in mind if you're using additionally libraries you'll have to compile them the same way.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://dev.my-gate.net/

Raptor88

  • Full Member
  • ***
  • Posts: 111
    • View Profile
    • Email
Re: Will a SFML program run on "ALL" PCs?
« Reply #6 on: June 06, 2012, 10:20:20 pm »
Is there a way to just have all of the code needed compiled into the one .exe file?

Yes you need to link statically as mentioned by Acrobat.
To do so is fairly simple although not always adviced...
You'll need to build SFML on your own though.

In CMake just uncheck 'BUILD_SHARED_LIBS' and check 'SFML_USE_STATIC_STD_LIBS' then build SFML.
Afterwards you need to change settings in your own project. Add 'SFML_STATIC' to the project definitions (Porject->Settings->C++->Preprocessor) and change the runtime library to 'multithreaded-debug' (or release: Project->Settings->C++->Code generation->Runtime library).
That's it.

But keep in mind if you're using additionally libraries you'll have to compile them the same way.
Wow, really good info!  I need all the help I can get.

Currently, I am just compiling C++ code using Visual Studio 2010 Express while learning C++.  I thought that I could just install SFML and compile either dynamic or static by changing some settings. (I haven't really researched installing SFML yet.)  Do I need to install CMake to link statically?  Could you explain what CMake does in layman's terms?  I googled CMake but can't quite grasp what its purpose is.

Also, would it be easier/faster to compile and link dynamically during development and then do a static link for the distribution .exe program?

Thanks!
Raptor
« Last Edit: June 06, 2012, 10:26:30 pm by Raptor88 »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Will a SFML program run on "ALL" PCs?
« Reply #7 on: June 06, 2012, 10:30:29 pm »
Quote
I thought that I could just install SFML and compile either dynamic or static by changing some settings.
You can. Don't bother with CMake, it's a meta-build system which is used to recompile SFML. Since SFML is distributed in both dynamic and static forms, you don't need to compile it yourself. And statically linking the standard library is not something that you should do unless you really know what you do, so forget that too.

Quote
Also, would it be easier/faster to compile and link dynamically during development and then do a static link for the distribution .exe program?
It makes no difference.
Laurent Gomila - SFML developer

Spirro

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Re: Will a SFML program run on "ALL" PCs?
« Reply #8 on: June 06, 2012, 11:02:43 pm »
I also looking into static linking of the VS 2010 runtimes for redistribution.  I use the Professional version so I have help files installed.  A quick search took me to a page that describing how static linking of these libraries if very frowned upon and didn't give an example of how to get it done.  However it did mention a simple work around to use so your VS 2010 compiled programs will run on computers without the VS 2010 compiler package installed.

The file you need depends on how your program is compiled.  You need either VCRedist_x86.exe, VC_Redist_x64.exe, or VCRedist_ia64.exe.  One of these will need to be downloaded on the target computer and installed, or included in your install package and executed on the target computer.

For static linking of the SFML libraries check http://www.sfml-dev.org/tutorials/2.0/start-vc.php .

Raptor88

  • Full Member
  • ***
  • Posts: 111
    • View Profile
    • Email
Re: Will a SFML program run on "ALL" PCs?
« Reply #9 on: June 06, 2012, 11:47:34 pm »
Quote
I thought that I could just install SFML and compile either dynamic or static by changing some settings.
You can. Don't bother with CMake, it's a meta-build system which is used to recompile SFML. Since SFML is distributed in both dynamic and static forms, you don't need to compile it yourself. And statically linking the standard library is not something that you should do unless you really know what you do, so forget that too.

Quote
Also, would it be easier/faster to compile and link dynamically during development and then do a static link for the distribution .exe program?
It makes no difference.
Hi Laurent,

First, thanks for creating and making SFML available for free to everyone.  That is really generous of you.
Thanks for the info on CMake.

And statically linking the standard library is not something that you should do unless you really know what you do, so forget that too.

From the responses I've received so far and with my limited knowledge, if I don't link statically, my .exe program will not be able to run on all Windows PCs unless I include dlls on the distribution CD and install them along with my .exe program.  Is that right?  Is there a link to info on how to distribute and install programs using SFML so they can run on any PC?

Thanks much,
Raptor
 

Raptor88

  • Full Member
  • ***
  • Posts: 111
    • View Profile
    • Email
Re: Will a SFML program run on "ALL" PCs?
« Reply #10 on: June 06, 2012, 11:53:26 pm »
I also looking into static linking of the VS 2010 runtimes for redistribution.  I use the Professional version so I have help files installed.  A quick search took me to a page that describing how static linking of these libraries if very frowned upon and didn't give an example of how to get it done.  However it did mention a simple work around to use so your VS 2010 compiled programs will run on computers without the VS 2010 compiler package installed.
Could you provide that link so I can read it?

Quote
The file you need depends on how your program is compiled.  You need either VCRedist_x86.exe, VC_Redist_x64.exe, or VCRedist_ia64.exe.  One of these will need to be downloaded on the target computer and installed, or included in your install package and executed on the target computer.
I assume this info is per the webpage you mentioned above.

Quote
For static linking of the SFML libraries check http://www.sfml-dev.org/tutorials/2.0/start-vc.php .
Thanks a lot for all of your info Spirro.  Very much appreciated,
Raptor


Spirro

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Re: Will a SFML program run on "ALL" PCs?
« Reply #11 on: June 07, 2012, 12:40:11 am »
Unfortunately the info I posted was from the local help files I downloaded after installation of VS 2010 on my system.  I changed my settings to view help online and briefly tried to find the page in online format, but couldn't find it so I printed the local help text to file and copy/pasted relevant portions below.

Quote
There are three ways to redistribute Visual C++ DLLs:

1)  We recommend that you use the Visual C++ Redistributable Package ( VCRedist_x86.exe, VCRedist_x64.exe, VCRedist_ia64.exe) to install all Visual C++ libraries as shared DLLs in %windir% \system32. Visual Studio installs this package in the %WindowsSdkDir%\Bootstrapper\Packages folder. You can also download it from the Microsoft Download Center. For an example of how to use this package, see Walkthrough: Deploying a Visual C++ Application By Using the Visual C++ Redistributable Package. 

2)  Use Visual C++ Redistributable Merge Modules to install a particular Visual C++ library as shared DLLs in %windir%\system32. Access to this folder requires that the installer application be run by a user with administrative rights. For more information please see Redistributing By Using Merge Modules. An example of this deployment may be found in Walkthrough: Deploying a Visual C++ Application By Using a Setup Project. 

3)  Install a particular Visual C++ DLL in the same folder as the application by using files provide in the Program Files\Microsoft Visual Studio 10.0\VC\Redist directory. This way is recommended to enable installation of applications by users who do not have administrative rights or when it should be possible to run an application from a share.

Below that in my help text is this:

Quote
It is not recommended to redistribute C/C++ applications that statically link to Visual C++ libraries. It is often mistakenly assumed that by statically linking your program to Visual C++ libraries it is possible to significantly improve the performance of an application. However the impact on performance of dynamically loading Visual C++ libraries is insignificant in almost all cases. Furthermore, static linking does not allow for servicing the application and its dependent libraries by either the application's author or Microsoft. For example, consider an application that is statically linked to a particular library, running on a client computer with a new version of this library. The application still uses code from the previous version of this library, and does not benefit from library improvements, such as security enhancements. Authors of C/C++ applications are strongly advised to think through the servicing scenario before deciding to statically link to dependent libraries, and use dynamic linking whenever possible.

There is a link provided in the first quote for the 'Walkthrough' that didn't get copied, but again I use local help so the 'Walkthrough' link goes to another page in my local help file.

When I went to the download center and entered a search for 'VCRedist_x86.exe' I was given two links to follow for 2008.  Both links were to rather large files(100 meg+), so I did a google for 'VCRedist_x86.exe' and got a link to Microsoft to that file directly and it was <5meg.  I assume it would be what you are looking for.

Raptor88

  • Full Member
  • ***
  • Posts: 111
    • View Profile
    • Email
Re: Will a SFML program run on "ALL" PCs?
« Reply #12 on: June 07, 2012, 07:41:44 am »
Unfortunately the info I posted was from the local help files I downloaded after installation of VS 2010 on my system.  I changed my settings to view help online and briefly tried to find the page in online format, but couldn't find it so I printed the local help text to file and copy/pasted relevant portions below. ...snip...

So nice of you to have done all that work to respond to my post.  I'll use the info you posted and do more Googling to learn more about it.

Thanks so much for taking the time,
Raptor

capz

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: Will a SFML program run on "ALL" PCs?
« Reply #13 on: June 08, 2012, 04:51:08 am »
I would also like to point out that you don't necessarily need to use VC++, there are other IDEs out there that use GCC for example and by definition don't link to any Microsoft libraries unless you make them. I used to use bloodshed devc++ when i was still on windows (it's getting really ancient now though) in combination with SDL, and all you'd end up with using that setup was the exe + the SDL dll. I would imagine something similar should be possible with SFML, too. I'm much more an Xcode user than a VC++ one though.

I just feel what you mean every time I install VC++ for an assignment and can't even find the darn .exe in that solution folder mess. So just saying that you don't necessarily need the monster truck called VC :)

..but it's still likely the way to go >_>
Geez I just added absolutely nothing of value to this thread. Go me  :o

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10282
    • View Profile
    • development blog
    • Email
Re: Will a SFML program run on "ALL" PCs?
« Reply #14 on: June 08, 2012, 04:24:22 pm »
Quote from: Laurent
You can. Don't bother with CMake, it's a meta-build system which is used to recompile SFML. Since SFML is distributed in both dynamic and static forms, you don't need to compile it yourself. And statically linking the standard library is not something that you should do unless you really know what you do, so forget that too.
I don't see why one should look into CMake, it's great and so simple. After you know how to use it, you won't depend anymore on precompiled libraries (not only limited to SFML). ;)
You're always so much against statically linking the runtime library. I know there are more pros for dynamic linking than static linking but the argument that you really need to know what you do seems really scary although it's not (unless you're pulling together 12 diffren libraries or so ;D). You only need a few further changes in the settings. No magic behind all this. ::)

Quote from: Raptor88
From the responses I've received so far and with my limited knowledge, if I don't link statically, my .exe program will not be able to run on all Windows PCs unless I include dlls on the distribution CD and install them along with my .exe program.  Is that right?
If you only want one .exe file you'll have to link everything statically including the runtime/standard library. But then again as mentioned by Spirro you'll only have to install the VC redistributionals which in fact are mostly already installed and if not you can point people to the Microsoft website.

Quote from: Raptor88
Is there a link to info on how to distribute and install programs using SFML so they can run on any PC?
You should still read a bit more about libraries and Windows application. Basically if you use the x86 SMFL libraries (so it will work on x86 and x64 machines), install the right runtime redistributionals and the target PC supports the used OpenGL version, your application will run on that machine. This should be true for most of the Windows XP, Vista and 7 machines.

I would also like to point out that you don't necessarily need to use VC++, there are other IDEs out there that use GCC for example and by definition don't link to any Microsoft libraries unless you make them.
You won't need to link against any Microsoft libraries - true, BUT if you compile with MinGW it still will look for the mingw runtime libraries unless you link statically. So you still end up with the same 'problem'. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://dev.my-gate.net/