Create an installation

setup program

When you start making pretty big programs, you will surely want to create a setup program .

Until now, you gave your program in a .zip file that had to be decompressed. Ok, it goes a bit, but when we want to make a serious program to distribute, we would like to be able to create a professional installation. This is the purpose of this course:)

User Image

This course will show you how I create a setup for the Mario Sokoban game made with the SDL library.
This game has been featured in part III of the C programming course on the SDL library.
Of course, what I show you there will be adaptable for any type of program, whether it is done in C, C ++, Java, Python or whatever else ^^

Download Inno Setup

In general, we do not code the installer ourselves. It would be far too long, a real waste of time.
In addition, it is quite complicated because the installer must combine all the files of the program in a single large .exe, and it must compress them too!

This makes the installation programs really suitable for distribution on the Internet. They take up as little space as possible, and all program files are packaged in the .exe of the installation:)

Installation creation tools

There are many tools to create an installation.
I’m not going to make you a list here, but still let’s say InstallShield (that name should tell you something). It is a paid installation creator very often used.

There are also many free tools. There is for example NullSoft Install System (NSIS) originally created for the Winamp software then made available free to everyone.

The tool that I am going to present here is very well known and reputed. Its name is Inno Setup . It has the following advantages:

  • Free

  • Open Source

  • Very discreet and professional: it does not display a message “Installation created with Bidule Truc”.

  • Multilingual: it manages facilities in different languages ​​at once as needed.

  • Very easy to use: there is an assistant.

  • Very customizable and powerful: you can choose many options, from the image displayed during the installation to the keys of the registry to be modified, via the shortcuts of the start menu.

In fact, what is really good is that the program does not show any message that the installation was created with Inno Setup. There is just one small comment (but you have to go get it!).
If you right-click the .exe of an installation program, then properties, the “Version” tab, you will see the following comment:

User Image

So it’s ultra-discreet (your users will probably never see it).
Besides I have a little game to propose: do the test on all the programs of installation that you have on your hard disk. Count the number of installations you have that have used Inno Setup: there are plenty!

This should reassure you, because it is a very used program that does not lack qualities :)

Download Inno Setup

Go to the official website of the software.
Click the Download link and retrieve the installer.

You are first asked for your language. Normally, the language is automatically detected based on the language used on your computer.

You then see the first window of the installation wizard:

Sympathetic is not it? :)

Well I do not make a screenshot of each of the steps of the installation, I think you are big enough to know how to click Next – Next – Next – Finish : p

At the end, you are asked if you want to run Inno Setup. Good idea that, we are precisely there for that!

Create a new installation

When you start Inno Setup, a welcome window asks if you want to create a new installation or open an existing one.

In fact, the Inno Setup installations are created from a small scripting language (very easy to use I reassure you). This wizard will generate the installation script for us
As the author is nice, he thought of beginners who want to go fast (like us : p). He therefore included a scripting wizard. . There was no: D

Check ” Create a new script file using the Script Wizard “:

User Image

Click OK.
The first wizard window opens:

User Image

Bla bla bla.
Do not tick the box, click Next, that’s all I ask you : D

The following window is already more interesting:

User Image

You must enter the name of your program, the name of your program with the version number, the name of the creator and the website of the program.
In my example, I’m about to create a setup for the Mario Sokoban game .

Next step :

User Image

You are prompted for the installation folder for the program. You can choose between putting it in Program Files or in a custom folder. We will stay classic, we will put the program in Program Files:)

I advise you to leave the check mark “Allow user to change the application directory”. This will allow the user to change the installation path if desired.
The other box “The application does not need a directory” is a bit special. It only serves for rare programs that do not need a special folder to be installed. It does not concern us here.

Then:

User Image

This window prompts you for the files to be packaged.
You are asked at the top where the executable is located (the .exe of the program). Specify where the file is located on your hard drive. In my case, it is called MarioSokoban.exe

