Windows 7 installer for game made in cocos

Windows 7 installer for game made in cocos
0.0 0

#1

Just wondering if anyone had any recommendations for a package to make an installer for a Windows 7 game made using cocos2d-x?

It’s a simple game, just the exe and some graphics files but there are lots of dependencies.
Cocos seems to need the Visual Studio 2010 and 2012 runtime libraries, and I need the 2015 one.
Also it needs DirectX, so these all need to be installed if they aren’t present.

Can anyone recommend a system that will check for and install the prerequisites, and then install the game, all from one single downloadable exe/msi file?


#2

There are so many: https://www.google.com/search?q=freeware+windows+installer+creator&oq=free+windows+install+creator&aqs=chrome.1.69i57j0l2.16342j0j7&sourceid=chrome&ie=UTF-8


#3

Which is why I was hoping for a recommendation from someone with experience using them.
So far I’ve tried Windows Installer and Installshield Express, but neither seems to quite be doing what I want. -

  • Windows Installer isn’t very good at installing the runtimes, and has text over my banner bitmaps that I have to manually edit the msi file to get rid of
  • Installshield Express seems to be focussed on CD/DVD based installations, and doesn’t seem to provide a single downloadable file.

#4

@dogwalker I know has an awesome game running on Windows, perhaps he can help us out.


#5

It was really trial and error. In my case, I build for Steam, so I place all the libraries in the appropriate folder. Steam also has a configuration screen for your app, where you can specify what runtimes it needs.

Unfortunately, when I tried just using their configuration screen, that didn’t seem to be enough, if I recall. In addition, we don’t likely really need the full installations, just a few dll files (at least, that’s what I found with mine).
So I manually added dlls msvcp120.dll, msvcr100.dll, etc to my content folder. Steam picks up whatever is in the content folder and packages it.

I haven’t looked into how to do this outside of Steam, but it seems similar - put everything you need (dlls, libs, exe, etc) in one folder and likely modify some packaging script.

Sorry I can’t be more help, but I hope that helps a little bit.


#6

Thanks, that is very helpful! I’m going to be tackling Steam soon too.
If I just use the dlls I can probably get the Windows Installer to do the job from Visual Studio, and add a script in to remove the annoying banner text.
Cocos does seem to need a lot of VS runtimes due to the dll dependencies.
I think I have msvcr100, msvcp120 and msvcr140. That’s three separate packages if you go via the ‘official’
installers.


#7

I think Inno Setup is best free option.
As mentioned add those dlls while making installer.


#8

look for the dependencies yourself, copy them to one folder and try out your game on a fresh install of windows 7 without any updates. If it works, package it into an installer.

  1. To list your dependencies, use dumpbin.exe (in the visualstudio VC folder)
    dumpbin.exe /dependents your_game.exe

    Example output
    Microsoft ® COFF/PE Dumper Version 12.00.21005.1
    Copyright © Microsoft Corporation. All rights reserved.

     Dump of file C:\Users\kalipo\Documents\Cocos\CocosProjects\NakamaTutorial\bin\debug\win32\NakamaTutorial.exe
    
         File Type: EXECUTABLE IMAGE
    
           Image has the following dependencies:
    
             libcocos2d.dll
             MSVCP120D.dll
             MSVCR120D.dll
             KERNEL32.dll
    
           Summary
    
                 4000 .data
                 6000 .idata
                 F000 .rdata
                 4000 .reloc
                 F000 .rsrc
                63000 .text
    

