cmake does not detect ant - opencv

when configuring cmake for opencv, cmake does not detected ant. Ant installed with apt. Here is the conclusion cmake:
Detected processor: x86_64
Could NOT find PythonInterp (missing: PYTHON_EXECUTABLE) (Required is at least version "2.7")
...
Java:
ant: NO
JNI: /usr/lib/jvm/default-java/include /usr/lib/jvm/default-java/include/linux /usr/lib/jvm/default-java/include
Java wrappers: NO
Java tests: NO
Install to: /home/dym/IdeaProjects/opencvJava
-----------------------------------------------------------------
Configuring done
followed this guide.
the file .bashrc says:
export ANT_HOME=/usr/share/ant
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
export ANT_EXECUTABLE=/usr/share/ant/bin

I had the same problem and I solved it!
In Cmake-gui, add entry "ANT_EXECUTABLE:FILEPATH=/usr/share/ant/bin/ant"
My result:
Java: export all functions
ant: /usr/share/ant/bin/ant (ver 1.10.7)
JNI: /usr/lib/jvm/java-8-openjdk-amd64/include /usr/lib/jvm/java-8-openjdk-amd64/include/linux /usr/lib/jvm/java-8-openjdk-amd64/include
Java wrappers: YES
Java tests: NO

Related

How to include Eigen in C++ library after installing libeigen3-dev package

I am trying to build OpenCV from Source (master branch) using cmake.
I installed Eigen package via apt-get.
sudo apt-get install libeigen3-dev
It was successfully installed, and cmake prints that eigen 3.3.4 is installed.
Eigen: YES(ver 3.3.4)
But when I did 'make', it showed the error
/opencv/modules/core/include/opencv2/core/private.hpp:66.12: fatal error: Eigen/Core: No such file or directory
# include <Eigen/Core>
^~~~~~~~~~~~
compilation teminated.
I found the same question on superuser.
So as the answer did, I have changed cmake/OpenCVFindLibsPerf.cmake from line 44 to 59.
After I have commented out line 46-48 and 59,
and changed find_package(Eigen3 QUIET) in line 44 to find_package(Eigen3 3.0.0), it works.
And this problem only happens on OpenCV 4.0 version.
When I install OpenCV 3.4.6 version(tag 3.4.6 on github), this problem does not occur.

Cmake unknown compiler identification with opencv Windows 7 codeblocks

I am fighting with a problem while installing opencv for Code Blocks.
I have installed MinGW with all necessary compilers and I'm trying to build binaries using CMake. I am setting code blocks MinGW makefiles as generator, and I am specyfing c and c++ compilers as x86_64-w64-mingw32-g++ and gcc. Yet I'm getting an error:
CMake Error: Error SetGlobalGenerator called with null
The CXX compiler identification is unknown
The C compiler identification is unknown
Check for working CXX compiler: C:/mingw-w64/mingw64/bin/x86_64-w64-mingw32-g++.exe
Check for working CXX compiler: C:/mingw-w64/mingw64/bin/x86_64-w64-mingw32-g++.exe -- broken
CMake Error at C:/Program Files/CMake/share/cmake-3.7/Modules/CMakeTestCXXCompiler.cmake:44 (message):
The C++ compiler "C:/mingw-w64/mingw64/bin/x86_64-w64-mingw32-g++.exe" is
not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/openCV/new_build/CMakeFiles/CMakeTmp
Run Build Command:"C:/Program Files (x86)/MSBuild/14.0/bin/MSBuild.exe"
"cmTC_2867a.vcxproj" "/p:Configuration=Debug" "/p:VisualStudioVersion=14.0"
Microsoft (R) Build Engine version 14.0.25420.1
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 2016-10-12 14:20:38.
Project "C:\openCV\new_build\CMakeFiles\CMakeTmp\cmTC_2867a.vcxproj" on
node 1 (default targets).
PrepareForBuild:
Creating directory "cmTC_2867a.dir\Debug\".
Creating directory "C:\openCV\new_build\CMakeFiles\CMakeTmp\Debug\".
Creating directory "cmTC_2867a.dir\Debug\cmTC_2867a.tlog\".
InitializeBuildStatus:
Creating "cmTC_2867a.dir\Debug\cmTC_2867a.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
ClCompile:
CL.exe /c /W1 /WX- /O2 /Oy- /D "CMAKE_INTDIR=\"Debug\"" /D _MBCS /Gm- /MD /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"cmTC_2867a.dir\Debug\\" /Fd"cmTC_2867a.dir\Debug\vc140.pdb" /Gd /TP /analyze- /errorReport:queue C:\openCV\new_build\CMakeFiles\CMakeTmp\testCXXCompiler.cxx
TRACKER : error TRK0005: Failed to locate: "CL.exe". Nie mo�na odnale��
okre�lonego pliku.
[C:\openCV\new_build\CMakeFiles\CMakeTmp\cmTC_2867a.vcxproj]
Done Building Project
"C:\openCV\new_build\CMakeFiles\CMakeTmp\cmTC_2867a.vcxproj" (default
targets) -- FAILED.
Build FAILED.
"C:\openCV\new_build\CMakeFiles\CMakeTmp\cmTC_2867a.vcxproj" (default
target) (1) ->
(ClCompile target) ->
TRACKER : error TRK0005: Failed to locate: "CL.exe". Nie mo�na odnale�� okre�lonego pliku. [C:\openCV\new_build\CMakeFiles\CMakeTmp\cmTC_2867a.vcxproj]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:01.11
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:93 (project)
Configuring incomplete, errors occurred!
See also "C:/openCV/new_build/CMakeFiles/CMakeOutput.log".
See also "C:/openCV/new_build/CMakeFiles/CMakeError.log".
I have path for MinGW bin folder created, yet there's a problem with compiler. I installed windows JDK8.1 (previously in error window it was said that I need to install it).