Below, I advise you to leave the checkbox the same as me: this box allows to leave the possibility to the user to start the program automatically at the end of the installation.
The box “The application does not have a main executable file” will usually not be checked. It is only used for programs that do not have a primary .exe. It is quite rare, but it happens^^

Then, and this is very important here too, you are asked for the “Other applications files”. You must indicate in there all the files that your program needs to function. I strongly advise you not to forget any, or your program will not work: D

I do not make you the list, but in the case of the Mario Sokoban it already has quite a lot of files! Between the DLLs of the SDL and SDL_Image, the images of the game, the file levels.lvl etc … It makes the world!

  • If you want to add files that will be installed in the same folder as the executable, click Add Files

  • If you want to add an entire directory to be recreated in the executable folder, click Add Directory

In my case, I did not need to add directory, all files are in the same folder as the executable.
In the case of very large programs, you will probably need to create folders (one for images, one for sounds, one for levels …). You will then click on Add Directory.

Next window:

User Image

You are asked what shortcuts you want to create. First, you are prompted for the folder name in the Start menu. Personally, I leave the default.

The checkboxes are interesting, I translate for non-English speakers:

  • Allow user to change Start Menu folder name : Allows the user to change the folder name of the start menu.

  • Creation : Allows the user to disable the creation of shortcuts in the start menu.

  • Create an Internet Shortcut in the Start Menu folder: A link to your website will be added to the Start Menu (chic chic : D)

  • Create an uninstall icon in the Start Menu folder : add an uninstall icon in the start menu.

  • Allow user to create a desktop icon : Allows the user to create a shortcut on the desktop.

  • User Image

    Allow user to create a Quick Launch icon : Allows the user to create a shortcut in the Quick Launch bar. This is a shortcut bar located just to the right of the Start menu.
    You can see the area in question on my screenshot:

Next window (go it’s almost finished!):

User Image

You are prompted for text files to be displayed before and after installation (as well as the program license).
You can specify any .txt file (or .rtf if you want to do a bit of formatting like color, bold …).

Personally, I do not put anything here for my program, but you will surely want to display information to your users. For example, you could indicate the known bugs in your program, the improvements made by the new version etc.

The part “License File” will be useful especially if you distribute your program under free license (GNU / GPL) as it is done most often for the programs Open Source (that is to say the programs whose code can be obtained source).

User Image

Here you will be asked for the languages ​​available in the installation program. If you select more than one language, you will be asked for the desired language at the beginning of the installation.
In my case, I will check only French (na! : p).

User Image

The first field is used to indicate in which folder the installation program should be created. Personally, I chose to put it in the file of my project to have it easily at hand.

Then you are prompted for the name of the installation program. I recommend changing the default “setup” to something more clear, like here: “mario_sokoban_setup”.

The third field allows you to choose a custom (.ico) icon file for installation. I will leave the icon by default, it is very good: p

Finally, the 4th field allows to protect the installation by password. Only those who know the password will be able to install your program.

The next window is the last one: you just have to click on Finish!

Compile the installation

You can see that the executable configuration script was automatically generated by the bottom wizard.
You are asked if you want to compile the installation now. If you do not want to customize the script a bit more by hand, click Yes:

User Image

After a few seconds, the installation program was generated!

User Image

And here is a nice new installation program!

User Image

Edit configuration script

If you want to modify the configuration script, free to you. You can find documentation in the Inno Setup Help. It’s really easy to use, you’ll soon learn:)

By editing the configuration script, you can do more advanced things like displaying a custom image during the installation of the program, restarting the computer at the end of the installation, or modifying registry keys.
To compile the installation again, you will go to the Build / Compile menu (Ctrl + F9).

For information, I needed to modify a little bit the configuration script for my game Mario Sokoban. In fact, you must specify the working directory (WorkingDir) in the line that commands the creation of the shortcut in the start menu:

[Icons]

Related posts

Leave a Comment