g++ can't find installed library - c++

I'm trying to compile and example file which needs the required library libmusicxml.
I compiled the library as they said (cmake, make, make install) and it made and installed a bunch of files:
Install the project...
-- Install configuration: ""
-- Installing: /usr/local/lib/libmusicxml2.so.3.00
-- Installing: /usr/local/lib/libmusicxml2.so
-- Installing: /usr/local/include/libmusicxml/musicxmlfactory.h
-- Installing: /usr/local/include/libmusicxml/sortvisitor.h
-- Installing: /usr/local/include/libmusicxml/xmlreader.h
... etc
Now I want to compile one of their sample files so I run g+ filename.cpp and it gives me the following error:
libmusicxml.h: No such file or directory
Does this mean it's not seeing the library in /usr/local? Can I specify this somewhere? Set a path or something?
I have made sure to have the latest version of the libmusicxml library from here and did the same (cmake followed by make).
When I go to the gives samples and try to make one (with the provided make file, which work according to the developer) it doesn't want to do it:
dorien#XP:~/bin/libmusicxml-master/samples$ make
gcc -g -O3 -Wall -Wuninitialized -I../src/elements -I../src/interface -I../src/files -I../src/lib -I../src/parser -I../src/visitors -I../src/guido -I../src/operations countnotes.cpp ../libmusicxml2.a -lstdc++ -o countnotes
gcc: error: ../libmusicxml2.a: No such file or directory
Makefile:14: recipe for target 'countnotes' failed
-> I tried to locate libmusicxml2.a and that doesn't seem to exist.
When I run xml2guido (which seems to have a compiled version in the root directory of the package), I get:
xml2guido: error while loading shared libraries: libmusicxml2.so.3.00: cannot open shared object file: No such file or directory
However, there is a libmusicxml2.so.3.00 in the same directory
Maybe it's that the package is not linked correctly? Or something about the missing .a file?
I do think it was built correctly:
make
[ 73%] Built target musicxml2
[ 75%] Built target RandomMusic
[ 78%] Built target countnotes
[ 80%] Built target partsummary
[ 82%] Built target readunrolled
[ 85%] Built target xml2guido
[ 87%] Built target xml2midi
[ 90%] Built target xmlclone
[ 92%] Built target xmlfactory
[ 95%] Built target xmliter
[ 97%] Built target xmlread
[100%] Built target xmltranspose
dorien#XP:~/bin/libmusicxml-master$ sudo make install
[ 73%] Built target musicxml2
[ 75%] Built target RandomMusic
[ 78%] Built target countnotes
[ 80%] Built target partsummary
[ 82%] Built target readunrolled
[ 85%] Built target xml2guido
[ 87%] Built target xml2midi
[ 90%] Built target xmlclone
[ 92%] Built target xmlfactory
[ 95%] Built target xmliter
[ 97%] Built target xmlread
[100%] Built target xmltranspose
Install the project...
-- Install configuration: ""
-- Up-to-date: /usr/local/lib/libmusicxml2.so.3.00
-- Up-to-date: /usr/local/lib/libmusicxml2.so
-- Up-to-date: /usr/local/include/libmusicxml/musicxmlfactory.h
-- Up-to-date: /usr/local/include/libmusicxml/sortvisitor.h
-- Up-to-date: /usr/local/include/libmusicxml/xmlreader.h
-- Up-to-date: /usr/local/include/libmusicxml/xmlfile.h
-- Up-to-date: /usr/local/include/libmusicxml/libmusicxml.h
-- Up-to-date: /usr/local/include/libmusicxml/unrolled_xml_tree_browser.h
-- Up-to-date: /usr/local/include/libmusicxml/xml.h
-- Up-to-date: /usr/local/include/libmusicxml/elements.h
-- Up-to-date: /usr/local/include/libmusicxml/factory.h
-- Up-to-date: /usr/local/include/libmusicxml/types.h
-- Up-to-date: /usr/local/include/libmusicxml/typedefs.h
-- Up-to-date: /usr/local/include/libmusicxml/xml_tree_browser.h
-- Up-to-date: /usr/local/include/libmusicxml/versions.h
-- Up-to-date: /usr/local/include/libmusicxml/exports.h

Does this mean it's not seeing the library in /usr/local?
It means that it didn't find the header libmusicxml.h. You didn't tell the compiler to look for it in /usr/local/include/libmusicxml.
Can I specify this somewhere? Set a path or something?
See the documentation of your compiler. In gcc, the option for include search paths is -I.
Instead of searching for the header libmusicxml.h from /usr/local/include/libmusicxml/, I would recommend including libmusicxml/libmusicxml.h and searching from /usr/local/include. That would be simpler since g++ searches from /usr/local/include by default, so no compiler options would be required.

The library (and headers) weren't recognised until I ran:
export LD_LIBRARY_PATH=/addressto/libmusicxml-master
That fixed it.

Related

How to use uiohook library in CMake project?

