/OpenCV-CMake-Build-Script

Simple shell script to build .cpp files without the use of CMake && Make.

Primary LanguageShell

OpenCV Build Script

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.

Pre-requisites

None, or just Open-CV installed. Depending on what system you run on, you should do the following steps.

OpenCV Installation

-Ubuntu/Debian

You can fetch the working script install here if a Ubuntu/Debian user

-Arch-Like

If using an Arch-Like system, just follow those steps:

sudo pacman -S opencv
sudo pacman -S hdf5 vtk
sudo pacman -S glew

Setting the Enviroinment

Ubuntu-like Systems

Simple 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)

  1. ZSH
foo@bar:~$ echo "export OpenCV_DIR=~/OpenCV/build" >> .zshrc
  1. BASH
foo@bar:~$ echo "export OpenCV_DIR=~/OpenCV/build" >> .bashrc

Arch Linux-like Systems

If 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.

Installing the Script

Once done that, create an hidden folder to contain the OpenCV build file:

foo@bar:~$ mkdir ~/.buildOpenCV

And copy the build file into this newly folder, i.e. from terminal:

foo@bar:~$ mv /path/to/build_arch ~/.buildOpenCV

Once done that, it's almost finished: Just add this line to your shell config file:

  1. Bash
foo@bar:~$ echo "alias opencv=~/.buildOpenCV/build_arch" >> .bashrc
  1. ZSH
foo@bar:~$ echo "alias opencv=~/.buildOpenCV/build_arch" >> .zshrc

And 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