How to install an application using large libraries?

Windows specific questions.
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

How to install an application using large libraries?

Post by TJF »

To distribute an FB application we can make an installer (e.g. using NSIS). If our application uses a library, we (can use the static version or) we can pack the shared DLL into the installer and copy it into the path where our EXE is placed.

This is a common way to install specific libraries. It works fine for libraries, only used by our application.

If our application uses a more general library (or package e.g. like GTK), it is not wise to ship this library with our application:
  • This general library may be installed allready on the users system.
    If we offer similar applications, the user has to host the same library several times on his system.
    We have to pack big installers, including all the libraries needed.
    It is a lot of effort to make sure that all DLLs are in matching versions.
    ...
The solution may be generating a small (NSIS) installer that includes only our app and does:
  • 1) check if a certain library is existing
    2) check the version of the library
    3) inform the user to
    • A) need to download and install the library before continuing (local or system wide)
      B) need to download and install a newer library version before continuing
      C) be ready to install our app
    4) install our app
Does anybody have created such an installer (using free software like NSIS)?
Or has anybody some experience creating one?
AMIBCT
Posts: 53
Joined: Jan 14, 2008 8:48
Location: Tehran
Contact:

Post by AMIBCT »

I have not written sth like this
But I can write one!

You can find many pre-written NSIS projects and code snippets over the net.
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Post by TJF »

AMIBCT wrote:You can find many pre-written NSIS projects and code snippets over the net.
Sure! E.g. you'll find Unfortunately I'm not keen on windows installation things (I'm a LINUX user). I loose a lot of time while testing all the registry stuff for different windows versions (which I haven't installed). But I like to distribute good cross platform applications with GUI for windows as well.
AMIBCT wrote:But I can write one!
If you'll do so and post the NSIS-script, you'll help me (and hopefully other users) a lot.
dkl
Site Admin
Posts: 3235
Joined: Jul 28, 2005 14:45
Location: Germany

Post by dkl »

I'd just include the needed DLLs, that's the easiest solution, and it will always work. No DLL version problems, no problems if they decide to uninstall the GTK runtime, no need to download anything, no need for a web connection, no need to be admin to make a system-wide update, no breaking other apps, ...

If you need some help to get going, check out FB's NSIS script (it's not doing any DLL checks though):
http://fbc.svn.sourceforge.net/viewvc/f ... mplate.nsi
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Post by TJF »

dkl wrote:I'd just include the needed DLLs, that's the easiest solution, and it will always work. No DLL version problems, no problems if they decide to uninstall the GTK runtime, no need to download anything, no need for a web connection, no need to be admin to make a system-wide update, no breaking other apps, ...
Thanks for your statement. No problems at all - for me as the programmer. What about the users?

I (and some others) have in mind to distribute small cross platform GUI tools for FreeBasic like a frontend for h_2_bi.bas or GTK+tobac2 with about 100 kB .exe files. If we ship GTK each time, we'll distribute 30 MB library for each 100 kB tool. Have a look at http://www.freebasic.net/forum/viewtopi ... ht=#145333 and you'll get an idea of what I mean.
AMIBCT
Posts: 53
Joined: Jan 14, 2008 8:48
Location: Tehran
Contact:

Post by AMIBCT »

Hi again!

OK, I'll prepare the required script for you.

But unfortunately I'm unfamiliar with GTK and don't know how it works and where it saves its installation data.

Give me more info so that I'll be able to write the script.
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Post by TJF »

AMIBCT wrote:... OK, I'll prepare the required script for you.
...
Give me more info so that I'll be able to write the script.
Here you are:

The link where to download the GTK installer:
To run the installer, I found for private installation:
Section "GTK+ (for this program only)" SecGtkPrivate
SectionIn 1
SetShellVarContext all ; use all user variables as opposed to current user
AddSize 12200 ; ~ size of unpacked gtk
; TODO: download GTK installer into "$INSTDIR"
; TODO: in the future, when we have translations for this program,
; make the GTK+ translations installation dependent on their installation status.
ExecWait '"${GTK_INSTALLER_EXE}" /sideeffects=no /dllpath=root /translations=no /compatdlls=no /S /D=$INSTDIR'
Delete "$INSTDIR\${GTK_INSTALLER_EXE}"
SectionEnd
and for system wide installation (should be default):
Section /o "GTK+ (shared installation)" SecGtkPublic
SectionIn 1
SetShellVarContext all ; use all user variables as opposed to current user
AddSize 12200 ; ~ size of unpacked gtk
; TODO: download GTK installer into "$INSTDIR"
ExecWait '"${GTK_INSTALLER_EXE}"'
Delete "$INSTDIR\${GTK_INSTALLER_EXE}"
SectionEnd
More details on (un)instalation can be found at http://gtk-win.sourceforge.net/home/ind ... /Embedding.