caffe installation stuck at "Linking CXX shared library ../../lib/libcaffe.so"

I encountered a problem when trying to build caffe with cmake (trying cmake since make constantly gives me errors but it turns out cmake is nothing better...). Below is the error message:
[ 82%] Linking CXX shared library ../../lib/libcaffe.so
/usr/bin/ld: cannot find -lopencv_dep_cudart
collect2: error: ld returned 1 exit status
src/caffe/CMakeFiles/caffe.dir/build.make:3284: recipe for target 'lib/libcaffe.so.1.0.0-rc3' failed
make[2]: *** [lib/libcaffe.so.1.0.0-rc3] Error 1
CMakeFiles/Makefile2:272: recipe for target 'src/caffe/CMakeFiles/caffe.dir/all' failed
make[1]: *** [src/caffe/CMakeFiles/caffe.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2
I tried to search online but did not find much information related to the missing -lopencv_dep_cudart.
I am running Ubuntu 16.04. Both gcc and gcc++ versions are 4.9. Opencv is installed and its version is 2.4.13. Below is part of the output from cmake .. that shows the dependencies for caffe (I think I have all dependencies installed):
-- Dependencies:
-- BLAS : Yes (Atlas)
-- Boost : Yes (ver. 1.58)
-- glog : Yes
-- gflags : Yes
-- protobuf : Yes (ver. 3.0.2)
-- lmdb : Yes (ver. 0.9.17)
-- LevelDB : Yes (ver. 1.18)
-- Snappy : Yes (ver. 1.1.3)
-- OpenCV : Yes (ver. 2.4.13)
-- CUDA : Yes (ver. 8.0)
--
-- NVIDIA CUDA:
-- Target GPU(s) : Auto
-- GPU arch(s) : sm_61
-- cuDNN : Yes (ver. 5.1.5)
--
-- Python:
-- Interpreter : /usr/bin/python2.7 (ver. 2.7.12)
-- Libraries : /usr/lib/x86_64-linux-gnu/libpython2.7.so (ver 2.7.12)
-- NumPy : /home/jack/.local/lib/python2.7/site-packages/numpy/core/include (ver 1.11.1)
--
Could someone advise? Please let me know if more information is needed. Thanks so much in advance!
I had similar issue. The solutions found in online forums (like using set(CUDA_USE_STATIC_CUDA_RUNTIME OFF) in CMakeLists.txt) did not fix my problem. But you can hack your cmake files to get past this error.
Steps
Enable the verbose in cmake using set(CMAKE_VERBOSE_MAKEFILE ON)
do a make | grep lopencv_dep_cudart
The command that performs the linking will have the string highlighted. Note down the path of the cmake file that has the search string.
Copy the command and run it in a shell in the above path but without the -lopencv_dep_cudart option. Hopefully the command will execute without error
Now run the make again.
I encountered a same problem. I find the flag -lopencv_dep_cudart in the file OpenCVModules-release.cmake which is used by Find_package(OpenCV):
OpenCVModules-release.cmake
I solved this problem by using FindPkgConfig Module of cmake to find OpenCV libs:
# firstly, add your/path/to/opencv.pc to system environment variable PKG_CONFIG_PATH
# modify the file Dependencies.cmake
find_package(PkgConfig REQUIRED)
pkg_check_modules(OpenCV REQUIRED opencv)
include_directories(SYSTEM ${OpenCV_INCLUDE_DIRS})
list(APPEND Caffe_LINKER_LIBS opencv_core opencv_highgui opencv_imgproc)
Alternatively, you can also directly set OpenCV_INCLUDE_DIRS and OpenCV_LIBS to your OpenCV path.

OpenCV won't build with CUDA even though WITH_CUDA=ON in CMake

I have tried to build OpenCV 3.1 using CMake (the gui version) to enable Cuda. I have installed Cuda version 7.5 64-bit and CMake automatically found the correct path to the Cuda toolkit. I made sure that the WITH_CUDA value was set to ON, and pressed configure. This is what I got concerning Cuda:
CUDA detected: 7.5
CUDA NVCC target flags: -gencode;arch=compute_20,code=sm_20;-gencode;arch=compute_20,code=sm_21;-gencode;arch=compute_30,code=sm_30;-gencode;arch=compute_35,code=sm_35;-gencode;arch=compute_30,code=compute_30
...
Extra dependencies: comctl32 gdi32 ole32 setupapi ws2_32 vfw32 cudart nppc nppi npps cufft -LC:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v7.5/lib/x64
...
Other third-party libraries:
Use IPP: 9.0.1 [9.0.1]
at: C:/OpenCV-3.1.0/opencv/sources/3rdparty/ippicv/unpack/ippicv_win
Use IPP Async: NO
Use Eigen: NO
Use Cuda: YES (ver 7.5)
Use OpenCL: YES
Use custom HAL: NO
NVIDIA CUDA
Use CUFFT: YES
Use CUBLAS: NO
USE NVCUVID: NO
NVIDIA GPU arch: 20 21 30 35
NVIDIA PTX archs: 30
Use fast math: YES
Then I generate using Visual Studio 12 2013 Win64.
Next I open the newly generated OpenCV.sln project in Visual Studio 2013 and build the project. It completes without any errors, but 103 warnings like this:
LINK : warning LNK4044: unrecognized option '/LC:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v7.5/lib/x64'; ignored
OpenCV builds just fine and I can build programs with it. I can also include "opencv2/core/cuda.hpp" without any problem. However, when I try to use cuda::getDevice() i get this error:
OpenCV Error: No CUDA support (The library is compiled without CUDA support) in throw_no_cuda, file C:\builds\master_PackSlave-win64-vc12-shared\opencv\modules\core\include\opencv2/core/private.cuda.hpp, line 97
When I print the information from cv::getBuildInformation() i get:
Other third-party libraries:
Use IPP: 9.0.1 [9.0.1]
at: C:\builds\master_PackSlave-win64-vc12-shared\opencv\3rdparty/ippicv/unpack/ippicv_win
Use IPP Async: NO
Use Eigen: NO
Use Cuda: NO
Use OpenCL: YES
Use custom HAL: NO
It seems Cuda is disabled somewhere in the process, but I can't figure out why. I have tried to reconfigure and rebuild several times with the same results. Would love some help on this!
The problem is CMake: it generates wrong link options for Visual Studio.
LINK : warning LNK4044: unrecognized option '/LC:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v7.5/lib/x64'; ignored
It should be "LIBPATH:C:" instead of "LC:".
To fix the problem:
Generate the solution with CMake
Go to the build directory
Open an IDE/Text editor which is able to do a global search in this directory
For each occurrence of "-LC:" in any file, replace it by "-LIBPATH:C:".
========= EDIT =========
I found the problem, it is in CMakeLists.txt :
foreach(p ${CUDA_LIBS_PATH})
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} -L${p})
endforeach()
Instead of using "${CMAKE_LIBRARY_PATH_FLAG}" which automatically put -LIBPATH, someone put "-L"...
So to fix it:
Open CMakeLists.txt
Replace "-L" by "${CMAKE_LIBRARY_PATH_FLAG}"
Configure & Generate the solution with CMake and compile with VS.
Hope it will help!
You can successfully compile OpenCV with Cuda after manually editing CMakeLists.txt as Dubrzr say.
Also You will have the same result if you download and compile OpenCV straight from github. It is already fixed.