I am trying to install the following C library:
https://github.com/kwhat/libuiohook
I did the described steps which seem to work with no error.
$ git clone https://github.com/kwhat/libuiohook
$ cd uiohook
$ mkdir build && cd build
$ cmake -S .. -D BUILD_SHARED_LIBS=ON -D BUILD_DEMO=ON -DCMAKE_INSTALL_PREFIX=../dist
$ cmake --build . --parallel 2 --target install
The problem is I don't know what to do next.
I tried to copy the code from the simple hook example and tried to execute the code in a different executable with the following CMakeLists.txt.
cmake_minimum_required(VERSION 3.20)
project(libuihook_test)
include_directories("/Users/ahoehne/libuiohook/dist/include")
find_library(lib uiohook)
if(NOT lib)
message(FATAL_ERROR "uiohook library not found")
endif()
set(CMAKE_CXX_STANDARD 17)
add_executable(libuihook_test main.cpp)
target_link_libraries(libuihook_test lib)
which doesn't work and results in a
CMake Error at CMakeLists.txt:9 (message):
uiohook library not found
the log from installing is the following:
[ 14%] Building C object CMakeFiles/uiohook.dir/src/darwin/input_helper.c.o
[ 14%] Building C object CMakeFiles/uiohook.dir/src/logger.c.o
[ 21%] Building C object CMakeFiles/uiohook.dir/src/darwin/input_hook.c.o
[ 28%] Building C object CMakeFiles/uiohook.dir/src/darwin/post_event.c.o
[ 35%] Building C object CMakeFiles/uiohook.dir/src/darwin/system_properties.c.o
[ 42%] Linking C shared library libuiohook.dylib
[ 42%] Built target uiohook
[ 57%] Building C object CMakeFiles/demo_post.dir/demo/demo_post.c.o
[ 57%] Building C object CMakeFiles/demo_properties.dir/demo/demo_properties.c.o
[ 71%] Linking C executable demo_properties
[ 71%] Linking C executable demo_post
[ 71%] Built target demo_post
[ 71%] Built target demo_properties
[ 78%] Building C object CMakeFiles/demo_hook.dir/demo/demo_hook.c.o
[ 85%] Building C object CMakeFiles/demo_hook_async.dir/demo/demo_hook_async.c.o
[ 92%] Linking C executable demo_hook
[100%] Linking C executable demo_hook_async
[100%] Built target demo_hook
[100%] Built target demo_hook_async
Install the project...
-- Install configuration: ""
-- Installing: /Users/ahoehne/libuiohook/dist/lib/libuiohook.1.2.0.dylib
-- Up-to-date: /Users/ahoehne/libuiohook/dist/lib/libuiohook.1.dylib
-- Up-to-date: /Users/ahoehne/libuiohook/dist/lib/libuiohook.dylib
-- Up-to-date: /Users/ahoehne/libuiohook/dist/include/uiohook.h
-- Installing: /Users/ahoehne/libuiohook/dist/lib/cmake/uiohook/uiohook-config.cmake
-- Installing: /Users/ahoehne/libuiohook/dist/lib/cmake/uiohook/uiohook-config-noconfig.cmake
-- Installing: /Users/ahoehne/libuiohook/dist/bin/demo_hook
-- Installing: /Users/ahoehne/libuiohook/dist/bin/demo_hook_async
-- Installing: /Users/ahoehne/libuiohook/dist/bin/demo_post
-- Installing: /Users/ahoehne/libuiohook/dist/bin/demo_properties
-- Installing: /Users/ahoehne/libuiohook/dist/lib/pkgconfig/uiohook.pc
I consulted the CMAKE Docs but honestly right now confuses me more than it helps. I am sure at some point I will have an aha moment and connect the dots. Most tutorials do an excellent job of explaining you C/C++ but they all lack the more advanced stuff around build tools, testing, debugging, and so on, everything you basically need to build more complex projects. So I am also grateful for book/video suggestions.
I also tried different combinations of include_directories, add, link library also an absolute path but nothing seems to work and I get a library not found error or uiohook.h not found.
I am well aware that C and C++ are completely different languages and different practices apply I am not sure If I could have fixed this question to one. But basically try to learn C++ but need to access a lot of C libs.
As the library provides a uiohook-config.cmake you should use that to link to the library via find_package rather than using find_library.
Something like this should work:
set(CMAKE_PREFIX_PATH /Users/ahoehne/libuiohook/dist/lib/cmake/uiohook/)
find_package(uiohook REQURIED)
target_link_libraries(libuihook_test uiohook)

Failed to build rtabmap_ros in my catkin_ws

