With this simple bash script, you will not need anymore to compile your OpenCV code with the aux of CMakeList & Makefile, avoiding the stress of compiling copy-pasted code everytime into your config file.
None, or just Open-CV installed. Depending on what system you run on, you should do the following steps.
You can fetch the working script install here if a Ubuntu/Debian user
If using an Arch-Like system, just follow those steps:
sudo pacman -S opencv
sudo pacman -S hdf5 vtk
sudo pacman -S glewSimple as it is, bebfore using this script is strongly suggested to create an alias to make the script executable everywhere
into your system.Instead, it is requested the presence of the OpenCV build dir into the path variables.
If you don't have the OpenCV_DIR set into your shell file, you should do something like this (example for bash shell,
assuming you have installed OpenCV and it is currently into your main folder):
foo@bar:~$ echo "export OpenCV_DIR=~/your/path/to/OpenCV/build" >> .<<yourshell>rc>example with various shells, if your OpenCV dir is into the home folder (~/OpenCV)
- ZSH
foo@bar:~$ echo "export OpenCV_DIR=~/OpenCV/build" >> .zshrc- BASH
foo@bar:~$ echo "export OpenCV_DIR=~/OpenCV/build" >> .bashrcIf you got an Arch-like enviroinment (Manjaro, Antegros or Arch) you can just install openCV from
the pre-requisites tutorial or the AUR repo.
In this case, you don't need to set the OPENCV_DIR because the library are installed
into your /usr/lib path.
Just donwload the appropriate BASH script (build_arch), rename it to build and follow the steps ahead.
Once done that, create an hidden folder to contain the OpenCV build file:
foo@bar:~$ mkdir ~/.buildOpenCVAnd copy the build file into this newly folder, i.e. from terminal:
foo@bar:~$ mv /path/to/build_arch ~/.buildOpenCVOnce done that, it's almost finished: Just add this line to your shell config file:
- Bash
foo@bar:~$ echo "alias opencv=~/.buildOpenCV/build_arch" >> .bashrc- ZSH
foo@bar:~$ echo "alias opencv=~/.buildOpenCV/build_arch" >> .zshrcAnd now you can just type
foo@bar:~$ opencv OpenCVFile.cpp To build, compile and link your OpenCV cpp file, avoiding the use of CMakeList.
obviously don't forget to run your program! The output of the script will be the name of the input file
minus the .cpp extension.
example: OpenCVTest.cpp -> OpenCVTest