I'm starting to try to work on a Linux computing cluster where some programs and libraries are made available through a system of environment modules.
I would like to install Haskell programs using stack (I should probably say that I'm not yet very familiar with stack).
stack is available as a module, so after doing module load stack, I tried stack setup, which failed, complaining about gmp missing:
$ stack setup
Preparing to install GHC (gmp4) to an isolated location.
This will not interfere with any system-level installation.
Downloaded ghc-gmp4-8.0.1.
Installed GHC.
The GHC located at
/pasteur/homes/bli/.stack/programs/x86_64-linux/ghc-gmp4-8.0.1/bin/ghc
failed to compile a sanity check. Please see:
http://docs.haskellstack.org/en/stable/install_and_upgrade/
for more information. Exception was:
Running
/pasteur/homes/bli/.stack/programs/x86_64-linux/ghc-gmp4-8.0.1/bin/ghc
/tmp/stack-sanity-check24665/Main.hs -no-user-package-db in directory
/tmp/stack-sanity-check24665/ exited with ExitFailure 1
[1 of 1] Compiling Main (
/tmp/stack-sanity-check24665/Main.hs, /tmp/stack-sanity-check24665/Main.o )
Linking /tmp/stack-sanity-check24665/Main ...
/usr/bin/ld: cannot find -lgmp
collect2: ld returned 1 exit status
`gcc' failed in phase `Linker'. (Exit code: 1)
The admin of the cluster told me that gmp was also available as an environment module, so I did module load gmp before trying again, and it seemed to work:
$ stack setup
Writing implicit global project config file to:
/pasteur/homes/bli/.stack/global-project/stack.yaml
Note: You can change the snapshot via the resolver field there.
Using latest snapshot resolver: lts-8.23
Downloaded lts-8.23 build plan.
Selected mirror https://s3.amazonaws.com/hackage.fpcomplete.com/
Downloading root
Selected mirror https://s3.amazonaws.com/hackage.fpcomplete.com/
Downloading timestamp
Downloading snapshot
Downloading mirrors
Cannot update index (no local copy)
Downloading index
Updated package list downloaded
Populated index cache.
Preparing to install GHC (gmp4) to an isolated location.
This will not interfere with any system-level installation.
Downloaded ghc-gmp4-8.0.2.
Installed GHC.
stack will use a sandboxed GHC it installed
For more information on paths, see 'stack path' and 'stack exec env'
To use this GHC and packages outside of a project, consider using:
stack ghc, stack ghci, stack runghc, or stack exec
Then I tried to install hlint using stack:
$ stack install hlint
clock-0.7.2: configure
uniplate-1.6.12: download
clock-0.7.2: build
old-time-1.1.0.3: configure
Package old-time uses a custom Cabal build, but does not use a
custom-setup stanza
Not using the explicit setup deps approach based on configuration
Strongly recommend fixing the package's cabal file
old-time-1.1.0.3: build
Package old-time uses a custom Cabal build, but does not use a
custom-setup stanza
uniplate-1.6.12: configure
Not using the explicit setup deps approach based on configuration
Strongly recommend fixing the package's cabal file
uniplate-1.6.12: build
uniplate-1.6.12: copy/register
Progress: 3/7
-- While building package old-time-1.1.0.3 using:
/tmp/stack8279/old-time-1.1.0.3/.stack-work/dist/x86_64-linux-gmp4/Cabal-1.24.2.0/setup/setup
--builddir=.stack-work/dist/x86_64-linux-gmp4/Cabal-1.24.2.0 build
--ghc-options " -ddump-hi -ddump-to-file"
Process exited with code: ExitFailure 1
Logs have been written to:
/pasteur/homes/bli/.stack/global-project/.stack-work/logs/old-time-1.1.0.3.log
[1 of 2] Compiling Main (
/tmp/stack8279/old-time-1.1.0.3/Setup.hs,
/tmp/stack8279/old-time-1.1.0.3/.stack-work/dist/x86_64-linux-gmp4/Cabal-1.24.2.0/setup/Main.o
)
[2 of 2] Compiling StackSetupShim (
/pasteur/homes/bli/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs,
/tmp/stack8279/old-time-1.1.0.3/.stack-work/dist/x86_64-linux-gmp4/Cabal-1.24.2.0/setup/StackSetupShim.o
)
Linking
/tmp/stack8279/old-time-1.1.0.3/.stack-work/dist/x86_64-linux-gmp4/Cabal-1.24.2.0/setup/setup
...
Configuring old-time-1.1.0.3...
configure: WARNING: unrecognized options: --with-compiler
checking for gcc... /usr/bin/gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether /usr/bin/gcc accepts -g... yes
checking for /usr/bin/gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... /usr/bin/gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking sys/timeb.h usability... yes
checking sys/timeb.h presence... yes
checking for sys/timeb.h... yes
checking time.h usability... yes
checking time.h presence... yes
checking for time.h... yes
checking for ftime... yes
checking for gmtime_r... yes
checking for localtime_r... yes
checking for gettimeofday... yes
checking whether struct tm is in sys/time.h or time.h... time.h
checking for struct tm.tm_zone... yes
checking whether time.h and sys/time.h may both be included... yes
checking for sys/time.h... (cached) yes
checking whether altzone is declared... no
configure: creating ./config.status
config.status: creating include/HsTimeConfig.h
configure: WARNING: unrecognized options: --with-compiler
Building old-time-1.1.0.3...
Preprocessing library old-time-1.1.0.3...
.stack-work/dist/x86_64-linux-gmp4/Cabal-1.24.2.0/build/System/Time_hsc_make:
error while loading shared libraries: libgmp.so.10: cannot open shared
object file: No such file or directory
running
.stack-work/dist/x86_64-linux-gmp4/Cabal-1.24.2.0/build/System/Time_hsc_make
failed (exit code 127)
command was:
.stack-work/dist/x86_64-linux-gmp4/Cabal-1.24.2.0/build/System/Time_hsc_make
>.stack-work/dist/x86_64-linux-gmp4/Cabal-1.24.2.0/build/System/Time.hs
-- While building package clock-0.7.2 using:
/pasteur/homes/bli/.stack/setup-exe-cache/x86_64-linux-gmp4/Cabal-simple_mPHDZzAJ_1.24.2.0_ghc-8.0.2
--builddir=.stack-work/dist/x86_64-linux-gmp4/Cabal-1.24.2.0 build
--ghc-options " -ddump-hi -ddump-to-file"
Process exited with code: ExitFailure 1
Logs have been written to:
/pasteur/homes/bli/.stack/global-project/.stack-work/logs/clock-0.7.2.log
Configuring clock-0.7.2...
Building clock-0.7.2...
Preprocessing library clock-0.7.2...
Clock.hsc:44:1: warning: "hsc_alignment" redefined
In file included from
.stack-work/dist/x86_64-linux-gmp4/Cabal-1.24.2.0/build/System/Clock_hsc_make.c:1:
/pasteur/homes/bli/.stack/programs/x86_64-linux/ghc-gmp4-8.0.2/lib/ghc-8.0.2/template-hsc.h:88:1:
warning: this is the location of the previous definition
.stack-work/dist/x86_64-linux-gmp4/Cabal-1.24.2.0/build/System/Clock_hsc_make:
error while loading shared libraries: libgmp.so.10: cannot open shared
object file: No such file or directory
running
.stack-work/dist/x86_64-linux-gmp4/Cabal-1.24.2.0/build/System/Clock_hsc_make
failed (exit code 127)
command was:
.stack-work/dist/x86_64-linux-gmp4/Cabal-1.24.2.0/build/System/Clock_hsc_make
>.stack-work/dist/x86_64-linux-gmp4/Cabal-1.24.2.0/build/System/Clock.hs
It seems that when compiling ghc, stack was able to see gmp, but not when installing some packages.
I notice this warning: configure: WARNING: unrecognized options: --with-compiler. I don't know if this is relevant.
The environment module system seems to work by exporting some environment variables:
$ module show gmp
-------------------------------------------------------------------
/local/gensoft2/devmodules/gmp/6.0.0:
module-whatis Set environnement for gmp (6.0.0)
module-whatis topic_3316
prepend-path LIBRARY_PATH /local/gensoft2/lib/gmp/6.0.0/lib
prepend-path LD_RUN_PATH /local/gensoft2/lib/gmp/6.0.0/lib
prepend-path -d LDFLAGS -L/local/gensoft2/lib/gmp/6.0.0/lib
prepend-path CMAKE_LIBRARY_PATH /local/gensoft2/lib/gmp/6.0.0/lib
prepend-path C_INCLUDE_PATH /local/gensoft2/lib/gmp/6.0.0/include
prepend-path CPLUS_INCLUDE_PATH /local/gensoft2/lib/gmp/6.0.0/include
prepend-path CMAKE_INCLUDE_PATH /local/gensoft2/lib/gmp/6.0.0/include
prepend-path -d CPPFLAGS -I/local/gensoft2/lib/gmp/6.0.0/include
setenv GMP_ROOT /local/gensoft2/lib/gmp/6.0.0
-------------------------------------------------------------------
The administrator told me that these environment variable are not always taken into account, and suggested to export LDFLAGS="-Wl,-rpath,$GMP_ROOT/lib $LDFLAGS" in my environment before trying, but this did not seem to have any effect on the issue.
I still obtain the following: error while loading shared libraries: libgmp.so.10: cannot open shared object file: No such file or directory
How can I get stack to reliably take into account development libraries that the environment modules system provides?
Edit
It seems that I can give the missing library paths on the command line to stack as follows:
$ stack --extra-lib-dirs=/local/gensoft2/lib/gmp/6.0.0/lib --extra-include-dirs=/local/gensoft2/lib/gmp/6.0.0/include install hlint
old-time-1.1.0.3: configure
Package old-time uses a custom Cabal build, but does not use a custom-setup stanza
Not using the explicit setup deps approach based on configuration
Strongly recommend fixing the package's cabal file
old-time-1.1.0.3: build
Package old-time uses a custom Cabal build, but does not use a custom-setup stanza
Not using the explicit setup deps approach based on configuration
Strongly recommend fixing the package's cabal file
clock-0.7.2: configure
clock-0.7.2: build
clock-0.7.2: copy/register
extra-1.5.3: download
extra-1.5.3: configure
extra-1.5.3: build
old-time-1.1.0.3: copy/register
Package old-time uses a custom Cabal build, but does not use a custom-setup stanza
Not using the explicit setup deps approach based on configuration
Strongly recommend fixing the package's cabal file
Package old-time uses a custom Cabal build, but does not use a custom-setup stanza
Not using the explicit setup deps approach based on configuration
Strongly recommend fixing the package's cabal file
cpphs-1.20.8: download
cpphs-1.20.8: configure
cpphs-1.20.8: build
extra-1.5.3: copy/register
cpphs-1.20.8: copy/register
haskell-src-exts-1.18.2: download
haskell-src-exts-1.18.2: configure
haskell-src-exts-1.18.2: build
haskell-src-exts-1.18.2: copy/register
hlint-1.9.41: download
hlint-1.9.41: configure
hlint-1.9.41: build
hlint-1.9.41: copy/register
Completed 6 action(s).
Copying from /pasteur/homes/bli/.stack/snapshots/x86_64-linux-gmp4/lts-8.23/8.0.2/bin/hlint to /pasteur/homes/bli/.local/bin/hlint
Copied executables to /pasteur/homes/bli/.local/bin:
- hlint
Is there a way to have this done automatically for every possible development library loaded by module?
I'm not sure this is completely reliable (environment modules for development libraries might not all export these variables), but passing -extra-include-dirs=${CMAKE_INCLUDE_PATH} and --extra-lib-dirs=${CMAKE_LIBRARY_PATH} to stack seems to work at least when installing hlint, scan and doctest.
I'm a bit confused about what would be the correct configuration file to use, and how, to make this automatic.
It seems that the corresponding settings in ~/.stack/config.yaml are taken into account (although the documentation mentions ~/.stack/global-project/stack.yaml).
The above-mentioned environment variables cannot be used as-is in the config file. I haven't determined what the exact reason. This could be either because their expansion results in something not syntactically correct (paths separated by ":" instead of ","), or because only plain text is permitted in the config file.
Therefore, the following works in the present case, but is not a general solution:
extra-include-dirs: [/local/gensoft2/lib/gmp/6.0.0/include]
extra-lib-dirs: [/local/gensoft2/lib/gmp/6.0.0/lib]
Related
im trying to install rsconnect to connect to shinyapps.io for online hosting. This is my first app so bear with me.
while installing rsconnect through:
install.packages("rsconnect")
it runs through the installation with the checks etc:
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking openssl/ssl.h usability... yes
checking openssl/ssl.h presence... no
configure: WARNING: openssl/ssl.h: accepted by the compiler, rejected by the preprocessor!
configure: WARNING: openssl/ssl.h: proceeding with the compiler's result
checking for openssl/ssl.h... yes
checking openssl/rsa.h usability... yes
checking openssl/rsa.h presence... no
configure: WARNING: openssl/rsa.h: accepted by the compiler, rejected by the preprocessor!
configure: WARNING: openssl/rsa.h: proceeding with the compiler's result
checking for openssl/rsa.h... yes
checking for library containing RSA_generate_key_ex... no
configure: error: Cannot find usable crypto library
ERROR: configuration failed for package ‘PKI’
* removing ‘/cnN0dWRpby1yYWNoYW5kR/x86_64-pc-linux-gnu-library/3.5/PKI’
Warning in install.packages :
installation of package ‘PKI’ had non-zero exit status
ERROR: dependency ‘PKI’ is not available for package ‘rsconnect’
* removing ‘/cnN0dWRpby1yYWNoYW5k/R/x86_64-pc-linux-gnu-library/3.5/rsconnect’
Warning in install.packages :
installation of package ‘rsconnect’ had non-zero exit status
A dependancy on PKI seems to be killing this installation. Installation of PKI separately though
install.packages("PKI")
also fails with the warning
configure: error: Cannot find usable crypto library
ERROR: configuration failed for package ‘PKI’
I am running on an enterprise VM that i do not have normal access to, but can only use apps installed therein. I do not have access to the VM terminal either unfortunately.
Im running yocto to build an image inside docker, but after all processes i get error related to automake. This is the error:
checking whether build environment is sane...
configure: error: newly created file is older than distributed files!
Check your system clock
The log is:
DEBUG: Executing shell function autotools_preconfigure
DEBUG: Shell function autotools_preconfigure finished
DEBUG: Executing python function autotools_aclocals
DEBUG: SITE files ['endian-little', 'common-linux', 'common-glibc', 'bit-64', 'x86_64-linux', 'common']
DEBUG: Python function autotools_aclocals finished
DEBUG: Executing shell function do_configure
NOTE: Running ../automake-1.15.1/configure --build=x86_64-linux --host=x86_64-linux --target=x86_64-linux --prefix=/shared/rpi3-custom/build/tmp/work/x86_64-linux/automake-native/1.15.1-r0/recipe-sysroot-native/usr --exec_prefix=/shared/rpi3-custom/build/tmp/work/x86_64-linux/automake-native/1.15.1-r0/recipe-sysroot-native/usr --bindir=/shared/rpi3-custom/build/tmp/work/x86_64-linux/automake-native/1.15.1-r0/recipe-sysroot-native/usr/bin --sbindir=/shared/rpi3-custom/build/tmp/work/x86_64-linux/automake-native/1.15.1-r0/recipe-sysroot-native/usr/sbin --libexecdir=/shared/rpi3-custom/build/tmp/work/x86_64-linux/automake-native/1.15.1-r0/recipe-sysroot-native/usr/libexec --datadir=/shared/rpi3-custom/build/tmp/work/x86_64-linux/automake-native/1.15.1-r0/recipe-sysroot-native/usr/share --sysconfdir=/shared/rpi3-custom/build/tmp/work/x86_64-linux/automake-native/1.15.1-r0/recipe-sysroot-native/etc --sharedstatedir=/shared/rpi3-custom/build/tmp/work/x86_64-linux/automake-native/1.15.1-r0/recipe-sysroot-native/com --localstatedir=/shared/rpi3-custom/build/tmp/work/x86_64-linux/automake-native/1.15.1-r0/recipe-sysroot-native/var --libdir=/shared/rpi3-custom/build/tmp/work/x86_64-linux/automake-native/1.15.1-r0/recipe-sysroot-native/usr/lib --includedir=/shared/rpi3-custom/build/tmp/work/x86_64-linux/automake-native/1.15.1-r0/recipe-sysroot-native/usr/include --oldincludedir=/shared/rpi3-custom/build/tmp/work/x86_64-linux/automake-native/1.15.1-r0/recipe-sysroot-native/usr/include --infodir=/shared/rpi3-custom/build/tmp/work/x86_64-linux/automake-native/1.15.1-r0/recipe-sysroot-native/usr/share/info --mandir=/shared/rpi3-custom/build/tmp/work/x86_64-linux/automake-native/1.15.1-r0/recipe-sysroot-native/usr/share/man --disable-silent-rules --disable-dependency-tracking --disable-static
configure: WARNING: unrecognized options: --disable-dependency-tracking, --disable-static
checking whether make supports nested variables... yes
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for a BSD-compatible install... /shared/rpi3-custom/build/tmp/hosttools/install -c
checking whether build environment is sane... configure: error: newly created file is older than distributed files!
Check your system clock
NOTE: The following config.log files may provide further information.
NOTE: /shared/rpi3-custom/build/tmp/work/x86_64-linux/automake-native/1.15.1-r0/build/config.log
ERROR: configure failed
WARNING: exit code 1 from a shell command.
ERROR: Function failed: do_configure (log file is located at /shared/rpi3-custom/build/tmp/work/x86_64-linux/automake-native/1.15.1-r0/temp/log.do_configure.11873)
In latest Yocto version, there is this patch that removes clock sanity check.
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 OpenCV 3.0.0 installed in /usr/local/opencv-3.0.0
I am trying to construct a CMakeLists file to build a library against this OpenCV 3.0.0. The CMakeLists.txt is as follows:
cmake_minimum_required(VERSION 2.8)
project(STT_People_Tracker)
cmake_policy(SET CMP0016 NEW)
# compilation mode setup
#set(CMAKE_BUILD_TYPE Release)
set(CMAKE_BUILD_TYPE Debug)
# set OpenCV directories - CHANGE DEPENDING ON SYSTEM
set(OpenCV_PATH "/usr/local/opencv-3.0.0")
set(OpenCV_INCLUDE_DIRS "${OpenCV_PATH}/include")
set(OpenCV_LIBS "${OpenCV_PATH}/lib/")
# set environment variables
set(SOURCES_PATH "${CMAKE_SOURCE_DIR}/Sources")
set(INCLUDES_PATH "${SOURCES_PATH}/include")
if(CMAKE_BUILD_TYPE MATCHES Debug)
set(OUTPUT_PATH "../Debug")
message(STATUS "Compiling in DEBUG mode")
elseif(CMAKE_BUILD_TYPE MATCHES Release)
set(OUTPUT_PATH "../Release")
message(STATUS "Compiling in RELEASE mode")
endif()
include_directories(${INCLUDES_PATH})
include_directories(${OpenCV_INCLUDE_DIRS})
# compilation of executables
message(STATUS "configuring executables...")
add_executable(${OUTPUT_PATH}/mainTest ${SOURCES_PATH}/mainTest.cpp)
# compilation of libraries
message(STATUS "configuring libraries...")
add_library(${OUTPUT_PATH}/background_substractor ${SOURCES_PATH}/background_substractor.cpp)
# set linker options
link_directories(${OpenCV_LIBS})
target_link_libraries(${OUTPUT_PATH}/mainTest opencv_core opencv_highgui)
target_link_libraries(${OUTPUT_PATH}/background_substractor opencv_core opencv_highgui)
message(STATUS "cmake configuration complete")
It is a fairly simple Cmake file, however, I have the following problems/doubts:
1.-How can I know I am using OpenCV 3, and not other versions of OpenCV present in the system?
2.- When compiling the file background_substractor, its associated header file can not be located, although I have checked the path and it is correctly assigned in the set(INCLUDES_PATH "${SOURCES_PATH}/include"):
/home/alberto/STT_People_Tracking/Sources/background_substractor.cpp:3:36: fatal error: background_substractor.h: No such file or directory
#include "background_substractor.h"
^
compilation terminated.
make[2]: *** [CMakeFiles/../Debug/background_substractor.dir/Sources/background_substractor.cpp.o] Error 1
make[1]: *** [CMakeFiles/../Debug/background_substractor.dir/all] Error 2
make: *** [all] Error 2
3.- Finally, and if I comment the header file, I have problems linking:
Linking CXX static library lib../Debug/background_substractor.a
/usr/bin/ar: lib../Debug/background_substractor.a: No such file or directory
make[2]: *** [lib../Debug/background_substractor.a] Error 1
make[1]: *** [CMakeFiles/../Debug/background_substractor.dir/all] Error 2
make: *** [all] Error 2
I have tried everything: Specifying the include files in the add_executable() and add_library() commands, I have checked paths and they are ok, etc etc.
Could anyone more experienced with CMake, give me a little hand?
Thank you very much in advance,
Alberto
How can I know I am using OpenCV 3, and not other versions of OpenCV present in the system?
Your project should check that.
But usually projects just use find_package command for fill variables related to 3d-party library. This command perform all needed checks. In your case it could be
find_package(OpenCV 3 REQUIRED)
call, which fills OpenCV_LIBS and OpenCV_INCLUDE_DIRS variables automatically. This command, by default, search OpenCV installation in default paths, but you can adjust searching algorithm by using parameters to cmake (so, you needn't to change CMakeLists.txt when you build the project on other machine). E.g., this way
cmake -DOpenCV_DIR=/usr/local/opencv-3.0.0 <source-dir>
you can specify precise installation path of OpenCV.
When compiling the file background_substractor, its associated header file can not be located...
Cannot suggest anything aside from checking file existence
/home/alberto/STT_People_Tracking/Sources/include/background_substractor.h
But this also can be a result of the 3d issue(see below).
Finally, and if I comment the header file, I have problems linking...
Your usage of CMake targets is incorrect. Unlike to make targets, which usually are files, CMake targets are simple names. By default, name of library/executable target determines filename of the library/executable file, produced by this target, but this can be changed. Directory, where resulted file will be located, can be adjusted using CMAKE_<TYPE>_OUTPUT_DIRECTORY variables, where <TYPE> can be ARCHIVE, LIBRARY or RUNTIME depending on target type.
Correct CMake script would be:
cmake_minimum_required(VERSION 2.8)
project(STT_People_Tracker)
cmake_policy(SET CMP0016 NEW)
# compilation mode setup
#set(CMAKE_BUILD_TYPE Release)
set(CMAKE_BUILD_TYPE Debug)
# set OpenCV directories using find_package.
find_package(OpenCV 3 REQUIRED)
# set environment variables
set(SOURCES_PATH "${CMAKE_SOURCE_DIR}/Sources")
set(INCLUDES_PATH "${SOURCES_PATH}/include")
if(CMAKE_BUILD_TYPE MATCHES Debug)
set(OUTPUT_PATH "${CMAKE_BINARY_DIR}/Debug") # Use absolute path
message(STATUS "Compiling in DEBUG mode")
elseif(CMAKE_BUILD_TYPE MATCHES Release)
set(OUTPUT_PATH "${CMAKE_BINARY_DIR}/Release")
message(STATUS "Compiling in RELEASE mode")
endif()
# Set output directory for STATIC libraries and executables
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${OUTPUT_PATH})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_PATH})
include_directories(${INCLUDES_PATH})
include_directories(${OpenCV_INCLUDE_DIRS})
# compilation of executables
message(STATUS "configuring executables...")
add_executable(mainTest ${SOURCES_PATH}/mainTest.cpp) # Use simple name as a target
# compilation of libraries
message(STATUS "configuring libraries...")
add_library(background_substractor ${SOURCES_PATH}/background_substractor.cpp) # Use simple name as a target
# set linker options
# Command below is no-op: OpenCV libraries enumerated using absolute paths
# link_directories(${OpenCV_LINK_DIRECTORIES})
target_link_libraries(mainTest ${OpenCV_LIBS}) # Variable OpenCV_LIBS contains OpenCV libraries needed to link with
target_link_libraries(background_substractor ${OpenCV_LIBS})
message(STATUS "cmake configuration complete")
I'm attempting to create a Homebrew formula for gtk-mac-integration. Running make in bindings/python/gtkosx_application fails:
/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: can't open file '/usr/local/Cellar/gtk-mac-integration/2.0.7/share/pygobject/2.0/codegen/h2def.py': [Errno 2] No such file or directory
make[3]: *** [gtkosx_application.defs] Error 2
This is because the Makefile tries to find the h2def.py file in the wrong location:
gtkosx_application.defs: $(headers)
$(PYTHON) $(datadir)/pygobject/2.0/codegen/h2def.py $(headers) > $#
It is clear to me why this is failing: $(datadir) points to the share directory of the package that is to be installed (gkt-mac-integration). Because Homebrew installs all packages into their own prefix (/usr/local/Cellar/...), it is not the same for gtk-mac-integration and pygobject.
I know it is possible to find out where the pygobject data directory is located using
pkg-config --variable=datadir pygobject-2.0
I don't suppose the correct fix is to replace datadir in the Makefile with the string above? How should I adjust configure.ac and Makefile.am to make this work properly?
Yeah, that sounds like a bug in the build system.
You can use the inreplace facility to patch this up. Insert this after def install:
inreplace %w[bindings/python/gtkmacintegration/Makefile.am
bindings/python/gtkmacintegration/Makefile.in
bindings/python/gtkosx_application/Makefile.am
bindings/python/gtkosx_application/Makefile.in],
'$(datadir)/pygobject', |
%x[pkg-config --variable=datadir pygobject-2.0].chomp + '/pygobject'
(I tried this out. The formula builds after that.)
You should report this upstream. They should change their build system to sort this out in their configure script.