I tried to build rtabmap_ros in my catkin_ws and I got this error:
user#user-desktop:~/catkin_ws$ catkin_make
Base path: /home/user/catkin_ws
Source space: /home/user/catkin_ws/src
Build space: /home/user/catkin_ws/build
Devel space: /home/user/catkin_ws/devel
Install space: /home/user/catkin_ws/install
####
#### Running command: "cmake /home/user/catkin_ws/src -DCATKIN_DEVEL_PREFIX=/home/user/catkin_ws/devel -DCMAKE_INSTALL_PREFIX=/home/user/catkin_ws/install -G Unix Makefiles" in "/home/user/catkin_ws/build"
####
-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Using CATKIN_DEVEL_PREFIX: /home/user/catkin_ws/devel
-- Using CMAKE_PREFIX_PATH: /home/user/catkin_ws/devel;/opt/ros/melodic
-- This workspace overlays: /home/user/catkin_ws/devel;/opt/ros/melodic
-- Found PythonInterp: /usr/bin/python2 (found suitable version "2.7.17", minimum required is "2")
-- Using PYTHON_EXECUTABLE: /usr/bin/python2
-- Using Debian Python package layout
-- Using empy: /usr/bin/empy
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /home/user/catkin_ws/build/test_results
-- Found gtest sources under '/usr/src/googletest': gtests will be built
-- Found gmock sources under '/usr/src/googletest': gmock will be built
-- Found PythonInterp: /usr/bin/python2 (found version "2.7.17")
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Using Python nosetests: /usr/bin/nosetests-2.7
-- catkin 0.7.29
-- BUILD_SHARED_LIBS is on
-- BUILD_SHARED_LIBS is on
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- ~~ traversing 1 packages in topological order:
-- ~~ - rtabmap_ros
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- +++ processing catkin package: 'rtabmap_ros'
-- ==> add_subdirectory(rtabmap_ros)
-- Using these message generators: gencpp;geneus;genlisp;gennodejs;genpy
CMake Warning at rtabmap_ros/CMakeLists.txt:31 (find_package):
By not providing "Findfiducial_msgs.cmake" in CMAKE_MODULE_PATH this
project has asked CMake to find a package configuration file provided by
"fiducial_msgs", but CMake did not find one.
Could not find a package configuration file provided by "fiducial_msgs"
with any of the following names:
fiducial_msgsConfig.cmake
fiducial_msgs-config.cmake
Add the installation prefix of "fiducial_msgs" to CMAKE_PREFIX_PATH or set
"fiducial_msgs_DIR" to a directory containing one of the above files. If
"fiducial_msgs" provides a separate development package or SDK, be sure it
has been installed.
-- Found RTABMap: /opt/ros/melodic/lib/librtabmap_core.so;/opt/ros/melodic/lib/librtabmap_utilite.so;/opt/ros/melodic/lib/librtabmap_gui.so;/usr/lib/aarch64-linux-gnu/libz.so;/opt/ros/melodic/lib/libg2o_core.so;/opt/ros/melodic/lib/libg2o_types_slam2d.so;/opt/ros/melodic/lib/libg2o_types_slam3d.so;/opt/ros/melodic/lib/libg2o_types_sba.so;/opt/ros/melodic/lib/libg2o_stuff.so;/opt/ros/melodic/lib/libg2o_solver_csparse.so;/opt/ros/melodic/lib/libg2o_csparse_extension.so;/usr/lib/aarch64-linux-gnu/libcxsparse.so;/opt/ros/melodic/lib/libg2o_solver_cholmod.so;/usr/lib/aarch64-linux-gnu/libcholmod.so;/usr/lib/aarch64-linux-gnu/libfreenect.so;/usr/lib/aarch64-linux-gnu/libfreenect_sync.so;/usr/lib/libOpenNI2.so;/usr/lib/aarch64-linux-gnu/libdc1394.so;/opt/ros/melodic/lib/liboctomap.so;/opt/ros/melodic/lib/liboctomath.so (Required is at least version "0.20.18")
-- Checking for module 'eigen3'
-- Found eigen3, version 3.3.4
-- Found eigen: /usr/include/eigen3
-- Checking for module 'libopenni'
-- Found libopenni, version 1.5.4.0
-- Found openni: /usr/lib/libOpenNI.so
-- The imported target "vtkGUISupportQt" references the file
"/usr/lib/aarch64-linux-gnu/libvtkGUISupportQt-6.3.so.6.3.0"
but this file does not exist. Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
"/usr/lib/cmake/vtk-6.3/VTKTargets.cmake"
but not all the files it references.
-- The imported target "vtkGUISupportQtOpenGL" references the file
"/usr/lib/aarch64-linux-gnu/libvtkGUISupportQtOpenGL-6.3.so.6.3.0"
but this file does not exist. Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
"/usr/lib/cmake/vtk-6.3/VTKTargets.cmake"
but not all the files it references.
-- The imported target "vtkGUISupportQtSQL" references the file
"/usr/lib/aarch64-linux-gnu/libvtkGUISupportQtSQL-6.3.so.6.3.0"
but this file does not exist. Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
"/usr/lib/cmake/vtk-6.3/VTKTargets.cmake"
but not all the files it references.
-- The imported target "vtkViewsQt" references the file
"/usr/lib/aarch64-linux-gnu/libvtkViewsQt-6.3.so.6.3.0"
but this file does not exist. Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
"/usr/lib/cmake/vtk-6.3/VTKTargets.cmake"
but not all the files it references.
-- The imported target "vtkGUISupportQtWebkit" references the file
"/usr/lib/aarch64-linux-gnu/libvtkGUISupportQtWebkit-6.3.so.6.3.0"
but this file does not exist. Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
"/usr/lib/cmake/vtk-6.3/VTKTargets.cmake"
but not all the files it references.
-- The imported target "vtkRenderingQt" references the file
"/usr/lib/aarch64-linux-gnu/libvtkRenderingQt-6.3.so.6.3.0"
but this file does not exist. Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
"/usr/lib/cmake/vtk-6.3/VTKTargets.cmake"
but not all the files it references.
-- The imported target "vtkRenderingQtTCL" references the file
"/usr/lib/aarch64-linux-gnu/libvtkRenderingQtTCL-6.3.so.6.3.0"
but this file does not exist. Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
"/usr/lib/cmake/vtk-6.3/VTKTargets.cmake"
but not all the files it references.
-- The imported target "vtkRenderingPythonTkWidgets" references the file
"/usr/lib/aarch64-linux-gnu/libvtkRenderingPythonTkWidgets.so"
but this file does not exist. Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
"/usr/lib/cmake/vtk-6.3/VTKTargets.cmake"
but not all the files it references.
-- The imported target "vtk" references the file
"/usr/bin/vtk"
but this file does not exist. Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
"/usr/lib/cmake/vtk-6.3/VTKTargets.cmake"
but not all the files it references.
-- The imported target "vtkRenderingQtPythonD" references the file
"/usr/lib/aarch64-linux-gnu/libvtkRenderingQtPython27D-6.3.so.6.3.0"
but this file does not exist. Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
"/usr/lib/cmake/vtk-6.3/VTKTargets.cmake"
but not all the files it references.
-- Found libusb-1.0: /usr/include
-- Checking for module 'flann'
-- Found flann, version 1.9.1
-- Found Flann: /usr/lib/aarch64-linux-gnu/libflann_cpp_s.a
-- Found qhull: /usr/lib/aarch64-linux-gnu/libqhull.so
-- Found PCL_COMMON: /usr/lib/aarch64-linux-gnu/libpcl_common.so
-- Found PCL_OCTREE: /usr/lib/aarch64-linux-gnu/libpcl_octree.so
-- Found PCL_IO: /usr/lib/aarch64-linux-gnu/libpcl_io.so
-- Found PCL_KDTREE: /usr/lib/aarch64-linux-gnu/libpcl_kdtree.so
-- Found PCL_SEARCH: /usr/lib/aarch64-linux-gnu/libpcl_search.so
-- Found PCL_SURFACE: /usr/lib/aarch64-linux-gnu/libpcl_surface.so
-- Found PCL_FILTERS: /usr/lib/aarch64-linux-gnu/libpcl_filters.so
-- Found PCL_2D: /usr/include/pcl-1.8
-- Found PCL_FEATURES: /usr/lib/aarch64-linux-gnu/libpcl_features.so
-- Found PCL_REGISTRATION: /usr/lib/aarch64-linux-gnu/libpcl_registration.so
-- Found PCL_SAMPLE_CONSENSUS: /usr/lib/aarch64-linux-gnu/libpcl_sample_consensus.so
-- Found PCL_GEOMETRY: /usr/include/pcl-1.8
-- Found PCL_ML: /usr/lib/aarch64-linux-gnu/libpcl_ml.so
-- Found PCL_SEGMENTATION: /usr/lib/aarch64-linux-gnu/libpcl_segmentation.so
-- Found PCL_VISUALIZATION: /usr/lib/aarch64-linux-gnu/libpcl_visualization.so
-- RTABMAP_SYNC_MULTI_RGBD = OFF
-- RTABMAP_SYNC_USER_DATA = OFF
-- rtabmap_ros: 18 messages, 16 services
-- WITH octomap_msgs
-- WITH apriltag_ros
-- WITH find_object_2d
-- checking for module 'OGRE'
-- found OGRE, version 1.9.0
-- WITH rviz
-- WITH costmap_2d
-- Configuring done
-- Generating done
-- Build files have been written to: /home/user/catkin_ws/build
####
#### Running command: "make -j4 -l4" in "/home/user/catkin_ws/build"
####
Scanning dependencies of target rtabmap_costmap_plugins
Scanning dependencies of target _rtabmap_ros_generate_messages_check_deps_Point2f
Scanning dependencies of target rtabmap_point_cloud_assembler
Scanning dependencies of target rtabmap_pointcloud_to_depthimage
make[2]: *** No rule to make target '/usr/lib/aarch64-linux-gnu/libvtkGUISupportQtOpenGL-6.3.so.6.3.0', needed by '/home/user/catkin_ws/devel/lib/rtabmap_ros/point_cloud_assembler'. Stop.
make[2]: *** Waiting for unfinished jobs....
[ 0%] Building CXX object rtabmap_ros/CMakeFiles/rtabmap_point_cloud_assembler.dir/src/PointCloudAssemblerNode.cpp.o
[ 0%] Built target _rtabmap_ros_generate_messages_check_deps_Point2f
make[2]: *** No rule to make target '/usr/lib/aarch64-linux-gnu/libvtkGUISupportQtOpenGL-6.3.so.6.3.0', needed by '/home/user/catkin_ws/devel/lib/rtabmap_ros/pointcloud_to_depthimage'. Stop.
make[2]: *** Waiting for unfinished jobs....
[ 0%] Building CXX object rtabmap_ros/CMakeFiles/rtabmap_pointcloud_to_depthimage.dir/src/PointCloudToDepthImageNode.cpp.o
[ 0%] Building CXX object rtabmap_ros/CMakeFiles/rtabmap_costmap_plugins.dir/src/costmap_2d/static_layer.cpp.o
Scanning dependencies of target _rtabmap_ros_generate_messages_check_deps_NodeData
[ 0%] Built target _rtabmap_ros_generate_messages_check_deps_NodeData
Scanning dependencies of target _rtabmap_ros_generate_messages_check_deps_GetMap
[ 0%] Built target _rtabmap_ros_generate_messages_check_deps_GetMap
Scanning dependencies of target sensor_msgs_generate_messages_cpp
[ 0%] Built target sensor_msgs_generate_messages_cpp
Scanning dependencies of target std_msgs_generate_messages_cpp
[ 0%] Built target std_msgs_generate_messages_cpp
Scanning dependencies of target _rtabmap_ros_generate_messages_check_deps_Info
[ 0%] Built target _rtabmap_ros_generate_messages_check_deps_Info
Scanning dependencies of target _rtabmap_ros_generate_messages_check_deps_GetPlan
[ 0%] Built target _rtabmap_ros_generate_messages_check_deps_GetPlan
Scanning dependencies of target _rtabmap_ros_generate_messages_check_deps_MapGraph
[ 0%] Built target _rtabmap_ros_generate_messages_check_deps_MapGraph
Scanning dependencies of target _rtabmap_ros_generate_messages_check_deps_RemoveLabel
[ 0%] Built target _rtabmap_ros_generate_messages_check_deps_RemoveLabel
Scanning dependencies of target _rtabmap_ros_generate_messages_check_deps_GetNodesInRadius
[ 0%] Built target _rtabmap_ros_generate_messages_check_deps_GetNodesInRadius
Scanning dependencies of target _rtabmap_ros_generate_messages_check_deps_SetLabel
[ 0%] Built target _rtabmap_ros_generate_messages_check_deps_SetLabel
Scanning dependencies of target _rtabmap_ros_generate_messages_check_deps_ScanDescriptor
[ 0%] Built target _rtabmap_ros_generate_messages_check_deps_ScanDescriptor
Scanning dependencies of target _rtabmap_ros_generate_messages_check_deps_MapData
[ 0%] Built target _rtabmap_ros_generate_messages_check_deps_MapData
Scanning dependencies of target _rtabmap_ros_generate_messages_check_deps_Path
[ 0%] Built target _rtabmap_ros_generate_messages_check_deps_Path
Scanning dependencies of target _rtabmap_ros_generate_messages_check_deps_PublishMap
[ 0%] Built target _rtabmap_ros_generate_messages_check_deps_PublishMap
Scanning dependencies of target _rtabmap_ros_generate_messages_check_deps_AddLink
[ 0%] Built target _rtabmap_ros_generate_messages_check_deps_AddLink
Scanning dependencies of target _rtabmap_ros_generate_messages_check_deps_DetectMoreLoopClosures
[ 0%] Built target _rtabmap_ros_generate_messages_check_deps_DetectMoreLoopClosures
Scanning dependencies of target _rtabmap_ros_generate_messages_check_deps_GPS
[ 0%] Built target _rtabmap_ros_generate_messages_check_deps_GPS
Scanning dependencies of target geometry_msgs_generate_messages_cpp
[ 0%] Built target geometry_msgs_generate_messages_cpp
Scanning dependencies of target _rtabmap_ros_generate_messages_check_deps_KeyPoint
[ 0%] Built target _rtabmap_ros_generate_messages_check_deps_KeyPoint
Scanning dependencies of target _rtabmap_ros_generate_messages_check_deps_OdomInfo
[ 0%] Built target _rtabmap_ros_generate_messages_check_deps_OdomInfo
Scanning dependencies of target _rtabmap_ros_generate_messages_check_deps_RGBDImages
CMakeFiles/Makefile2:706: recipe for target 'rtabmap_ros/CMakeFiles/rtabmap_point_cloud_assembler.dir/all' failed
make[1]: *** [rtabmap_ros/CMakeFiles/rtabmap_point_cloud_assembler.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 0%] Built target _rtabmap_ros_generate_messages_check_deps_RGBDImages
CMakeFiles/Makefile2:743: recipe for target 'rtabmap_ros/CMakeFiles/rtabmap_pointcloud_to_depthimage.dir/all' failed
make[1]: *** [rtabmap_ros/CMakeFiles/rtabmap_pointcloud_to_depthimage.dir/all] Error 2
[ 0%] Linking CXX shared library /home/user/catkin_ws/devel/lib/librtabmap_costmap_plugins.so
[ 0%] Built target rtabmap_costmap_plugins
Makefile:140: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j4 -l4" failed
I also have issues installing this particular library libvtkGUISupportQtOpenGL-6.3.so.6.3.0.
It seems that you need to install fiducial_msgs:
sudo apt-get install ros-noetic-fiducial-msgs

