lundi 4 février 2013

Deal with different libraries versions on Windows

Pour une version française de l'article, cliquez sur ce lien : http://antoine-agthe.blogspot.com/2013/02/gerer-les-differentes-versions-de-ses.html

As many developers I have to deal with a lot of projects at the same time, each of them using quite different libraries.
Most developers work on multiplatform projects using haXe/NME, Actionscript Flash/AIR, Cocos2D, Starling Framework, Apache Ant … That means a lot of SDK/framework/library folders.

In parallel, I have to test some new library versions on existing projects, or experiment them on small prototypes, so I have to keep every single version of each library in order not to break any WIP projects.

Linux developers usually take benefits of a common way to manage libraries and versions.
Programs usually share their libraries in common folders called lib, lib32 and lib64.
But all the programs don't use the same version of their libraries.
In order to manage different versions, it is possible to use a simple command-line tool called ln that creates a symbolic reference of a folder, or a file.

A symbolic reference is like a shortcut on Windows, but more powerful.

In order to understand the difference between a symbolic reference and a simple shortcut, just follow these steps on your Windows OS.


  • Create a new folder called my_real_folder
  • Right click on it and create a shortcut that you'll rename my_shortcut
  • Then double click to my_shortcut.
  • Check the address bar. You're in my_real_folder.
Windows automatically open the folder specified in the shortcut. If you take a look on these folder and shortcut with cmd, you'll see that your shortcut is a LNK file.
If you try to open my_shortcut as a folder, an error will occur ("invalid folder name", or something like that)

THAT is the big difference between shortcuts and symbolic references.

Symbolic references are managed by the file system. It is not a simple link file produced by the operating system. A symbolic reference behaves AS the file or folder it's linked with.

How to create symbolic references on Windows ?
You have to use the cmd shell in administrator mode, and call the mklink command-line program.

mklink allows you to create a file-system-level reference on a file or a folder, as ln does on Linux.
The big difference with ln, is that you have to specify the /D parameter if you want to reference a folder:

mklink /D <link> <target>

We'll go back to our example and use this command to create a reference of our my_real_folder, that we'll name my_ref_folder.
All you have to do is tip :

mklink /D my_reference_folder my_real_folder

Then use dir to list files.

You can see that the reference is not a simple file, but a completely different entity in the file system.
Then use cd to enter the reference folder.
In the prompt, you can see that the file system really enters the reference folder, instead of doing a visible redirection.

It also works on your graphical interface, where you can see two things:
  • The folder in the address bar is the reference folder
  • The reference folder is visible in the folder exploration on the left, while folder shortcut is not.


Thanks to mklink, you can create a Linux lib-like folder on Windows.

For example:
You developed some projects with Adobe Flex 3.2.0, Adobe Flex 3.4.0 and Adobe Flex 3.4.1.
You currently develop some projects with Adobe Flex 4.6.0.
At least, I want to experiment Apache Flex 4.9.0.

You can create several folder references to point major and minor versions of your librairies, as I did.

On this screenshot, you can see that:

  • flex-4.9.0 is referenced by flex-4.9
  • flex-4.9 is referenced by flex-4
  • and flex-4 is referenced by flex
Thanks to this technique, if I want to create a Flex 4 project, I can use flex-4 reference in my project configuration.
When Apache Flex 4.10 will be released, I just will recreate my references and all my projects using flex-4 reference will be updated.



If you want to use a more precise version of a tool, it is still possible if you use real folders.

This way to manage SDKs and librairies is not the only one. You can regroup libraries in a language or technology specific folder. The one I describe is the one I use, and it works great.

Aucun commentaire:

Enregistrer un commentaire