Switch between OpenCV versions at light speed.
This script allows to take snapshots of OpenCV installations and switch between them quickly. Once and OpenCV version is installed, you can take a snapshot of it with
cvswitch save. This will store all the necessary headers, libraries and pkg-config files for the current version in a private directory for later recovery. The files will be associated to the version number. Then, you can make any previously saved version your current one with
Target system and tests
Target system: Ubuntu (tested on Ubuntu 12.04 LTS)
Tested with the following versions of OpenCV:
Precautions and Disclaimer
Remember that you use CVswitch at your own risk. It is a good idea to keep your OpenCV builds until you are sure that CVswitch is saving/restoring them correctly, since this project is in early beta stage. For the full disclaimer, see the LICENSE file.
- OpenCV 188.8.131.52 is installed in your system and you code program A with it
- You store the current version with
- You upgrade OpenCV to version 184.108.40.206 and code program B using new stuff
- You fix some things in A and want to verify that it still builds with OpenCV 220.127.116.11, so you run
cvswitch 18.104.22.168to downgrade and test. Before doing the switch, version 22.214.171.124 is automatically saved.
- You install OpenCV 3.0.0-alpha to test some new features in program C
- Now, B does not build with the new OpenCV version, so you switch back to 126.96.36.199 with
cvswitch 188.8.131.52to continue working on B. Before doing the switch, the script automatically saves version 3.0.0-alpha.
- Then, you
cvswitch 3.0.0-alphaback to keep testing experimental features
- You rebuild version 184.108.40.206 with different configuration to try to improve performance and install it again, but the new config breaks something.
cvswitch 220.127.116.11brings the working 18.104.22.168 back to life.
Show the current OpenCV version
Save the current OpenCV version
Show the list of saved versions
Switch to a saved version
If the current version was not already saved, it does so beforehand. You may use shortcuts for saved_version, i.e. you can type 2.4 instead of 22.214.171.124 if there is no other 2.4 variant, or just type 2 if there is a single version 2 variant. If cvswitch is confused by what you typed, it will let you know about the alternatives.
Just copy the script to somewhere in your path, so you can invoke it from anywhere.
cvswitch needs root access for certain actions. If you are not in a root account, you do not have to worry about sudoing, since the script does it automatically for you. Just call the script and type your password when required. However, if, for any reason, you prefer to sudo yourself when calling cvswitch, you should do it with
sudo -E to make sudo copy your environment, because cvswitch uses variable PKG_CONFIG_PATH to determine paths of the OpenCV installation. For minimal typing, you might find more convenient to configure sudo to automatically copy variable PKG_CONFIG_PATH to the root's environment without using -E. cvswitch will warn you and let you know how to do this, if PKG_CONFIG_PATH is not found.