I am using Sublime Text in Ubuntu and learning OpenCV. Until today, I was using Sublime Text to write and save the code, and using Terminal for compiling.
I am compiling with the following code:
cmake .
make
./a.out
But for fast processing, I am trying to make my build system and I want to make this all automatically by pressing Ctrl + B
I've tried the following code in a custom build system but it fails:
{
"cmd": ["cmake ."],
"cmd": ["make"],
"cmd": ["./a.o"],
"selector": "source.c++",
"shell": true,
"windows":
{
"cmd": ["cl", "/Fo${file_path}", "/O2", "$file"],
"selector": "source.c++",
"shell": true
}
}
Any ideas? Thanks.
You should only have one "cmd"
key in your build system. Please read the docs for more information. Instead, you can concatenate your commands using the &&
operator:
{
"cmd": ["cmake .", "&&", "make", "&&", "./a.out"],
"selector": "source.c++",
"shell": true,
}
Since you're on Linux, you don't need the Windows stuff at all.
You can use cmake to create a sublime project. Just execute
cmake -G "Sublime Text 2 - Unix Makefiles" .
I don't know if it works for subime text 3 since I don't have it installed
Thanks to MattDMo , I have built a build system that works properly, here it is:
{
"cmd": ["cp /home/as/Documents/c++/opencv/CMakeLists.txt ${file_path} && cmake . && make && ./project"], "working_dir": "${file_path}",
"selector": "source.c++",
"shell": true
}
It copies the CMakeLists.txt (Which is a default CMakeList.txt I have prepared to be suitable with every project) to the current project directory and runs the project.
Additionally, CMakeLists.txt includes the following text:
cmake_minimum_required(VERSION 2.8)
project( project )
find_package( OpenCV REQUIRED )
add_executable( project main.cpp )
target_link_libraries( project ${OpenCV_LIBS} )
I hope that will run all of OpenCV projects!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.