You can see that you should have libcocos2d.dll and MSVCP12.dll should be in your game folder. MSVCR12.dll “i think” comes with the visual c redistributables . The visual c redistributable (MSVCR12) should be installed from microsoft
[https://www.itechtics.com/microsoft-visual-c-redistributable-versions-direct-download-links/](http://direct download links). Be sure to test your game on a virtual machine with a fresh install of windows to make sure all dependencies work. Now bundle your exe and the visual c redistributable with your installer. Good luck. Any chance I can beta test? :slight_smile:


#9

Right, I think I have this working to my satisfaction now so I thought I’d share what I learned along the way.

My app installer uses Installer Projects (a free extension in Visual Studio - https://marketplace.visualstudio.com/items?itemName=VisualStudioProductTeam.MicrosoftVisualStudio2015InstallerProjects) to build an msi file that contains everything I need. This was fairly straightforward to set up, mostly dragging the project files I need into the file system layout.

However! This relies on the Visual Studio Runtimes being installed on the device, so I wanted a way to have them install if they were missing. This needs more than a raw msi file, it needs one with a bootstrapper. To make this I used WiX ( http://wixtoolset.org/ ) with a very simple script indeed, using these lines to include the runtimes from the vcredist files that Microsoft handily provide.

  <ExePackage SourceFile="redist\vcredist_x86_2010.exe"  Name="vc2010 Runtime" InstallCommand="/quiet /norestart" PerMachine="yes" Permanent="yes" />
  <ExePackage SourceFile="redist\vcredist_x86_2013.exe"  Name="vc2013 Runtime" InstallCommand="/quiet /norestart" PerMachine="yes" Permanent="yes" />
  <ExePackage SourceFile="redist\VC_redist.x86_2017.exe" Name="vc2017 Runtime" InstallCommand="/quiet /norestart" PerMachine="yes" Permanent="yes" />

…followed by my msi package from the first part.
This works brilliantly, installing the packages if it needs to and not installing them if it doesn’t.

The need for three runtimes is a bit unfortunate, but these are dragged in to cocos because it links to prebuilt versions of (I think) sqlite3.dll and zlib1.dll, and they need 2013 and 2010. It’s just one of those things where it was easier to include the runtimes than rebuild the libraries without them.

The Wix wrapper means you don’t see the interface from the msi file installer, so the problem with the text writing over my logo can’t be seen any more. It also makes a handy, single msi file containing all the redist files it needs internally, and this can be downloaded and installed no problem.

@smitpatel88 I did look at Inno Setup, and it looks very powerful, but my installer was really quite simple (although it still seemed more difficult to make than it needed to be) and the automatic templates I got with Wix worked well enough for me. I didn’t have to define any dialog boxes or anything. I pretty much just specified an icon, which vc_redists I wanted, and my app installer and it took care of the rest.

Hope this is helpful to people in future. Most of my time was spent finding a suitable installer from the many, many options available so if I can save people some time then that’ll be handy.

@Kalipo, we are in a closed beta at the moment but I can put you down for the next round!


#10

Hey, while we’re on this subject, I’m working on two things at the moment, before starting on the next version of my game:

  1. try to upgrade from cocos2d-x 3.13 to 3.16
  2. try to get gen-libs working so I can have faster compiles

When I look at gen-libs examples, they all have “vs 2015” in the command line. I’m currently on Visual Studio 2013. What version of VS are you folks using? I think I’ll try 2015 now, given the apparent gen-libs dependency.

As for moving my large project to 3.16, what I’ve done is create a simple test project with 3.13 and checked it into git, then removed all the files and created a project with 3.16, so I can compare the two projects. I’m hoping that’ll help me see what I need to do. If anyone has any other advice, I’d appreciate it.

Oh, and I need my project to work equally well on my PC (for Windows) and my Mac (for iOS). AND if I can create a Mac version this year, that would be a huge plus!


#11

I’m using VS 2015 - which reminds me, my installer puts the VS 2017 runtime in, but that is binary compatible with VS 2015. I had no end of trouble with the VS 2015 runtime failing to install because I already had the 2017 installed, and it considers that a more up-to-date version of the same thing. In the end it was easier to install the 2017 runtime.

I get faster compiles by making new solution configs called ‘debug nococos’ and ‘release nococos’ which are identical to the normal debug and release but have the cocos2d project unticked in the build box. This means I can build the ‘normal’ debug and release once (which builds the cocos libs), then switch to the ‘nococos’ versions forever more, and it still links and works fine but never attempts to rebuild cocos. I haven’t tried gen-libs because this approach took 5 minutes and seems to work fine.

I haven’t tried to upgrade my cocos version yet, but I think I’d tackle it in a similar way - compare two simple projects generated with the old and new versions to find the differences.


#12

My goodness, that’s so brilliant! I’m going to see if I can do that in VS 2015. I develop mainly in Xcode, then switch to my PC only for building my project for Steam and doing anything that’s Windows-specific, so I’m very much a novice in VS. I’m going to copy my project to a new folder and see if I can find how to do what you’re saying. It makes a lot of sense! (Edit: yep, I think I’ve found how to do it, will check back in later this afternoon - thanks!)

[Hey, quick question - when I go to create a new Solution configuration, such as “debug nococos” I’m copying the debug one; do you recommend checking the “create new project configurations” checkbox?]

So, say you wanted to do a clean build. Can you do that with your setup, without rebuilding all the cocos files? Or just don’t worry about it, since clean builds aren’t that common?

Thanks again!


#13

Ah, you don’t need any copies of projects etc. you can just do it by adding new configurations in Configuration Manager. It uses the same projects.

Under ‘Active Solution Configurations’ there’s a ‘new’ option that lets you clone an existing configuration, so you make a ‘DebugNococos’ and copy settings from ‘Debug’.
Untick the ‘Create new project configurations’ box, because that clones all the project configurations too, and you don’t want that. You want literally exactly the same projects.
When you OK this it takes you back to the Configuration Manager where you will see debug versions of all your projects, each with a tick next to it in the ‘build’ column.
All you have to do is untick the one in the libcocos2d (and any other third-party libraries you never change) and that’s it. It’ll never build, clean or rebuild those projects while you’re in the DebugCocos solution configuration.

Not cleaning/rebuilding is one of the big advantages. Thinking back, that’s one of the main reasons I did it in the first place. I often want my code cleaned/rebuilt but rarely do I want the same done to cocos.


#14

Thanks much CdrJameson! I’ve just done this on my Windows build, and all is now smooth and running great in VS 2015 and cocos2d-x 3.16! I really had to modify only a few files (in addition to creating the new solution configurations as you suggested). Now I’m going to repeat the work on my Mac.

I’m not sure what all will come along by updating from 3.10 to 3.16, but it was time. I’m hoping it’ll make it possible for me to create a Mac version and also maybe help out with improving my iPhoneX support. Maybe add crowd sounds, who knows.

But mainly, I just want to thank you again for your great suggestion! Thanks!


#15

We use a Zip file for our Win32 distributions.

I’m now moving to statically link the C++RT so we can stop installing it.