The first comments led me through until I reached the error below
NEW ERROR AFTER running sudo apt install libeigen3-dev
CMake Error at rpg_emvs/mapper_emvs/CMakeLists.txt:16 (find_package):
By not providing "FindEigen.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "Eigen", but
CMake did not find one.
Could not find a package configuration file provided by "Eigen" with any of
the following names:
EigenConfig.cmake
eigen-config.cmake
Add the installation prefix of "Eigen" to CMAKE_PREFIX_PATH or set
"Eigen_DIR" to a directory containing one of the above files. If "Eigen"
provides a separate development package or SDK, be sure it has been
installed.
This is the Cmakelists.txt file
project(mapper_emvs)
cmake_minimum_required(VERSION 2.8.3)
find_package(catkin_simple REQUIRED)
catkin_simple(ALL_DEPS_REQUIRED)
find_package(Eigen REQUIRED)
find_package(Boost REQUIRED system filesystem date_time thread)
#Setting include, lib directories and definitions
include_directories(${${Boost_INCLUDE_DIR} ${EIGEN_INCLUDE_DIRS}})
should I try commenting the eigen add package part ?
NEW ERROR After updating CMAKE file
/home/ubuntu/emvs_ws/src/numpy_eigen/include/numpy_eigen/boost_python_headers.hpp:23:22: fatal error: Eigen/Core: No such file or directory
compilation terminated.
ERROR after building numpy_eigen alone
-- verifying file...
file='/home/ubuntu/emvs_ws/build/eigen_catkin/eigen_src-prefix/src/3.3.4.tar.bz2'
-- MD5 hash of
/home/ubuntu/emvs_ws/build/eigen_catkin/eigen_src-prefix/src/3.3.4.tar.bz2
does not match expected value
expected: 'a7aab9f758249b86c93221ad417fbe18'
actual: 'd41d8cd98f00b204e9800998ecf8427e'
-- File already exists but hash mismatch. Removing...
-- Downloading...
dst='/home/ubuntu/emvs_ws/build/eigen_catkin/eigen_src-prefix/src/3.3.4.tar.bz2'
timeout='none'
-- Using src='http://bitbucket.org/eigen/eigen/get/3.3.4.tar.bz2'
[ 13%] Building CXX object numpy_eigen/CMakeFiles/numpy_eigen_test.dir/src/autogen_test_module/test_float.cpp.o
[ 13%] Building CXX object numpy_eigen/CMakeFiles/numpy_eigen_test.dir/src/autogen_test_module/numpy_eigen_test_module.cpp.o
[ 18%] Building CXX object numpy_eigen/CMakeFiles/numpy_eigen_test.dir/src/autogen_test_module/test_double.cpp.o
[ 22%] Building CXX object numpy_eigen/CMakeFiles/numpy_eigen_test.dir/src/autogen_test_module/test_uchar.cpp.o
[ 27%] Building CXX object numpy_eigen/CMakeFiles/numpy_eigen_test.dir/src/autogen_test_module/test_int.cpp.o
[ 31%] Building CXX object numpy_eigen/CMakeFiles/numpy_eigen_test.dir/src/autogen_test_module/test_long.cpp.o
/home/ubuntu/emvs_ws/src/numpy_eigen/src/autogen_test_module/test_uchar.cpp:1:22: fatal error: Eigen/Core: No such file or directory
compilation terminated.
/home/ubuntu/emvs_ws/src/numpy_eigen/src/autogen_test_module/test_float.cpp:1:22: fatal error: Eigen/Core: No such file or directory
compilation terminated.
You can download and keep inside /home/ubuntu/emvs_ws/src(assume this is your ros workspace) folder and compile with other packages which need numpy_eigen.
cd /home/ubuntu/emvs_ws/src
git clone https://github.com/ethz-asl/numpy_eigen.git
cd ../
catkin_make
I guess it's better to use catkin_make instead of catkin build, something those packages getting strange errors with catkin build. Also, if this package depends on catkin_simple, if you don't have catkin_simple, clone that repo into src and try executing catkin_make.
Related
I am compiling a rather big C++ project with cmake.
The project has several targets defined in the CMakeLists.txt of the various subdirectories
I can create a folder somewhere and use cmake to prepare compilation of the targets, and compile any of the target :
cmake ..
make -j8 cytosim
And this works.
However, if I call cmake with a target :
cmake .. --target cytosim
I get the error
CMake Error: The source directory ".../build/cytosim" does not exist.
I thought target was supposed to be a module/library/executable target... What am I missing ?
CMake --target argument is usable in CMake Build Mode (--build).
Try cmake --build .. --target cytosim
I want to create a shared library from cmake . I have a simple test.cpp .
My CMakeLists.txt looks like below
cmake_minimum_required(VERSION 2.8)
project (test)
set(CMAKE_BUILD_TYPE Release)
#include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
add_library(test SHARED /home/tuhin/test/test1/test.cpp)
But I am not able to find "test" which my .so, I have seen test.dir folder created but not .so
Please help me to understand the issue.
(I suppose you read the comments and acted accordingly...)
(I also suppose you need a way to find out where your library will be placed, from within CMake build system)
The disk location of any target does not depend on CMakeLists.txt only, but also on the choice of the generator. Multi config generators like Visual Studio something, or Xcode might append configuration name as an additional directory, so you may get different results just by choosing a different generator.
This means that there is no easy way to uniquely identify disk location during configure stage. On the other hand, you may very easily check that information during the build stage:
cmake_minimum_required(VERSION 3.15)
project (lib_file_name)
add_library(my_test_lib SHARED my_test_lib.cpp)
add_custom_target(output_lib_name
ALL
COMMAND ${CMAKE_COMMAND} -E echo "my_test_lib location: $<TARGET_FILE:my_test_lib>"
)
note add_custom_target line:
new target was added, named output_lib_name
it will be executed as a part of building the default target (-> ALL)
command to build this target is asking cmake to output the file name of the target in question, using CMAke generator expressions (--> COMMAND ${CMAKE_COMMAND} -E echo "my_test_lib location: $<TARGET_FILE:my_test_lib>")
If you run it with makefile generator:
$ cmake -S /tmp -B /tmp/make-build -G "Unix Makefiles" ; cmake --build /tmp/make-build
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/make-build
Scanning dependencies of target my_test_lib
[ 50%] Building CXX object CMakeFiles/my_test_lib.dir/my_test_lib.cpp.o
[100%] Linking CXX shared library libmy_test_lib.dylib
[100%] Built target my_test_lib
Scanning dependencies of target output_lib_name
my_test_lib location: /tmp/make-build/libmy_test_lib.dylib
[100%] Built target output_lib_name
Note the line
my_test_lib location: /tmp/make-build/libmy_test_lib.dylib
if you run it with Xcode generator:
configure:
$ cmake -S /tmp -B /tmp/xcode-build -G Xcode
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/xcode-build
build release configuration:
$ cmake --build /tmp/xcode-build --config Release
........... lot of output deleted ...........
my_test_lib location: /tmp/xcode-build/Release/libmy_test_lib.dylib
** BUILD SUCCEEDED **
build debug configuration:
$ cmake --build /tmp/xcode-build --config Debug
........... lot of output deleted ...........
my_test_lib location: /tmp/xcode-build/Debug/libmy_test_lib.dylib
** BUILD SUCCEEDED **
Note how the location is different for different configuration builds, without any change in CMake build system.
At the end, this is the cmake documentation about add_custom_command, cmake generator expressions.
I've been writing a compiler using LLVM as the backend. The CMake files I've written so far have worked on Linux, but I haven't had any luck on Windows. The project is split into a library and "driver" executable with their own CMakeLists.txt in separate subdirectories.
The top level CMakeLists.txt looks like this:
cmake_minimum_required (VERSION 3.7.0)
project (compiler)
set (CMAKE_CXX_STANDARD 14)
set (CMAKE_CXX_STANDARD_REQUIRED ON)
set (CMAKE_CXX_EXTENSIONS OFF)
find_package (LLVM REQUIRED CONFIG)
message (STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message (STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
include_directories (${LLVM_INCLUDE_DIRS})
add_definitions(${LLVM_DEFINITIONS})
add_subdirectory (Compiler_Lib)
add_subdirectory (Compiler_exe)
The CMakeLists.txt for the library:
cmake_minimum_required (VERSION 3.7.0)
add_library (compiler_lib
AST.cpp
AST.h
parser.cpp
parser.h
scanner.cpp
scanner.h
token.cpp
token.h
visualizer.cpp
visualizer.h
codegen.cpp
codegen.h)
target_include_directories (compiler_lib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(compiler_lib LLVM)
And the CMakeLists.txt for the executable (which is where linking to the libraries fails):
cmake_minimum_required (VERSION 3.7.0)
project (compiler_exe)
add_executable (compiler_exe Compiler_exe.cpp getopt.h getopt.cpp)
target_link_libraries (compiler_exe LINK_PUBLIC LLVM compiler_lib)
I run the command "c:\Program Files\CMake\bin\cmake.exe" .. -G"MinGW Makefiles" -DCMAKE_PREFIX_PATH=C:\Users\James\llvm+clang-7.0.0-win64-msvc-release where C:\Users\James\llvm+clang-7.0.0-win64-msvc-release is the path to prebuilt LLVM libraries. However, running mingw32-make afterwards fails with the output
Scanning dependencies of target compiler_lib
[ 10%] Building CXX object Compiler_Lib/CMakeFiles/compiler_lib.dir/AST.cpp.obj
[ 20%] Building CXX object Compiler_Lib/CMakeFiles/compiler_lib.dir/parser.cpp.obj
[ 30%] Building CXX object Compiler_Lib/CMakeFiles/compiler_lib.dir/scanner.cpp.obj
[ 40%] Building CXX object Compiler_Lib/CMakeFiles/compiler_lib.dir/token.cpp.obj
[ 50%] Building CXX object Compiler_Lib/CMakeFiles/compiler_lib.dir/visualizer.cpp.obj
[ 60%] Building CXX object Compiler_Lib/CMakeFiles/compiler_lib.dir/codegen.cpp.obj
[ 70%] Linking CXX static library libcompiler_lib.a
[ 70%] Built target compiler_lib
Scanning dependencies of target compiler_exe
[ 80%] Building CXX object Compiler_exe/CMakeFiles/compiler_exe.dir/Compiler_exe.cpp.obj
[ 90%] Building CXX object Compiler_exe/CMakeFiles/compiler_exe.dir/getopt.cpp.obj
[100%] Linking CXX executable compiler_exe.exe
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: cannot find -lLLVM
collect2.exe: error: ld returned 1 exit status
Compiler_exe\CMakeFiles\compiler_exe.dir\build.make:102: recipe for target 'Compiler_exe/compiler_exe.exe' failed
mingw32-make[2]: *** [Compiler_exe/compiler_exe.exe] Error 1
CMakeFiles\Makefile2:176: recipe for target 'Compiler_exe/CMakeFiles/compiler_exe.dir/all' failed
mingw32-make[1]: *** [Compiler_exe/CMakeFiles/compiler_exe.dir/all] Error 2
Makefile:82: recipe for target 'all' failed
mingw32-make: *** [all] Error 2
This is the first time I've used CMake so I could have missed something obvious, but as I say it seems to work on Linux.
For the linking to succeed two things need to be true:
1) the file libLLVM.a needs to exist
2) that file has to be in a directory in the library search path
There should be a way to get cmake to tell you the list of places it searches for libraries, and you need to find a way to get wherever libLLVM.a exists into that list of dirs.
Apologies for the partial answer, but that's the troubleshooting path...
I'm trying to install awesome wm from source. So I created a build directory and executed the following command:
cmake .. -DCMAKE_INSTALL_PREFIX=$PREFIX
But make install tries to put some of the program files in /usr/local/share, which isn't where I want them:
> make install
[ 3%] Built target generated_sources
[ 6%] Built target test-gravity
[ 9%] Built target lgi-check
[ 9%] Built target version_stamp
[ 29%] Built target generated_icons
[ 31%] Checking for LGI...
Building for Lua 5.3.
Found lgi 0.9.2.
[ 31%] Built target lgi-check-run
[ 35%] Built target generate_awesomerc
[100%] Built target awesome
Install the project...
-- Install configuration: ""
-- Up-to-date: /home/user/.local/bin/awesome
-- Up-to-date: /home/user/.local/bin/awesome-client
-- Installing: /usr/local/share/awesome/lib
CMake Error at cmake_install.cmake:69 (file):
file INSTALL cannot make directory "/usr/local/share/awesome/lib": No such
file or directory
make: *** [Makefile:107: install] Error 1
Is there some cmake variable similar to CMAKE_INSTALL_PREFIX or CMAKE_INSTALL_LIBDIR which I need to specify for share data?
You'll have CMAKE_INSTALL_DATADIR for share when using the cmake module: include(GNUInstallDirs)
Note: when using cmake --build build --target install -- DESTDIR=foo
please read the CMAKE_INSTALL_PREFIX doc
On UNIX one can use the DESTDIR mechanism in order to relocate the whole installation. DESTDIR means DESTination DIRectory.
WARNING: DESTDIR may not be used on Windows because installation prefix usually contains a drive letter like in C:/Program Files which cannot be prepended with some other prefix.
src: https://cmake.org/cmake/help/latest/variable/CMAKE_INSTALL_PREFIX.html#variable:CMAKE_INSTALL_PREFIX
First Attempt
In my cmake/c++ project I get the following error when compiling:
C:\local\projects\synergy-usb\synergy-through-usb-master>cmake .
You have called ADD_LIBRARY for library cryptopp without any source files. This typically indicates a problem with your CMakeLists.txt file
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
LIBUSB_1_INCLUDE_DIR
used as include directory in directory C:/local/projects/synergy-usb/synergy-through-usb-master/src/lib/arch
used as include directory in directory C:/local/projects/synergy-usb/synergy-through-usb-master/src/lib/net
LIBUSB_1_LIBRARY
linked by target "arch" in directory C:/local/projects/synergy-usb/synergy-through-usb-master/src/lib/arch
-- Configuring incomplete, errors occurred!
See also "C:/local/projects/synergy-usb/synergy-through-usb-master/CMakeFiles/CMakeOutput.log".
So I am missing libusb libraries.
Second Attempt
So now I have found a version of libusb_1 (libusbx-1.0.18-win) which includes the folders:
examples
include
MinGW32
MinGW64
MS32
MS64
I copied MS64/dll (windows 64-bit) contents and put it here:
C:\local\libs\libusbx
I added this path to my PATH variable and then tried to run cmake again:
C:>cd local\projects\synergy-usb\synergy-through-usb-master
C:\local\projects\synergy-usb\synergy-through-usb-master>cmake .
You have called ADD_LIBRARY for library cryptopp without any source files. This typically indicates a problem with your CMakeLists.txt file
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
LIBUSB_1_LIBRARY
linked by target "arch" in directory C:/local/projects/synergy-usb/synergy-through-usb-master/src/lib/arch
-- Configuring incomplete, errors occurred!
See also "C:/local/projects/synergy-usb/synergy-through-usb-master/CMakeFiles/CMakeOutput.log".
Now I am stuck again. I have no idea what it wants me to do. It knows where libusb is...
Edit
Here is the contects (part of) the CMakeLists.txt that has libusb in it:
find_package(libusb-1.0 REQUIRED)
set(inc
.
../base
../common
../mt
../platform
../synergy
${LIBUSB_1_INCLUDE_DIRS}
)
if (UNIX)
list(APPEND inc
../../..
../arch
)
endif()
include_directories(${inc})
add_library(arch STATIC ${src})
set(libs
../lib
${LIBUSB_1_LIBRARIES}
)
if (WIN32)
if (GAME_DEVICE_SUPPORT)
list(APPEND libs synxinhk)
endif()
endif()
target_link_libraries(arch ${libs})
Edit 2
I added the following lines into the findlibusb-1.0.cmake file:
set(LIBUSB_1_LIBRARY C:\\local\\libs\\libusbx\\libusb-1.0.dll)
message(STATUS "***********************************> LIBUSB_1_LIBRARY: ${LIBUSB_1_LIBRARY}")
Here is the output from that:
C:\local\projects\synergy-usb\synergy-through-usb-master>cmake .
-- ***********************************> LIBUSB_1_LIBRARY: C:\local\libs\libusbx\libusb-1.0.dll
-- Found libusb-1.0:
-- - Includes: C:/local/libs/libusbx
-- - Libraries: C:\local\libs\libusbx\libusb-1.0.dll
You have called ADD_LIBRARY for library cryptopp without any source files. This typically indicates a problem with your CMakeLists.txt file
-- Configuring done
CMake Error: CMake can not determine linker language for target: cryptopp
CMake Error: CMake can not determine linker language for target: cryptopp
CMake Error: CMake can not determine linker language for target: cryptopp
CMake Error: CMake can not determine linker language for target: cryptopp
-- Generating done
-- Build files have been written to: C:/local/projects/synergy-usb/synergy-through-usb-master
Still does not build, but this particular library seems to be added ok now :)
synergy had such approach to keep some 3rd party libs compressed in zip in ext subdirectory. synergy-through-usb though kept cmake way to specify include through -DLIBUSB_1_INCLUDE_DIR=... -DLIBUSB_1_LIBRARY=... for Windows.
So you just need go to 'ext' directory and uncompress its zip archives with libraries gtest, gmock and crypto.