Travis-ci can't find boost/geometry.hpp

In .travis.yml I have:
dist: precise
addons:
apt:
sources:
# For gcc >= 4.8
- ubuntu-toolchain-r-test
# For cmake >= 2.8.8 (for CMakePackageConfigHelpers)
- kubuntu-backports
- boost-latest
packages:
- g++-4.8
- cmake
- libboost-thread-dev
- libboost-graph-dev
- libcgal-dev
- postgresql-server-dev-all
- postgresql-common
In CmakeLists.txt
find_package(Boost)
if(Boost_INCLUDE_DIRS)
message(STATUS "Boost headers were found here: ${Boost_INCLUDE_DIRS}")
find_file(MYVAR geometry.hpp)
message(STATUS "geometry.hpp found here: ${MYVAR}")
endif(Boost_INCLUDE_DIRS)
When I run the cmake in my computer I get:
-- Boost version: 1.54.0
-- Boost headers were found here: /usr/include
-- geometry.hpp found here: /usr/include/boost/geometry.hpp
But when working in github's travis it can not find geometry.hpp:
-- Boost version: 1.46.1
-- Boost headers were found here: /usr/include
-- geometry.hpp found here: MYVAR-NOTFOUND
-- Boost version: 1.46.1
-- Found the following Boost libraries:
-- thread
Something I am missing in the addons section that its not finding the header only library geometry?
Boost.Geometry was added to Boost in version 1.47 (in 2011 IIRC)
Therefore, using 1.46.1, it cannot be found.

Resources