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.
Related
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
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.
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.
I am trying to install libpython-dev on a Travis-CI worker without success. I am using the container-based workers. The relevant section of the .travis.yml file follows:
sudo: false
language: cpp
addons:
apt:
packages:
# Compilers
- g++
- gfortran
- cmake
# Libraries for static linking
- binutils-gold
- libc6-dev
- libpthread-stubs0-dev
# Math libraries
- libblas-dev
- liblapack-dev
- libatlas-base-dev
# MPI
- openmpi-bin
- libopenmpi-dev
# Python library, development version
- libpython-dev
I get the following error: E: Unable to locate package libpython-dev
even though the package is on the ubuntu-precise whitelist
I'm trying to use ios-cmake to generate Xcode project targeting iOS. However, it cannot find Threads. Here's a simple CMake script for demonstration:
CMAKE_MINIMUM_REQUIRED (VERSION 2.8)
PROJECT (MyCITest)
SET (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")
########################
# EDIT: I've also tried adding the lines below prior to posting this question,
# but there doesn't seem to be any effect.
# (http://stackoverflow.com/questions/8386897)
SET (CMAKE_REQUIRED_INCLUDES ${CMAKE_IOS_SDK_ROOT}/usr ${CMAKE_IOS_SDK_ROOT}/usr/include)
SET (CMAKE_CXX_FLAGS "--sysroot=${CMAKE_IOS_SDK_ROOT} ${CMAKE_CXX_FLAGS}")
SET (CMAKE_C_FLAGS "--sysroot=${CMAKE_IOS_SDK_ROOT} ${CMAKE_C_FLAGS}")
########################
FIND_PACKAGE (ZLIB REQUIRED)
FIND_PACKAGE (LibXml2 REQUIRED)
FIND_PACKAGE (Threads REQUIRED)
Running CMake from the terminal:
cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/iOS.cmake -GXcode
This is the output I got:
-- Toolchain using default iOS SDK: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk
-- Found ZLIB: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/usr/lib/libz.dylib (found version "1.2.5")
-- Found LibXml2: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/usr/lib/libxml2.dylib (found version "2.7.8")
-- Looking for include file pthread.h
-- Looking for include file pthread.h - not found
CMake Error at cmake/modules/FindPackageHandleStandardArgs.cmake:97 (MESSAGE):
Could NOT find Threads (missing: Threads_FOUND)
Call Stack (most recent call first):
cmake/modules/FindPackageHandleStandardArgs.cmake:288 (_FPHSA_FAILURE_MESSAGE)
cmake/modules/FindThreads.cmake:166 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
CMakeLists.txt:8 (FIND_PACKAGE)
-- Configuring incomplete, errors occurred!
I've already triple-checked that pthread.h is located in /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/usr/include, and besides, it located ZLib and LibXML2 without a problem, so I'm not sure what I'm doing wrong.
> cmake --version
cmake version 2.8.10.2
None of these solutions seem to work. I found the only thing that consistently worked for me was to set the variables that FindThreads.cmake sets. In other words, define the following in your toolchain file:
set(CMAKE_THREAD_LIBS_INIT "-lpthread")
set(CMAKE_HAVE_THREADS_LIBRARY 1)
set(CMAKE_USE_WIN32_THREADS_INIT 0)
set(CMAKE_USE_PTHREADS_INIT 1)
The problem is indeed due to the call to try_compile failing in FindThreads.cmake. But for me setting CMAKE_CXX_COMPILER_WORKS was not enough. Instead, I changed the type of test performed by try_compile from trying to build an executable to trying to build a static library, by putting this in the toolchain file:
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
[Sept 2019] Fix for XCode 11 & iOS 13
As explained here.
Need to use XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED instead of CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED below to make this work:
set(CMAKE_TRY_COMPILE_PLATFORM_VARIABLES "XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED")
set(XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO")
find_package(Threads REQUIRED)
unset(CMAKE_TRY_COMPILE_PLATFORM_VARIABLES)
unset(XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED)
[Aug 2019]: Info from CMake's issue tracker
The issue was discussed here and explained by #alcroito. It does not use the custom ios-cmake toolchain but the new native iOS toolchain (CMake 3.14+) but the issue is the same.
Source of the issue
When using the Xcode generator, it will try to sign applications by default. When looking for Threads, CMake calls FindThreads.cmake which will call a TRY_COMPILE test that Xcode will try to sign and fail at.
Proper solution:
Disable signing for the try_compile within FindThreads (seen here):
set(CMAKE_TRY_COMPILE_PLATFORM_VARIABLES "CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED")
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO")
find_package(Threads REQUIRED)
unset(CMAKE_TRY_COMPILE_PLATFORM_VARIABLES)
unset(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED)
Other solutions in this thread
Make the binary of that try_compile static, which won't be signed (seen here). That's not great since it should be an executable and not a static lib.
Pass proper information to be able to sign the try_compile executable (seen here). That actually would not work for me.
Skip try_compile (seen here): not quite safe since you'll skip all your compiler tests. That would not work for me either.
Hardcode Threads by overriding what FindThreads does (seen here): quite a dirty workaround.
It turns out that the iOS toolchain currently doesn't support TRY_COMPILE, which is used by CheckIncludeFiles.cmake, which is in turn used by FindThreads.cmake. The toolchain is currently set to skip TRY_COMPILE by using:
set (CMAKE_CXX_COMPILER_WORKS TRUE)
set (CMAKE_C_COMPILER_WORKS TRUE)
Reference: http://code.google.com/p/ios-cmake/issues/detail?id=1&can=1
You can fix try_compile command using next variables in toolchain:
# toolchain.cmake
set(CMAKE_MACOSX_BUNDLE YES)
set(CMAKE_OSX_SYSROOT "iphoneos")
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer")
set(MACOSX_BUNDLE_GUI_IDENTIFIER "com.example")
And minimalistic example:
# CMakeLists.txt
cmake_minimum_required(VERSION 2.8)
project(Foo)
find_package(Threads REQUIRED)
add_executable(foo foo.cpp)
Generate output:
> cmake -H. -B_builds -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake -GXcode
...
-- Looking for include file pthread.h
-- Looking for include file pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - found
-- Found Threads: TRUE
...
Complete solution
Just to mention, I also encountered the same problem in my project. I commented out the find_package(Threads REQUIRED) line and generate the Xcode proejct. The codes compiled without errors. Maybe Xcode could automatically link with posix thread library.
The solution for me was a combination of the 2 answers before me.
Comment out the 2 lines that disable try_compile
# Skip the platform compiler checks for cross compiling
set (CMAKE_CXX_COMPILER_WORKS TRUE)
set (CMAKE_C_COMPILER_WORKS TRUE)
Then add this to the top of the IOS.cmake toolchain file.
set(MACOSX_BUNDLE_GUI_IDENTIFIER com.example)
set(CMAKE_MACOSX_BUNDLE YES)
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer")