Deploy a c++ game to other windows machines - c++

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?

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.)

Related

Visual Studio 2017 C++ Exe for any pc (linking vcruntime140.dll)

I'm very new to GUI programming in c++, thus I don't have that much experience.
I created myself a GUI for my programm using the Visual Studio 2017 CRL package and now I'm trying to make this exe available for everyone.
The application works fine for those who have Visual Studio or VC Runtime installed but for those who don't the programm throws something like: "vcruntime140.dll is missing on your computer to run this app".
I am not sure how to link these dll's in my programm so that EVERYONE is able to use it.
I'm also not quit sure how I would link dll's.
There's basically two options.
The Standard in the industry is to ship the Visual Studio 20xx Runtime Redistributable Installer alongside your program, and have it run before anyone tries to run your program themselves, to make sure that the .dll files are installed onto the target computer.
The other option is to change the way that the libraries are linked to the executable at compile-time. This is done with a flag in Visual Studio:
Basically, you want to change the Runtime Library field to either say Multi-Threaded or Multi-Threaded Debug depending on whether you're in Release or Debug mode, as opposed to "Multi-Threaded DLL", which is the default.
Note, however, that you need to make sure that every single library you're using was compiled the same way: if any of them were compiled using the DLL version of the Runtime Library, they'll interoperate with your code in funny ways, and the least of your problems will be that they'll need the DLLs installed anyways, defeating your effort.
Naturally, that's not an issue if all your libraries are Header-Only, but if any of them have been compiled, then you'll need to recompile them using the correct settings.
You need to install Visual Studio 2017 redistribuables on the machine (that's how it works for every version of Visual Studio).
However, I could not find any official link on Microsoft website (probably because this is not officially released yet)....
You probably need to use 2015 version (for which redistribuables are available here) and wait for 2017 to become an official release.

visual studio 2015. c++ console application converted in setup project with all dll

So i'm fairly new to VS and coding and I've recently made a small snake game in a C++ console application project, which works fine but i would like to get it to work on another PC without VS. The closest i have found to answering my question were these other StackOverflow questions here and here. i have installed the vs installer projects extension to try make it a setup project and include the required dependencies but i cant work out how to do this. Does anyone have any info to guide me through my last step of this problem or am i completely on the wrong track?
If the application uses dynamic runtime (which is the default), it uses the VS DLL files. To provide them, the Visual Studio Runtime Redistributable for that particular VS version needs to be installed on the target machine (as mentioned in your second link).
So that means you need to setup the installer that way. I didn't use it, but there might be some options that the resulting setup can either contain or download and install the VS redistributable automatically.
See also here: How to install redistributable with visual studio setup? (but it is for VS 2013, there might be some changes in 2015)
Well, you don't tell us what kind of project your C++ console app is...
Using only C++, your app can be built with different versions of the CRT, like for instance:
V120 (VS-2013)
V120_XP (VS-2013 w/ XP support)
V140 (VS-2015)
V140_XP (VS-2015 w/ XP support)
Even on VS 2015, you can choose the version of the CRT you want, and use an older version, if needed.
Anyway, the target computer will need the DLLs for the correct CRT version.
Microsoft provides them. You can either ship them with your product, if you have a custom installer, or use the installer provided by Microsoft.
MSDN - Determining Which DLLs to Redistribute
For instance, using V120:
msvcp120.dll
msvcr120.dll
Your project might also use .NET.
In such a case, you also need to install the correct version in the host machine.

remove msvc dlls dependency to run qt application

How to remove msvc dlls (example: msvcr100.dll) dependency to run qt appliation?
I've developed a qt application which runs just fine in dveloper machine but unable to run on any other machine gives error message "program can't start because MSVCR100.dll is missing from your computer". I can solve this error by copying that file in the application folder but I dont want to copy, instead I want to link statically or some other way to remove that dependency.
Thanks in advance
The issue is that you are probably trying to run an application on a machine which has a different Visual Studio (MSVC) version installed than the version that was used for building your application itself.
Generally, the correct solution is to install the corresponding Visual Studio redistributable package on the target machine. It is not a "workaround" or "hack" because if you wish to use an application built with different runtime libraries, etc, then it is expected. Here you can read a bit more about it:
Redistributing Visual C++ Files
Yes, it is a bit unfortunate, and apparently MS has not managed to make it the most ideal, but after all, it is simple enough to circumvent. Note that the target machine would not only have issues with your application, but in general with any distributed in a similar fashion.
The other way to solve the issue is to build the application with the same environment that is installed on the target machine, but this can easily go haywire if you need to supply the application to several machines with versatile setup. Now, I would say this is the "hackish" approach.
You will need to grab the redistributable for this particular problem from here:
Microsoft Visual C++ 2010 Redistributable Package (x86)
Microsoft Visual C++ 2010 Redistributable Package (x64)
Even if you went down for statically hacking this around somehow, you would need to deal with nasty consequences when using your application with DLLs and static libraries, etc.
As far as I know, you can't link statically to Visual Studio Redistributable. Any application built with Visual Studio Compiler needs the corresponding msvcXXX.dll to run. Installers containing all dll for each specific version of MSVC are available here: http://search.microsoft.com/en-us/DownloadResults.aspx?q=redistributable
If you want avoid errors for your users when you distribute your application, you have some solution. A commonly used is to install the right redistributable package before installing your application on the user machine. Often used tools (NSIS, Inno Setup, etc.) have options to run other executable in the process. And each Microsoft redist package can be run silently (without any window display to user).
Note: This problem is absolutely not related to qt. It comes directly from the compiler you choose.

Compile Visual Studio projects without having Visual Studio installed?

Is there a way to compile a Visual Studio 2012 project without having the VS installed? I need to compile C++ stuff for windows quite rarely and buying the product is not justified as there's no profit (community projects). In most of the cases the project and solution files will be available. If there's a way to compile the code with SDK, could you please share an example?
Thanks!
You can download visual studio express for free. Whenever you build a solution, the bin folder in your project folder will contain the compiled code.
http://www.visualstudio.com/en-us/downloads/download-visual-studio-vs.aspx
EDITED: (per MS website)
Visual Studio Express 2013 for Windows Desktop enables the creation of desktop apps in C#, Visual Basic, and C++, and supports Windows Presentation Foundation (WPF), Windows Forms, and Win32.
Sign in to Visual Studio within 30 days with your Microsoft account to synchronize your settings across multiple machines and register your product.
Your best bet is likely going to be using msbuild which will allow you to build a solution or project without having Visual Studio installed.
If you have the free version VC++ Express installed (and thus the compiler toolchain), you might find it more interesting to use Eclipse CDT as IDE on top. At least the newer versions (I think since Helios) support using the native MS toolchain. You can import from native
VS projects also.
Eclipse is the more powerful IDE IMHO, and will additionally support other toolchains (either cross compiling, or Windows alternatives as MinGw GCC).

x64 if Visual Studio C++ 2012?

I have been using SDL with Visual C++ for a while, mostly making practice games, but I find that I can't give the game to other people unless they have Visual C++ themselves. One problem that I found using a Dependency Tracker was that the source files and such used both x86 and x64. After looking through, I found that my Visual Studio source files were all in x64, so naturally I went through and modified my SDL files to be the x64 package instead of the x86. After fussing about how it still insisted on not working, I found out that the program that I was exporting was in x86 all along! I've been trying since to get it to export in x64 since, but I simply don't know how. Can somebody help me do this?
Oh well, this question is a bit hard to understand for me. It looks, like MSalters suggested, that you mix up some terms.
The source of your problem is probably just the missing Visual Studio Redistributable on the target computer.
You can get it here. Not that this is the redistributable for VS 2012 Update 1. There are also different versions for x86 and x64 (also arm). Depending on what your output is, you have to deliver the right version of the redistributable with you programms.