installing caffe cmake error - cmake

I've followed all the steps to install the caffe dependencies. I've bumped into the following error:
find: `dependencies/cmake-3.3.0-rc2/Tests/FindPackageTest/Baz': No such file or directory
find: `1.1': No such file or directory
find: `dependencies/cmake-3.3.0-rc2/Tests/FindPackageTest/Baz': No such file or directory
find: `1.2': No such file or directory
find: `dependencies/cmake-3.3.0-rc2/Tests/FindPackageTest/Baz': No such file or directory
find: `1.2/CMake': No such file or directory
find: `dependencies/cmake-3.3.0-rc2/Tests/SubDirSpaces/Another': No such file or directory
find: `Subdir': No such file or directory
find: `Sources': No such file or directory
bash: -c: line 0: syntax error near unexpected token `('
bash: -c: line 0: `find dependencies/cmake-3.3.0-rc2/Tests/SubDirSpaces/Some(x86) Sources -maxdepth 1 \( -name '*.cpp' -o -name '*.proto' \) | grep -q .'
find: `dependencies/cmake-3.3.0-rc2/Tests/SubDirSpaces/Some': No such file or directory
find: `Examples': No such file or directory
find: `dependencies/cmake-3.3.0-rc2/Tests/SubDirSpaces/Some': No such file or directory
find: `Examples/example2': No such file or directory
find: `dependencies/cmake-3.3.0-rc2/Tests/SubDirSpaces/Some': No such file or directory
find: `Examples/example1': No such file or directory
LD -o .build_release/lib/libcaffe.so
/usr/bin/ld: /usr/local/lib/libgflags.a(gflags.cc.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libgflags.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make: *** [.build_release/lib/libcaffe.so] Error 1
I'm not really sure what's going on. It seems as if cmake hasn't been installed properly? What's curious is that I have two cmake folders: One in my caffe folder and the other one inside an extra folder I called "dependencies" in which I am compiling all other dependencies for caffe:
doing form my /caffe/ folder:
$ ls
build
.build_release
caffe.cloc
cmake
cmake-3.3.0-rc2.tar.gz
CMakeLists.txt
CONTRIBUTORS.md
data
dependencies
distribute
docs
.Doxyfile
examples
.gitignore
include
INSTALL.md
LICENSE
Makefile
Makefile.config
Makefile.config.example
matlab
models
python
README.md
scripts
src
tools
.travis.yml
doing ls from my /caffe/dependencies/ folder:
$ ls
cmake-3.3.0-rc2
cmake-3.3.0-rc2.tar.gz
gflags-master
gflags-master.zip
glog-0.3.3
glog-0.3.3.tar.gz
master.zip
mdb
Was I supposed to install all the dependencies inside my /caffe/ folder?

I suggest you should use the cmake-gui for making Caffe. There you can set the appropriate paths easily. No need to install all the dependencies in the Caffe root directory. You may install them in your system home directory.

Related

meson.build: ERROR: File does not exist, while in reality it does

From a trivial meson.build file, I get the following error:
meson.build:27:0: ERROR: File dataStructures.hpp does not exist.
dataStructures.hpp,
The meson.build file is:
headers += [
'dataStructures.hpp',
'interface.hpp',
'platform.hpp',
'progArgs.hpp',
]
The file reported as missing is present and it is in the same directory the meson.build file is.
If I remove the 'dataStructures.hpp' string from the list, I get the same error for the second file 'interface.hpp'.
What am I doing wrong?
More details follow.
> CC=clang CXX=clang++ meson /dev/shm/test-build
The Meson build system
Version: 0.52.0
Source dir: /home/pietrom/myProgs/test
Build dir: /dev/shm/test-build
Build type: native build
Project name: test
Project version: 0.0.1
C++ compiler for the host machine: clang++ (clang 8.0.1 "clang version 8.0.1 (tags/RELEASE_801/final)")
C++ linker for the host machine: GNU ld.bfd 2.32
Host machine cpu family: x86_64
Host machine cpu: x86_64
src/meson.build:27:0: ERROR: File dataStructures.hpp does not exist.
A full log can be found at /dev/shm/test-build/meson-logs/meson-log.txt
In the full log there is no much more than what already reported.
This is the project directory structure:
test/
meson.build
src/
meson.build
sources
config/
meson.build
sources
testers/
meson.build
sources
utilities/
meson.build
sources
As you don't provide all meson.build file contents, and most importantly the place where it happens - meson.build:27:0: ERROR: File dataStructures.hpp does not exist. - points at line 27 in some meson.build file, I'll try to make a guess that you build executable in root meson.build file, i.e. in test/meson.build however your headers are inside test/src. If that's the case, you don't need to have this array of headers at all, just add
inc = include_directories('./src')
some_test_exe = executable('mytest',
test_sources,
...
include_directories : inc
)
include_directories function creates include object with path relative to your source root.

CMake's find_library cannot find library without version, extension and lib prefix

I am trying to link against a system library: /usr/lib/x86_64-linux-gnu/libtcmalloc.so.4, when I have this CMakeLists.txt
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
project(all)
find_library(TCMALLOC_LIB NAMES tcmalloc)
if(TCMALLOC_LIB)
message("Found TCMALLOC_LIB: ${TCMALLOC_LIB}")
else()
message(FATAL_ERROR "TCMALLOC_LIB library not found")
endif()
(also tried find_library(TCMALLOC_LIB tcmalloc))
I get
CMake Error at CMakeLists.txt:13 (message):
TCMALLOC_LIB library not found
While, if I have
find_library(TCMALLOC_LIB NAMES libtcmalloc.so.4)
everything is fine: Found TCMALLOC_LIB: /usr/lib/x86_64-linux-gnu/libtcmalloc.so.4
Am I doing something wrong? Why do I need to specify filename precisely? How can I debug find_library?
Update - Real cause
As #Tsyvarev mentioned in the comment, it turns out that cmake could not find the library because I installed it only "partially", the -dev version (libgoogle-perftools-dev) should have been installed.
TL;DR
Well, it turns out that tcmalloc is not a regular/conventional library, namely, it does not have libtcmalloc.so symlink pointing to .so.4, that is why cmake cannot find it.
How can I debug find_library?
I found a way of debugging find_library via strace:
$ rm -rf ./* && strace cmake ../scripts/ 2>&1 | grep tcmalloc
access("/usr/local/nvidia/bin/libtcmalloc.so", R_OK) = -1 ENOENT (No such file or directory)
access("/usr/local/cuda/bin/libtcmalloc.so", R_OK) = -1 ENOENT (No such file or directory)
access("/usr/local/sbin/libtcmalloc.so", R_OK) = -1 ENOENT (No such file or directory)
access("/usr/local/bin/libtcmalloc.so", R_OK) = -1 ENOENT (No such file or directory)
...
<many lines skipped>
...
From this strace output we see that cmake, indeed tries to prepend lib and append .so, but it does not try to prepend any version.
Now, if we look at another "normal" library:
# locate protobuf | grep "\.so"
/usr/lib/x86_64-linux-gnu/libprotobuf.so
/usr/lib/x86_64-linux-gnu/libprotobuf.so.17
/usr/lib/x86_64-linux-gnu/libprotobuf.so.17.0.0
we will see that it DOES install .so symlink, while tcmalloc does not:
# locate tcmalloc | grep "\.so"
/usr/lib/x86_64-linux-gnu/libtcmalloc.so.4
/usr/lib/x86_64-linux-gnu/libtcmalloc.so.4.3.0

How to use CMake to create a package that installs to '/etc' and '/var'?

I've got CMake (3.02) installing to a DESTDIR when I invoke:
$ make -C build DESTDIR=$(pwd)/build/rootfs install
This results in a file layout that I'm happy with: binaries are located in the .../build/rootfs/usr/local/bin directory and the init scripts are in .../build/rootfs/etc/init.d. To accomplish that, I used a mixture of relative and absolute paths in my CMakeLists.txt file:
set(CPACK_SET_DESTDIR ON)
...
INCLUDE(CPack)
...
set(ROOTFS_BIN_DIR bin)
set(ROOTFS_ETC_INITD_DIR /etc/init.d)
...
INSTALL(TARGETS myDaemon DESTINATION ${ROOTFS_BIN_DIR})
INSTALL(PROGRAMS myDaemon.sh RENAME myDaemon DESTINATION ${ROOTFS_ETC_INITD_DIR})
With that, I think 'working', I'm trying to create a simple tarball package which will eventually become a debian package (with pre/post install/remove scripts) but when I invoke:
$ make -C build DESTDIR=$(pwd)/build/rootfs package
I'm getting errors because cpack is attempting to write my init scripts to the system's /etc/init.d directory (instead of $(pwd)/build/rootfs/etc/init.d). If I wanted that, then $sudo !! would solve the problem. The error (replaced full path with ...):
CMake Error at .../build_src/cmdServer/cmake_install.cmake:44 (file):
file INSTALL cannot copy file
".../src/cmdServer/cmdServer.sh" to
"/etc/init.d/cmdServer".
I'm not using a lot of CPACK directives: in my top level CMakeLists.txt file I have:
SET(CPACK_SET_DESTDIR ON)
SET(CPACK_GENERATOR TGZ)
INCLUDE(CPack)
How can I package my init scripts correctly?
I've been referencing:
https://cmake.org/pipermail/cmake/2008-April/020833.html
and https://cmake.org/pipermail/cmake/2006-November/011890.html

Ninja not found by CMake

I'm trying to build some code I got from GitHub using CMake, but keep getting the followings errors:
CMake Error: CMake was unable to find a build program corresponding to "Ninja". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_C_COMPILER_ENV_VAR
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_C_COMPILER
CMake Error: Could not find cmake module file:/golang/project/src/github.com/devsisters/goquic/libquic/build/debug/CMakeFiles/2.8.11/CMakeCCompiler.cmake
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_CXX_COMPILER_ENV_VAR
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_CXX_COMPILER
CMake Error: Could not find cmake module file:/golang/project/src/github.com/devsisters/goquic/libquic/build/debug/CMakeFiles/2.8.11/CMakeCXXCompiler.cmake
-- Configuring incomplete, errors occurred!
How do I set these variables correctly?
I used a ./build_libs.sh file that came with the GitHub code to build this.
The script you are executing uses the CMake Ninja generator. For that to work you need Ninja on the path. On most Linux distributions you can install it from a package.
Ubuntu: ninja-build
openSUSE: ninja
If you can't find it for your distribution, you have to download it and add its location to the path environment variable.
My solution: symlink "ninja-build" to "ninja".
# ln -s /usr/bin/ninja /usr/bin/ninja-build
This only works on very old versions of CMake, which I will explain below.
I had already dropped my fresh "ninja" binary into /usr/bin and checked it had 0755 permissions. I was stumped until I ran an strace on the generator command.
# strace cmake -GNinja .. | grep -i ninja
access("ninja-build", R_OK) = -1 ENOENT (No such file or directory)
access("/usr/local/sbin/ninja-build", R_OK) = -1 ENOENT (No such file or directory)
access("/usr/local/bin/ninja-build", R_OK) = -1 ENOENT (No such file or directory)
access("/sbin/ninja-build", R_OK) = -1 ENOENT (No such file or directory)
access("/bin/ninja-build", R_OK) = -1 ENOENT (No such file or directory)
access("/usr/sbin/ninja-build", R_OK) = -1 ENOENT (No such file or directory)
access("/usr/bin/ninja-build", R_OK) = -1 ENOENT (No such file or directory)
access("/opt/texlive/2016/bin/i386-linux/ninja-build", R_OK) = -1 ENOENT (No such file or directory)
access("/root/bin/ninja-build", R_OK) = -1 ENOENT (No such file or directory)
It was looking for "ninja-build", not "ninja"!
I use CMake with Ninja extensively at work and at home, on Windows and Linux. So why haven't I seen this bug before?
Well... in this instance I'm using a very old version of CMake, version 2.8.12. It's so old it's almost fossilised. So presumably it's either a CMake bug which was fixed later, or the Ninja project changed the name of the binary at some point.
In Debian/Ubuntu systems, go ahead and install it
apt install ninja-build
Then rerun CMake.
If ninja really exists in $PATH and it still does not work, you should check the permission of the executable file via ls -l /PATH/TO/NINJA. Make sure others have read and execute permissions (like '-rwxr-xr-x').
See also: 0013910: Ninja generator initialization fails if /usr/bin/ninja is not world-readable
You may still suffer
CMake Error: CMake was unable to find a build program corresponding to "Ninja". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
even you already have::
put ninja in your PATH
ninja executable with proper privilege
newer version of cmake**
Then it might because -D CMAKE_MAKE_PROGRAM and -G Ninja are specified at the same time but CMAKE_MAKE_PROGRAM with invalid value (such as empty).
For example
Android Studio with gradle plugin version :
classpath 'com.android.tools.build:gradle:7.0.0-alpha03'
and not using SDK Manager provided cmake, by:
put cmake executable in PATH environment variable
put ninja executable in PATH environment variable
specify cmake version equal to the one in PATH, in modules's build.gradle, like:
externalNativeBuild {
cmake {
path "src/main/cpp/CMakeLists.txt"
version "3.19.1" // this line
}
}
Then actually gradle calling cmake like this:
cmake ^
-HD:\dev\android_cv_examples\HelloNDK7\app\src\main\cpp ^
-DCMAKE_SYSTEM_NAME=Android ^
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON ^
-DCMAKE_SYSTEM_VERSION=26 ^
-DANDROID_ABI=arm64-v8a ^
-DCMAKE_ANDROID_ARCH_ABI=arm64-v8a ^
-DANDROID_NDK=D:\soft\Android\ndk-r21b ^
-DCMAKE_ANDROID_NDK=D:\soft\Android\ndk-r21b ^
-DCMAKE_TOOLCHAIN_FILE=D:\soft\Android\ndk-r21b\build\cmake\android.toolchain.cmake ^
-DCMAKE_MAKE_PROGRAM= ^
-DCMAKE_C_FLAGS= ^
-DCMAKE_CXX_FLAGS=-std=c++11 ^
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=D:\dev\android_cv_examples\HelloNDK7\app\build\intermediates\cmake\debug\obj\arm64-v8a ^
-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=D:\dev\android_cv_examples\HelloNDK7\app\build\intermediates\cmake\debug\obj\arm64-v8a ^
-DCMAKE_BUILD_TYPE=Debug ^
-BD:\dev\android_cv_examples\HelloNDK7\app\.cxx\cmake\debug\arm64-v8a ^
-GNinja ^
-DANDROID_PLATFORM=android-24
Note: If removing previous cmake build cache, and modify that calling script by deleting -DCMAKE_MAKE_PROGRAM then problem will be solved.
I am using Mac Monterey. I put ninja into /Applications and /Users/USER/Applications and made sure $PATH was pointing to these directories, but no luck.
I only made CMake discover Ninja by installing it via homebrew:
brew install ninja
My issue was fixed by upgrading CMake to the latest version as specified in this answer:
https://askubuntu.com/a/865294/924090
This was apparently an issue in CMake that is now fixed in the latest version. More information here:
https://gitlab.kitware.com/cmake/cmake/-/issues/21486
At U20 was resolved for me only when using "pip install ninja" rather than "sudo apt install ninja-build"

Cannot find input file: makefile.in

I've bin trying to integrate Apache and with Django.
I downloaded the mod_wsgi-3.4 folder from the net and tried running the ./configure command from git bash.
I'm using dev c++ as my c compiler.
I get the following errors:
./configure: line 1877: apxs: command not found ln: creating symbolic link 'Makefile.in' to 'posix-apX.mk.in': No such file directory configure: creating ./config.status config.status:error: cannot find input file: Makefile.in
Can someone help me with this?
You can specify the location of apxs
./configure --with-apxs=/usr/local/apache/bin/apxs