To check if GTK is installed (system wide) and which version it is, you may use (as mentioned above):
GetDllVersion "libgtk-win32-2.0-0.dll" $R0 $R1
IntOp $R2 $R0 / 0x00010000
IntOp $R3 $R0 & 0x0000FFFF
IntOp $R4 $R1 / 0x00010000
IntOp $R5 $R1 & 0x0000FFFF
StrCpy $0 "$R2.$R3.$R4.$R5"
If the existing GTK version is newer than or equal to the GTK installer version (2.16.6.0) no download should be done.

Do not hesitate to ask for further information if needed.
AMIBCT
Posts: 53
Joined: Jan 14, 2008 8:48
Location: Tehran
Contact:

Post by AMIBCT »

The only problem here is how to find and download the latest version of GTK+

The link you have written here is the INDIRECT link of current version
Maybe new version gets released
and the bad thing: the current link gets deleted
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Post by TJF »

AMIBCT wrote:... Maybe new version gets released
and the bad thing: the current link gets deleted
It's a SVN repository. You'll find versions of the age of five years and more. The link will not get deleted during the life time of our installer. And, the gtk-installer doesn't care about every new version (current GTK is 2.20, experimental version is 2.90 - the newest win-installer is 2.16).
AMIBCT wrote:The only problem here is how to find and download the latest version of GTK+ ...
If this is the only problem for you, it sounds promissing!

From my point of view it's not neccessary to find and download the latest version. If the user is going to be up to date he will care about his GTK installation himself and install the desired version. In this case we'll find a new version on the system and we'll have to do nothing.

Our installer should help users who want to make a test of our tools and who do not want to care about GTK installation. In this case an old but working installation is sufficient. (We may update the download link from time to time, let's say every two years or so.)

From my point of view it's just important to support uninstallation as well.
Galeon
Posts: 563
Joined: Apr 08, 2009 5:30
Location: Philippines
Contact:

Post by Galeon »

That type of installer is planned for my FbEdit addin Project Publisher. Actually I'm planning to work with it in this weekend. I'll try to help.
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Post by TJF »

Galeon wrote:... I'll try to help.
You're wellcome! Can you post code to share with AMIBCT?
AMIBCT
Posts: 53
Joined: Jan 14, 2008 8:48
Location: Tehran
Contact:

Post by AMIBCT »

Fine

I'll start coding the installer as soon as possible.

I've to attend university classes for two days.
after that I'll try to do the job.
AMIBCT
Posts: 53
Joined: Jan 14, 2008 8:48
Location: Tehran
Contact:

Post by AMIBCT »

Hi

I've completed the installer script
There should be no critical errors

But it needs some modifications for sure

Most of global things are defined as global variables and you can locate and change them at first lines of script

Tell me about any modifications needed

Download Script and compiled version here - 90 KB
http://www.4shared.com/file/Ra-DZslN/In ... _AMIB.html
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Post by TJF »

AMIBCT wrote:Hi

I've completed the installer script
There should be no critical errors
Great work! Thank you for the first draft! I'll do some detailed testing tomorrow morning (I'm too tired now).
AMIBCT wrote:Tell me about any modifications needed
So far, I miss an important feature. The installer should check the installed GTK version on startup and show the result in the second (components-) window. It should:
  • * Uncheck the box 'Runtime files' if the installed GTK version on the user system is newer than our download version (and print out a message in the 'Description' field like 'GTK+ installation version x.x.x allready installed').

    * Check the boxes 'Runtime files' and 'Download and Install GTK+' if no GTK+ is found or the installed version on the user system is older than our download version (and print out a message in the 'Description' field like 'found old GTK+ installation version x.x.x, need to download and install version x.x.x' or 'found no GTK+ installation, need to download and install GTK+-x.x.x')
To check the installed GTK+ version I found:
Function .onInit
GetDllVersion "libgtk-win32-2.0-0.dll" $R0 $R1
IntOp $R2 $R0 / 0x00010000
IntOp $R3 $R0 & 0x0000FFFF
IntOp $R4 $R1 / 0x00010000
IntOp $R5 $R1 & 0x0000FFFF
StrCpy $0 "$R2.$R3.$R4.$R5"
...
FunctionEnd
I hope you can care about this improvement.

BTW: If you're working with incscape, you'll have at least one GTK+ installation on your system. Be careful not to overwrite it with an old version.
AMIBCT
Posts: 53
Joined: Jan 14, 2008 8:48
Location: Tehran
Contact:

Post by AMIBCT »

Here is the revised installer
http://www.4shared.com/file/fDz7geY7/In ... _rev1.html

There is one problem with changing description text of sections during runtime
I was unable to find an easy solution for it

Currently the GTK+ installation and version number is studied and the relevant item is selected as necessary.
but no message is being shown for the user.

Finally about the installer rewriting previous version of GTK+
There should be no problem while the GTK+ installer is called to create the files in YOUR APPLICATION DIRECTORY and create NO registry values.

Any advice on how improvements can be done, is welcome.
Post Reply