I have created a c++ game with the following libraries : SDL2
and SDL2_MIXER
. I want to give the game to some friends who have no programming experience to play with. Now I don't really know how to do that.
What I have tried is to use installshield limited edition with visual studio. After giving the installation program to some friends they all had a common problem-error that a dll MVCsomething was missing.
What is the simplest way to give my friends the app? Since c++ is translated to assembly do I have to compile the source again each time I change a machine?

- 23
- 4
-
' do I have to compile the source again each time I change a machine?' good god no. It is, however, your responsibility to ensure that your delivered app has access to the DLL's it requires to run. – Martin James Feb 14 '16 at 17:30
-
1@MartinJames thanks for your reply. Can you explain something to me please? c/c++ is translated to machine code right? So machine code is produced. What happends if I deploy my app to a user with a different assembly than mine ? – omg133 Feb 14 '16 at 17:34
1 Answers
Given the way that you've tagged your question, it is unclear if you are using Visual Studio or CodeBlocks to compile the code.
I guessing that you're compiling it in Visual Studio, and therefore they're getting an error that they don't have the appropriate MSVCRT DLLs—in other words, the C runtime library that your code depends upon, having been compiled with Microsoft's compiler. Point them to download the version of the Visual C++ Redistributable matching the version of Visual Studio that you're using on your development computer. For example, if you have VS 2015, they'll need to install Visual C++ Redistributable for Visual Studio 2015.
Alternatively, you can bundle the required redistributable into your installer to make sure that it gets installed automatically, if it isn't already. In InstallShield, I believe that's done by marking the VC++ Redistributable as a "requirement". Make sure that it's set as a prerequisite. Although, judging from the answer to this question, it may be that InstallShield LE doesn't support this. If that's the case, my advice would be to ditch InstallShield altogether and use something like Inno Setup to build an installer. There is a moderate learning curve, but it is useful knowledge. That being said, I can't believe Microsoft would ship a mechanism for creating a setup program with Visual Studio that didn't support automated installation of the CRT. I have not kept up with what Visual Studio supports nowadays with respect to setup wizards.
Since c++ is translated to assembly do I have to compile the source again each time I change a machine?
No, no. Assuming that your friends are all running Windows (and not, say, Linux) and have x86-based machines (which they do if they're running Windows), your code will work fine. The only hitch would be if you are compiling 64-bit code that runs on your machine, but they only have 32-bit machines. Then you'll need to have a 32-bit and 64-bit version. (Or a single 32-bit version, which will run on both.)

- 1
- 1

- 239,200
- 50
- 490
- 574
-
1wow thanks for the concrete answer! I have one last question. c/c++ is translated to machine code right? So machine code is produced. What happens if I deploy my app to a user with a different assembly than mine ? Do all 32 bit or 64 bit processors have the same assembly? – omg133 Feb 14 '16 at 17:38
-
1@omg Yes, all processors from a single family use the same assembly language. This is why you can buy applications off the shelf or download them from the web and run them. The C++ code you compile is no different. The architecture supported by Windows and implemented by just about any Intel/AMD chip is called [x86](http://wikipedia.org/wiki/X86). There *are* other architectures out there, but Windows doesn't run on them. As I mentioned in my answer, though, the only thing you have to watch out for is 32-bit (x86) and 64-bit (x86-64), which *are* different but backwards compatible. – Cody Gray - on strike Feb 14 '16 at 17:45
-
I would also like to add that if you are using any 3rd party libraries that your application has dependencies of; then it would be advisable to include either the static (lib) files or dynamic (dll) files with your application and make sure that they are saved to the appropriate directories so that your application can find those files when it is installed on their machine. This may require adding registry entries and environment variables to your friends machine provided they are using a windows platform. This should be achievable through a good installer setup application. – Francis Cugler Feb 14 '16 at 22:11
-
1@Francis is right about required DLLs. You *never* need to bundle LIB files though, because the whole point of a static library is that the code they contain is compiled directly into your executable. DLLs are not, the code they contain is loaded dynamically, so they need to be there. As far as adding registry entries and environment variables, that is unnecessary in 98% of cases. Just put the DLLs in the same folder as your EXE file and you will be golden. That works fine so long as you aren't hard-coding paths to DLLs in your EXE, which you shouldn't be doing. Use the default search order. – Cody Gray - on strike Feb 15 '16 at 10:06