Cmake doesn't respect value of CMAKE_INSTALL_PREFIX

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

AttributeError: 'module' object has no attribute 'xfeatures2d' [python/opencv 3.1.0 dev]

To resolve this error I tried to add extra module opencv-contrib-master from https://github.com/opencv/opencv_contrib.git I followed the steps given in the readme.md file but while running 'make' I am getting the following output:
[ 4%] Built target libwebp
[ 4%] Built target opencv_core_pch_dephelp
[ 4%] Built target pch_Generate_opencv_core
Scanning dependencies of target opencv_core
[ 4%] Building CXX object modules/core/CMakeFiles/opencv_core.dir/src/system.cpp.o
Linking CXX shared library ../../lib/libopencv_core.so
[ 7%] Built target opencv_core
[ 7%] Built target opencv_ts_pch_dephelp
[ 7%] Built target pch_Generate_opencv_ts
[ 7%] Built target opencv_imgproc_pch_dephelp
[ 8%] Built target pch_Generate_opencv_imgproc
Linking CXX shared library ../../lib/libopencv_imgproc.so
[ 11%] Built target opencv_imgproc
[ 11%] Built target opencv_imgcodecs_pch_dephelp
[ 11%] Built target pch_Generate_opencv_imgcodecs
Linking CXX shared library ../../lib/libopencv_imgcodecs.so
[ 12%] Built target opencv_imgcodecs
[ 12%] Built target opencv_videoio_pch_dephelp
[ 12%] Built target pch_Generate_opencv_videoio
Linking CXX shared library ../../lib/libopencv_videoio.so
[ 13%] Built target opencv_videoio
[ 13%] Built target opencv_highgui_pch_dephelp
[ 13%] Built target pch_Generate_opencv_highgui
Linking CXX shared library ../../lib/libopencv_highgui.so
[ 14%] Built target opencv_highgui
[ 14%] Built target opencv_ts
[ 14%] Built target opencv_perf_core_pch_dephelp
[ 14%] Built target pch_Generate_opencv_perf_core
Linking CXX executable ../../bin/opencv_perf_core
[ 16%] Built target opencv_perf_core
[ 16%] Built target opencv_test_core_pch_dephelp
[ 16%] Generating test_precomp.hpp.gch/opencv_test_core_RELEASE.gch
In file included from <command-line>:0:0:
/usr/include/stdc-predef.h:1:0: fatal error: can’t create precompiled header /home/chandu/Opencv/opencv/release/modules/core/test_precomp.hpp.gch/opencv_test_core_RELEASE.gch: Permission denied
/* Copyright (C) 1991-2014 Free Software Foundation, Inc.
^
compilation terminated.
Preprocessed source stored into /tmp/cchn5Yvk.out file, please attach this to your bugreport.
ERROR: Cannot create report: [Errno 17] File exists: '/var/crash/_usr_lib_gcc_x86_64-linux-gnu_4.9_cc1plus.1000.crash'
make[2]: *** [modules/core/test_precomp.hpp.gch/opencv_test_core_RELEASE.gch] Error 1
make[1]: *** [modules/core/CMakeFiles/pch_Generate_opencv_test_core.dir/all] Error 2
make: *** [all] Error 2
Somewhere it was told that there may be problem in gcc version but I updated gcc version but no success. I am using gcc of version 4.9.4 and ubuntu of version 14.04.1. Before 'make' step I ran:
cmake -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules /usr/local .. -DWITH_IPP=OFF -DWITH_OPENGL=ON -DWITH_QT=ON -DBUILD_EXAMPLES=ON
I approached many resources but no results. Any kind of help is appreciable.
Did you tried prepending the command with sudo?
The problem is that xfeatures2d was not being exported from opencv-contrib module. So, when I was running 'make' command it was not able to add that module to opencv build module.
I ran the following command followed by make command:
export xfeatures2d=/path/to/opencv_contrib/modules/
It worked for me.

Linking and UIC order in a CMake Qt project

Talking about a Qt 5.3.2 project which is buildt using cmake.
This is a calling order problem between UIC execution and target_link_libraries... unfortunately not in that order.
Below this text you will find
1.) a (still functional) excerpt section of my CMakeLists.txt and
2.) an excerpt of the the output of the command 'cmake .'
3.) the output of a following call to 'make' without using the
generated headers like 'ui_main.h'.
If (in the source of my library libqt.a) I require 'ui_main.h' the
make process crashes not finding the header. Looking at the
non-crashing make output shows why:
[..]
Scanning dependencies of target qt
[ 29%] Building CXX object CMakeFiles/qt.dir/home/kochmn/projects/sentinel/src/qt/form_main.cpp.o
[ 35%] Building CXX object CMakeFiles/qt.dir/qt_automoc.cpp.o
Linking CXX static library libqt.a
[..]
[ 52%] Generating ui_main.h
[..]
Make would generate libqt.a before generating the required header file.
So I experimented using code like
target_link_libraries(sentinel
${Qt5Widgets_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5Core_LIBRARIES})
add_library(optimization "${DIR_SRC}/optimization/linalg.cpp")
add_library(qt "${DIR_SRC}/qt/form_main.cpp")
target_link_libraries(sentinel qt optimization)
to no avail. The question: How can I motivate cmake to first run UIC generating the ui-header files and then compiling my libqt.a?
Appendix
# 2.8.11 instead of 2.8 required for automatic linking to the qtmain.lib
# library if this ever should expand to Windows.
# (http://doc.qt.io/qt-5/cmake-manual.html)
cmake_minimum_required(VERSION 2.8.11)
project(sentinel)
set( CMAKE_AUTOMOC ON )
# CMake uses uic in order to generate header files from .ui forms from designer.
set ( CMAKE AUTOUIC ON )
# Auto-generating functions write their headers into the build directory.
# Hence the build directory should be included.
set( CMAKE_INCLUDE_CURRENT_DIR ON )
#> Getting the Qt essentials. ----------------------------------------
# Widgets finds its own dependencies (QtGui and QtCore).
find_package(Qt5Widgets REQUIRED)
message ("Found Qt5Widgets Version ${Qt5Widgets_VERSION_STRING}")
# All those darling variables are explained here:
# http://doc.qt.io/qt-5/cmake-manual.html
message("Core FOUND: ${Qt5Core_FOUND}")
message("Gui FOUND: ${Qt5Gui_FOUND}")
message("Widgets FOUND: ${Qt5Widgets_FOUND}")
message("Core VERSION: ${Qt5Core_VERSION_STRING}")
message("Gui VERSION: ${Qt5Gui_VERSION_STRING}")
message("Widgets VERSION: ${Qt5Widgets_VERSION_STRING}")
message("Core INCLUDE: ${Qt5Core_INCLUDE_DIRS}")
message("Gui INCLUDE: ${Qt5Gui_INCLUDE_DIRS}")
message("Widgets INCLUDE: ${Qt5Widgets_INCLUDE_DIRS}")
message("Core LIBRARIES: ${Qt5Core_LIBRARIES}")
message("Gui LIBRARIES: ${Qt5Gui_LIBRARIES}")
message("Widgets LIBRARIES: ${Qt5Widgets_LIBRARIES}")
message("Core DEFINITIONS: ${Qt5Core_DEFINITIONS}")
message("Gui DEFINITIONS: ${Qt5Gui_DEFINITIONS}")
message("Widgets DEFINITIONS: ${Qt5Widgets_DEFINITIONS}")
message("Core COMPILE_DEFINITIONS: ${Qt5Core_COMPILE_DEFINITIONS}")
message("Gui COMPILE_DEFINITIONS: ${Qt5Gui_COMPILE_DEFINITIONS}")
message("Widgets COMPILE_DEFINITIONS: ${Qt5Widgets_COMPILE_DEFINITIONS}")
message("Core EXECUTABLE_COMPILE_FLAGS: ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}")
message("Gui EXECUTABLE_COMPILE_FLAGS: ${Qt5Gui_EXECUTABLE_COMPILE_FLAGS}")
message("Widgets EXECUTABLE_COMPILE_FLAGS: ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")
include_directories(
${Qt5Widgets_INCLUDE_DIRS} ${Qt5Core_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS})
add_definitions(${Qt5Widgets_DEFINITIONS})
#add_definitions(${Qt5Core_DEFINITIONS}) # Unnecessary. In Widgets.
#add_definitions(${Qt5Gui_DEFINITIONS}) # Unnecessary. In Widgets.
#< -------------------------------------------------------------------
set (DEBUG 1)
set (SENTINEL_NAME "Sentinel GL")
set (SENTINEL_VERSION_MAJOR "0")
set (SENTINEL_VERSION_MINOR "1")
set (SENTINEL_VERSION "${SENTINEL_VERSION_MAJOR}.${SENTINEL_VERSION_MINOR}")
## Compiler flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")
# ${Qt5Core_EXECUTABLE_COMPILE_FLAGS} ${Qt5Gui_EXECUTABLE_COMPILE_FLAGS} #<-- redundant.
if(CMAKE_COMPILER_IS_GNUCXX)
message("Using GnuCXX compiler.")
add_definitions("-O0 -std=c++0x -lSOIL -llapacke -lblas")
endif()
if (DEBUG MATCHES 1)
message("\nBuilding DEBUG build.")
add_definitions(-Wall)
set(CMAKE_BUILD_TYPE Debug)
endif()
set(DIR_BASE "${PROJECT_SOURCE_DIR}/..")
set(DIR_SRC "${PROJECT_SOURCE_DIR}/../src")
set(DIR_RES "${PROJECT_SOURCE_DIR}/../resources")
set(DIR_BUILD "${PROJECT_SOURCE_DIR}/../build")
# Generated using uic FormMain.ui > ui_FormMain.h
set(qt_H
"${DIR_BUILD}/ui_main.h" "${DIR_BUILD}/ui_dialog_setup_game.h")
# Generated using the trusty QtDesigner.
set(qt_UI
"${DIR_SRC}/ui/main.ui" "${DIR_SRC}/ui/dialog_setup_game.ui")
# My own hand-written XML describing the internal resources.
set(qt_QRC "${DIR_RES}/application.qrc")
# generate rules for building source files that moc generates
QT5_WRAP_CPP(qt_H_MOC ${qt_H})
# generate rules for building header files from the ui files
QT5_WRAP_UI(qt_UI_H ${qt_UI})
# Resource Handling. QRC: "Qt Resource Collection"
QT5_ADD_RESOURCES(qt_RCCS ${qt_QRC})
# btw.: rcc generates a C program from ./resources/application.qrc
# However, this is not needed. cmake sees to that. :-)
#< -------------------------------------------------------------------
include_directories("${DIR_SRC}/include" "${PROJECT_SOURCE_DIR}")
add_executable(sentinel "${DIR_SRC}/sentinel.cpp" ${qt_H_MOC} ${qt_UI_H} ${qt_RCCS})
# Available modules are listed here: http://doc.qt.io/qt-5/qtmodules.html
# find /usr/lib/x86_64-linux-gnu/cmake -iname "*.cmake*" | less
# Note: http://stackoverflow.com/questions/20266235/cmake-error-qglwidget-no-such-file-or-directory
qt5_use_modules(sentinel Widgets Gui Core)
add_library(optimization "${DIR_SRC}/optimization/linalg.cpp")
add_library(qt "${DIR_SRC}/qt/form_main.cpp")
target_link_libraries(sentinel
${Qt5Widgets_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5Core_LIBRARIES}
qt optimization
)
kochmn#Ulyss:~/projects/sentinel/build$ cmake .
-- The C compiler identification is GNU 4.9.2
-- The CXX compiler identification is GNU 4.9.2
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
Found Qt5Widgets Version 5.3.2
Core FOUND: 1
Gui FOUND: 1
Widgets FOUND: 1
Core VERSION: 5.3.2
Gui VERSION: 5.3.2
Widgets VERSION: 5.3.2
Core INCLUDE: /usr/include/x86_64-linux-gnu/qt5/;/usr/include/x86_64-linux-gnu/qt5/QtCore;/usr/lib/x86_64-linux-gnu/qt5//mkspecs/linux-g++-64
Gui INCLUDE: /usr/include/x86_64-linux-gnu/qt5/;/usr/include/x86_64-linux-gnu/qt5/QtGui;/usr/include/x86_64-linux-gnu/qt5/QtCore;/usr/lib/x86_64-linux-gnu/qt5//mkspecs/linux-g++-64
Widgets INCLUDE: /usr/include/x86_64-linux-gnu/qt5/;/usr/include/x86_64-linux-gnu/qt5/QtWidgets;/usr/include/x86_64-linux-gnu/qt5/QtGui;/usr/include/x86_64-linux-gnu/qt5/QtCore;/usr/lib/x86_64-linux-gnu/qt5//mkspecs/linux-g++-64
Core LIBRARIES: Qt5::Core
Gui LIBRARIES: Qt5::Gui
Widgets LIBRARIES: Qt5::Widgets
Core DEFINITIONS: -DQT_CORE_LIB
Gui DEFINITIONS: -DQT_GUI_LIB;-DQT_CORE_LIB
Widgets DEFINITIONS: -DQT_WIDGETS_LIB;-DQT_GUI_LIB;-DQT_CORE_LIB
Core COMPILE_DEFINITIONS: QT_CORE_LIB
Gui COMPILE_DEFINITIONS: QT_GUI_LIB;QT_CORE_LIB
Widgets COMPILE_DEFINITIONS: QT_WIDGETS_LIB;QT_GUI_LIB;QT_CORE_LIB
Core EXECUTABLE_COMPILE_FLAGS: -fPIE
Gui EXECUTABLE_COMPILE_FLAGS: -fPIE
Widgets EXECUTABLE_COMPILE_FLAGS: -fPIE
Using GnuCXX compiler.
Building DEBUG build.
Sentinel GL -- C++ Project V 0.1.
(c) Markus-Hermann Koch, mhk#markuskoch.eu, 2015/04/28-?
Primary directory is /home/kochmn/projects/sentinel/build
System is Linux
Generating configuration header: "/home/kochmn/projects/sentinel/build/../build/mhk_cmake_config.h"
-- Configuring done
-- Generating done
-- Build files have been written to: /home/kochmn/projects/sentinel/build
kochmn#Ulyss:~/projects/sentinel/build$ make
Scanning dependencies of target optimization_automoc
[ 5%] Automatic moc for target optimization
[ 5%] Built target optimization_automoc
Scanning dependencies of target optimization
[ 11%] Building CXX object CMakeFiles/optimization.dir/home/kochmn/projects/sentinel/src/optimization/linalg.cpp.o
[ 17%] Building CXX object CMakeFiles/optimization.dir/optimization_automoc.cpp.o
Linking CXX static library liboptimization.a
[ 17%] Built target optimization
Scanning dependencies of target qt_automoc
[ 23%] Automatic moc for target qt
[ 23%] Built target qt_automoc
Scanning dependencies of target qt
[ 29%] Building CXX object CMakeFiles/qt.dir/home/kochmn/projects/sentinel/src/qt/form_main.cpp.o
[ 35%] Building CXX object CMakeFiles/qt.dir/qt_automoc.cpp.o
Linking CXX static library libqt.a
[ 35%] Built target qt
Scanning dependencies of target sentinel_automoc
[ 41%] Automatic moc for target sentinel
[ 41%] Built target sentinel_automoc
[ 47%] Generating qrc_application.cpp
[ 52%] Generating ui_main.h
[ 58%] Generating moc_ui_main.cpp
/home/kochmn/projects/sentinel/build/ui_main.h:0: Note: No relevant classes found. No output generated.
[ 64%] Generating ui_dialog_setup_game.h
[ 70%] Generating moc_ui_dialog_setup_game.cpp
/home/kochmn/projects/sentinel/build/ui_dialog_setup_game.h:0: Note: No relevant classes found. No output generated.
Scanning dependencies of target sentinel
[ 76%] Building CXX object CMakeFiles/sentinel.dir/home/kochmn/projects/sentinel/src/sentinel.cpp.o
[ 82%] Building CXX object CMakeFiles/sentinel.dir/moc_ui_main.cpp.o
[ 88%] Building CXX object CMakeFiles/sentinel.dir/moc_ui_dialog_setup_game.cpp.o
[ 94%] Building CXX object CMakeFiles/sentinel.dir/qrc_application.cpp.o
[100%] Building CXX object CMakeFiles/sentinel.dir/sentinel_automoc.cpp.o
Linking CXX executable sentinel
[100%] Built target sentinel
CMake generation order is computed from dependencies between files and targets. If your qt library depends on headers generated from .ui files, then you have to add ${qt_UI_H} in inputs of target qt:
QT5_WRAP_UI(qt_UI_H ${qt_UI})
[...]
add_library(qt "${DIR_SRC}/qt/form_main.cpp" ${qt_UI_H})
And CMake should normally execute UIC on .ui files before compiling libqt
By the way using target_link_libraries only set dependencies between targets at link time. At compile time, the normal behavior is "All source files should be found". In your case, some headers are generated, so setting these headers as input of a target ensures that the macro which generates them (QT5_WRAP_UI) will be executed before the compilation of the target.