System: VM Ubuntu 14.04 x64
Summary:
I'm building OpenCV 3.0.0-dev with the contrib modules from https://github.com/Itseez/opencv_contrib but I can't get the executables from opencv_contrib.
I was trying to follow this tutorial about the tracking API: http://docs.opencv.org/trunk/modules/tracking/doc/tracking.html
Somewhere it says: To see how API works, try tracker demo: https://github.com/lenlen/opencv/blob/tracking_api/samples/cpp/tracker.cpp
But that's a forked old repository (by user lenlen), not the official repository. In the recent versions (with the new repos) it seems like that file is not in that location anymore but in:
https://github.com/Itseez/opencv_contrib/blob/master/modules/tracking/samples/tracker.cpp
The problem:
I'm being able to build OpenCV without errors, but I can't see how to build that executable file from opencv_contrib, or where is it getting located.
I've tried:
Setting up OPENCV_EXTRA_MODULES_PATH with: cmake -D OPENCV_EXTRA_MODULES_PATH=../opencv_contrib/modules ..
Setting up INSTALL_C_EXAMPLES with: cmake -D INSTALL_C_EXAMPLES=ON ..
Entering in opencv_contrib, creating and entering into a "build" directory and from there executing: "cmake .." ...but that gives errors (no CMakeLists.txt).
Entering in "opencv_contrib/modules/tracking/", creating and entering into a "build" directory and executing "cmake .." (because there's a CMakeLists.txt inside of the tracking directory). But that also gives errors.
Entering in "opencv_contrib/modules/tracking/samples/" and executing "g++ tracker.cpp", but that also gives errors.
Thanks in advance!
I solved it. It was a silly mistake.
I was setting up OPENCV_EXTRA_MODULES_PATH as: cmake -D OPENCV_EXTRA_MODULES_PATH=../opencv_contrib/modules ..
But my working directory was "opencv/build/" (I was in a directory "build" inside of opencv and the "opencv_contrib" was in the same directory as "opencv"), so that variable should have been: cmake -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules ..
Related
I cloned https://github.com/juce-framework/JUCE
I first uncommented find_package(JUCE) in /GuiApp' CMakeList.txt.
Then I ran cmake .. . -B cmake-build-dir -D JUCE_BUILD_EXAMPLES=ON
on the top level directory.
It says:
-- Checking for modules 'webkit2gtk-4.0;gtk+-x11-3.0'
-- No package 'webkit2gtk-4.0' found
-- No package 'gtk+-x11-3.0' found
-- Checking for module 'alsa'
-- No package 'alsa' found
-- Configuring juceaide
-- Building juceaide
-- Exporting juceaide
CMake Error at examples/CMake/GuiApp/CMakeLists.txt:27 (find_package):
Could not find a package configuration file provided by "JUCE" with any of
the following names:
JUCEConfig.cmake
juce-config.cmake
Add the installation prefix of "JUCE" to CMAKE_PREFIX_PATH or set
"JUCE_DIR" to a directory containing one of the above files. If "JUCE"
provides a separate development package or SDK, be sure it has been
installed.
-- Configuring incomplete, errors occurred!
I tried to find where is JUCEConfig.cmake
/work/juce/temp/JUCE/build$ find . -name JUCEConfig.cmake
./cmake-build-dir/tools/JUCEConfig.cmake
How am I supposed to put this path in CMAKE_PREFIX_PATHS?
Clone this repository: https://github.com/juce-framework/JUCE
alsa and webkit2gtk are required dependencies which were absent on Ubuntu 18.04 in my computer. You too may have to install as follows:
sudo apt install libwebkit2gtk-4.0-dev libasound2-dev
In the examples/CMake folder in this repository there is a folder called GuiApp.
To build a new GUI App project with JUCE/CMake, do this (starting from scratch):
Copy the GuiApp folder to a new location.
In the GuiApp's CMakeLists.txt that you copied, replace the
add_subdirectory(JUCE)
with
add_subdirectory("<path_to_JUCE_cloned_repository>" JUCE)
replacing the path with the real location of the JUCE repository on your system.
From the GuiApp folder that you copied, run
cmake . -B cmake-build-dir
Above command will create a build tree folder named cmake-build-dir
cmake --build cmake-build-dir
Above command will build all targets in the cmake-build-dir folder.
After successful build, you can run the executable by going in directory:
cmake-build-dir/GuiAppExample_artefacts/
and issuing ./Gui\ App\ Example. That's the name of the resultant default executable.
Credit: https://forum.juce.com/u/reuk/summary
I'm trying to install locally and compile my program, with that. I have installed OpenCV-2.4.10 with cmake configuration:
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=~/opencv/installation/ -D CUDA_GENERATION=Kepler -D CMAKE_CXX_COMPILER=/usr/bin/g++-4.9 -D CMAKE_C_COMPILER=/usr/bin/gcc-4.9 -DWITH_FFMPEG=OFF ..
in folder ~/opencv/opencv-2.4.10/build
Then I have set environment variable export OpenCV_DIR=/lhome/home/golda/opencv/opencv-2.4.10/build
And was trying to compile my programm with running cmake before. After setting OpenCV_DIR cmake has return no errors. Here's a fragment of CMakeCache.txt connected with OpenCV (With full path to my home directory. I replaced it with
'~'):
//Path where debug 3rdpaty OpenCV dependencies are located
OpenCV_3RDPARTY_LIB_DIR_DBG:PATH=
//Path where release 3rdpaty OpenCV dependencies are located
OpenCV_3RDPARTY_LIB_DIR_OPT:PATH=
OpenCV_CONFIG_PATH:FILEPATH=~/opencv/opencv-2.4.10/build
//The directory containing a CMake configuration file for OpenCV.
OpenCV_DIR:PATH=~/opencv/opencv-2.4.10/build
//Path where debug OpenCV libraries are located
OpenCV_LIB_DIR_DBG:PATH=
//Path where release OpenCV libraries are located
OpenCV_LIB_DIR_OPT:PATH=
And finally after make i got the errors like undefined reference to 'cv::imread'
I have tried adding paths:
~/opencv/opencv-2.4.10/build/lib:
~/opencv/opencv-2.4.10/include/opencv:
respectively to variables: LD_LIBRARY_PATH and INCLUDE_PATH
My question is what should I do to fix this? I'm lack of ideas now.
I am working on a c++ project and I am using cmake as the build system, so my workflow here is make changes to code. then,
rm -r build
mkdir build
cd build
cmake -G "Unix Makefiles" ..
make
Now I added glew as a dependency to the project, so whenever I try to run make I get an error saying SDL.h not found(this was working before).After sometime I decided to check CMakeCache.txt.opened it using vim then :wq that's all I did now if I run make, my project is building successfully, I am not sure why this is happening, Can anyone tell me why?
ps: added gif of this event, check it out to get a clear picture
(the code i am working on is linked as well, this exact issue is in this commit "dd4452b45c733e0612bc5f3c632e9d1a08be8072")
link to gif
link to code
variables in cmake are limited to the scope of the directory they are in plus their subdirectories.
This, calling find_module() in the gamelib subdirectory does not find that module for use in the main directory.
The preferred way to propagate include directory dependencies is to add them to the target (in the gamelib directory), like this:
target_include_directories(gamelib BEFORE PRIVATE
$<BUILD_INTERFACE:${SDL2_INCLUDE_DIR}>
$<BUILD_INTERFACE:${GLEW_INCLUDE_DIR}>
)
target_include_directories(gamelib SYSTEM BEFORE PUBLIC
$<BUILD_INTERFACE:${SDL2_INCLUDE_DIR}>
$<BUILD_INTERFACE:${GLEW_INCLUDE_DIR}>
)
then you don't need to even mention them in any executable that uses gamelib.
I am doing this Tutorial
http://docs.opencv.org/doc/tutorials/introduction/linux_install/linux_install.html#linux-installation
But I got confused. I stopped at building the OpenCV from source.
I already created an File called Workspace where I made the cmake_binary_dir (named release). I downloaded the sourcefile (which is in my home directory and named: opencv-2.3.1), and now I want to run this
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
where I use:
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/home/markus/opencv-2.3.1
But the Terminal keeps telling me, that this source directory does not exist!?
So what I am doing wrong?
CMAKE_INSTALL_PREFIX defines where to distribute the binary to after its compiled and linked, it defaults to good place (/usr/local/) so avoid defining it
You are leaving out the trailing .. in your cmake command which tells it where to get the source code hence the error message
Here are the typical steps when installing from source code any project which uses cmake
if you see a file :
CMakeLists.txt
in the src directory this indicates it wants you to use cmake
0 cd into dir where your expanded source code lives
1 mkdir build # make a build dir (initially empty)
2 cd build
3 cmake .. # NOTE those little .. which declares relative path to src dir
which says populate current dir (build) with compiled code
and get the source code and configs from parent directory (..)
4 examine the output, if it looks successful go to step 5
if it has errors you may need to install upstream dependent
libraries then try cmake again
5 make -j4 # compile source, -j speeds up by using multicore
6 sudo make install <-- only if above step 4 and 5 are OK
You can do everything cmake related from command line, yet its GUI can be quite handy especially with an unfamiliar project. In above instead of typing :
cmake ..
its GUI version is :
cmake-gui ..
in the GUI its easy to toggle on/off settings like to build examples or not ... the values column on the right is editable ... if you changed settings in the gui at bottom hit button Configure then when its done hit Generate to perform same as the normal cmake .. now return to step 4 above to do the compile
I'm using Ubuntu 12.04. I was trying to install OpenCV using the steps shown in http://karytech.blogspot.in/2012/05/opencv-24-on-ubuntu-1204.html
But when it comes to the step for Compiling, i get an error :
clive#clive-Aspire-4755:~/OpenCV-2.4.0/build$ cmake -D WITH_QT=ON -D WITH_XINE=ON -D WITH_OPENGL=ON -D WITH_TBB=ON -D BUILD_EXAMPLES=ON ..
CMake Error: The source directory "/home/clive" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.
Can anyone help me?
NOTE : The CMakeLists.txt file is present in the folder OpenCV-2.4.0 and not inside build.
Try /home/clive/OpenCV-2.4.0 instead of .. at the end of the command.
Also, It's generally easier to use ccmake instead cmake, regarding the options You are trying to set for setup.
I was facing the same issue, resolved by using the below command
Try with cmake .. your command