Script for automatically using OpenCV with gcc and CMake (Patch #2664)
Description
Usage: ./script filename.cpp
Description:
The script creates the necessary CMakeLists.txt file needed for cmake configuration. Next to that, it makes a new directory called 'build' and puts there all the files produced after cmake. Then it compiles the filename.cpp and finally copies the executable file back to the original directory. So, that's an easy way for starters with OpenCV to build and run their "hello OpenCV" applications using gcc and CMake.
Script Source Code:
#!/bin/bash app=`echo $1 | awk -F "." '{ print $1 }'`; if [ -f CMakeLists.txt ] then mv CMakeLists.txt CMakeLists.txt.old echo Old CMakeLists.txt has renamed as CMakeLists.txt.old rm CMakeLists.txt fi touch CMakeLists.txt echo -e "cmake_minimum_required(VERSION 2.6)" >> CMakeLists.txt echo -e "project( $app )" >> CMakeLists.txt echo -e "find_package( OpenCV REQUIRED )" >> CMakeLists.txt echo -e "add_executable( $app $app.cpp )" >> CMakeLists.txt echo -e "target_link_libraries( $app \${OpenCV_LIBS} )" >> CMakeLists.txt echo CMakeLists.txt has been created! mkdir build cd build cmake .. make cp $app .. cd ..
GitHub Link: https://github.com/drpaneas/uzful-scripts/blob/master/cvmake.sh
PS: I found it very helpful, so I'd like to share it with you guys :)
History
Updated by Vadim Pisarevsky about 12 years ago
- Affected version set to 2.4.3
- Priority changed from Normal to Low
- Tracker changed from Bug to Patch
Updated by Ilya Lavrenov almost 10 years ago
Not necessary.
- Status changed from Open to Cancelled
- Assignee deleted (
Andrey Kamaev) - HW Platform set to x86
- Operating System set to Any
- Affected version changed from 2.4.3 to branch 'master' (3.0-dev)