I'm trying to build a project with arUco.
I am using openCV v.3.1, which apparently includes aruco. However, I get the error:
opencv2/aruco/dictionary.hpp: No such file or directory
#include "opencv2/aruco/dictionary.hpp"
^
I then downloaded arUco, built it, and tried to build the example described at the bottom of http://www.uco.es/investiga/grupos/ava/node/26 . I get the error:
fatal error: aruco/aruco.h: No such file or directory
#include <aruco/aruco.h>
^
The CMakeLists.txt used is:
cmake_minimum_required(VERSION 2.8)
project(aruco_testproject)
SET(CMAKE_MODULE_PATH ${CMAKE_INSTALL_PREFIX}/lib/cmake/ )
MESSAGE(${CMAKE_MODULE_PATH})
find_package(aruco REQUIRED )
add_executable(aruco_simple aruco_simple.cpp)
target_link_libraries(aruco_simple ${aruco_LIBS})
I've copied Findaruco.cmake to /usr/local/lib/cmake/
If anyone could help, that'd be fantastic. I've been looking for a solution for a while and I feel really stuck. Thanks a lot!
You are missing the include_directories stanza. Also I think the correct variable name suffix for the library should be _LIBRARIES, not _LIBS, but afaik, cmake is unable to enforce any rule with rogue cmake modules, so the best bet is probably to try several common suffixes. That's one of cmake's atrocities.
cmake_minimum_required(VERSION 2.8)
project(aruco_testproject)
SET(CMAKE_MODULE_PATH ${CMAKE_INSTALL_PREFIX}/lib/cmake/ )
MESSAGE(${CMAKE_MODULE_PATH})
find_package(aruco REQUIRED )
add_executable(aruco_simple aruco_simple.cpp)
include_directories(${ARUCO_INCLUDE_DIR} ${ARUCO_INCLUDE_DIRS})
target_link_libraries(aruco_simple ${ARUCO_LIBRARY} ${ARUCO_LIBRARIES})
For the header inclusion, #include <aruco/aruco.h> looks fine, but not #include "opencv2/aruco/xxx".
Related
I have been trying to get one my older projects to work which uses some OpenGL code. I am unable to produce a working executable. All that happens is, just by calling glfwInit(), is a segmentation fault:
My best guess is that it somehow doesnt use/find the glfw dll i am trying to use.
Let me explain my current setup:
I have installed glfw using msys2:
pacman -S mingw-w64-x86_64-glfw
I have created a glad header and source file
I wrote a simple cmake-file (which also used to work 2 years ago)
cmake_minimum_required(VERSION 3.23)
project(2DGameEngine)
find_package(glfw3 3.3 REQUIRED)
find_package(OpenGL REQUIRED)
set(CMAKE_CXX_STANDARD 23)
file(GLOB_RECURSE SRCS src/*.cpp src/*.c)
add_executable(2DGameEngine ${SRCS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wshadow")
target_link_libraries(2DGameEngine glfw)
target_link_libraries(2DGameEngine OpenGL::GL)
I used the simplest example I could find:
#include "glad.h"
#include <GLFW/glfw3.h>
#include <iostream>
int main()
{
// glfw: initialize and configure
// ------------------------------
if(!glfwInit()){
std::cout << "error" << std::endl;
exit(1);
}
return 0;
}
Yet I am unable to get rid of the segmentation fault when calling glfwInit(). I assume it has to do with some .dll missing but I have no idea how I could check this. I am very happy for any help.
0xc0000135 is the error you get when your Windows OS could not find a required dll when executing your program. There is a handy site that decodes these types of errors here: https://james.darpinian.com/decoder/?q=0xc0000135
Use this program: https://github.com/lucasg/Dependencies to figure out what dll can not be found and then put that dll in the same folder as the executable or edit your OS PATH environment variable to contain the folder which has that dll.
Here is a good article on how to set the OS PATH environment variable: https://www.computerhope.com/issues/ch000549.htm
There are several other options contained in this Microsoft document which explains how and where your OS searches for dlls: https://learn.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-search-order#search-order-for-desktop-applications
Hello I am developing CUDA C++ application. I would like to use CUDA interactive debugger in visual studio but cmake projects seem to be not supported (am I wrong?).
So I am trying to switch from cmake to visual studio project. Hovewer I run into strange problem.
Without any importanta changes in code I have error:
Severity Code Description Project File Line Suppression State
Error Multiple definition of '_ZN4cuda3__48pipelineILNS_3std3__48__detail12thread_scopeE2EE25__barrier_try_wait_parityERNS0_7barrierILS5_2ENS3_18__empty_completionEEEb' in 'x64/Debug/MainPassFunctions.cu.obj', first defined in 'x64/Debug/BiggerMainFunctions.cu.obj' CUDADebugB C:\Users\1\source\repos\CUDADebugB\CUDALINK 1
when I try to use function where argument is defined as :
cuda::pipeline< cuda::thread_scope_block>& pipeline
Begining of my cu file
#include "cuda_runtime.h"
#include <cstdint>
#include <cuda/pipeline>
#include <cooperative_groups.h>
#include <cuda_pipeline.h>
using namespace cooperative_groups;
in cmake project all worked well with cmake as below
cmake_minimum_required(VERSION 3.8 FATAL_ERROR)
project(hello LANGUAGES CXX CUDA)
enable_language(CUDA)
find_package(hdf5 CONFIG REQUIRED)
find_package(GTest CONFIG REQUIRED)
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -lineinfo -rdc=true -lcudadevrt")
set(CMAKE_CUDA_ARCHITECTURES 80)
add_executable(hello hello.cu )
include_directories(${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
target_link_libraries(${PROJECT_NAME} ${CUDA_LIBRARIES})
target_link_libraries(hello PRIVATE hdf5::hdf5-shared hdf5::hdf5_hl-shared hdf5::hdf5_cpp-shared hdf5::hdf5_hl_cpp-shared)
target_link_libraries(hello PRIVATE GTest::gmock GTest::gtest GTest::gmock_main GTest::gtest_main)
now my vs studio project settings
What i should change to make it work?
Answer by
rturrado solved the problem
"
It looks like you have two definitions for the same function, one in the MainPassFunctions object file, and the other in the BiggerMainFunctions object file."
So I just fused two files into one.
I am trying to launch a ROS project but I receive a very strange error: ‘boost::placeholders’ has not been declared.
I have the following settings:
Ubuntu 20.04
ROS Noetic
Boost 1.71
CMake -> cmake version 3.16.3
Below a sample of the error I receive in the terminal:
In file included from /opt/ros/noetic/include/ros/node_handle.h:34,
from /opt/ros/noetic/include/ros/ros.h:45,
/opt/ros/noetic/include/ros/publisher.h: In member function ‘boost::function<void(const boost::shared_ptr<ros::SubscriberLink>&)> ros::Publisher::getLastMessageCallback()’:
/opt/ros/noetic/include/ros/publisher.h:179:70: error: ‘boost::placeholders’ has not been declared
179 | return boost::bind(&Impl::pushLastMessage, impl_.get(), boost::placeholders::_1);
Below the file that seems to carry this error is reported:
template<class M, class T>
Subscriber subscribe(const std::string& topic, uint32_t queue_size, void(T::*fp)(M), T* obj,
const TransportHints& transport_hints = TransportHints())
{
SubscribeOptions ops;
ops.template initByFullCallbackType<M>(topic, queue_size, boost::bind(fp, obj, boost::placeholders::_1));
ops.transport_hints = transport_hints;
return subscribe(ops);
}
Following this source I can confirm I added C++14:
cmake_minimum_required(VERSION 2.8.3)
project(lidar_boat_detection)
set(CMAKE_BUILD_TYPE Debug)
add_compile_options(-std=c++14 -g)
find_package(PCL 1.8 REQUIRED)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
find_package(Boost REQUIRED COMPONENTS
system
filesystem
date_time
thread
)
find_package(catkin REQUIRED COMPONENTS
roscpp
pcl_conversions
pcl_ros
std_msgs
message_generation
)
Also I consulted this source and I added #include <boost/bind/bind.hpp> instead of #include <boost/bind.hpp> as per new directive and I added using namespace boost::placeholders;. However non of these solutions worked and another thing I tried was to add #include <boost/bind/placeholders.hpp> and that also didn't work:
#ifndef ROSCPP_PUBLISHER_HANDLE_H
#define ROSCPP_PUBLISHER_HANDLE_H
#include "ros/forwards.h"
#include "ros/common.h"
#include "ros/message.h"
#include "ros/serialization.h"
//#include <boost/bind.hpp>
#include <boost/bind/bind.hpp>
#include <boost/thread/mutex.hpp>
using namespace boost::placeholders;
namespace ros
{
class NodeHandleBackingCollection;
....
}
Always from the same post I tried to add the following line #define BOOST_BIND_NO_PLACEHOLDERS at the beginning of the file but that also didn't work:
#ifndef ROSCPP_PUBLISHER_HANDLE_H
#define ROSCPP_PUBLISHER_HANDLE_H
#define BOOST_BIND_NO_PLACEHOLDERS
#include "ros/forwards.h"
#include "ros/common.h"
#include "ros/message.h"
#include "ros/serialization.h"
//#include <boost/bind.hpp>
#include <boost/bind/bind.hpp>
#include <boost/thread/mutex.hpp>
using namespace boost::placeholders;
namespace ros
{
class NodeHandleBackingCollection;
....
}
I dug more and come across this post but unfortunately it was not useful to solve the problem.
This question would have been useful is a proper answer would have been provided as this is extremely close to the problem I have.
EDITS
Creating Package: template_package_msgs
-- Using these message generators: gencpp;geneus;genlisp;gennodejs;genpy
CMake Error at /usr/lib/x86_64-linux-gnu/cmake/Boost-1.71.0/BoostConfig.cmake:117 (find_package):
Could not find a package configuration file provided by "boost_bind"
(requested version 1.71.0) with any of the following names:
boost_bindConfig.cmake
boost_bind-config.cmake
Add the installation prefix of "boost_bind" to CMAKE_PREFIX_PATH or set
"boost_bind_DIR" to a directory containing one of the above files. If
"boost_bind" provides a separate development package or SDK, be sure it has
been installed.
Call Stack (most recent call first):
/usr/lib/x86_64-linux-gnu/cmake/Boost-1.71.0/BoostConfig.cmake:182 (boost_find_component)
/usr/share/cmake-3.16/Modules/FindBoost.cmake:443 (find_package)
template_package/template_package_msgs/CMakeLists.txt:9 (find_package)
-- Configuring incomplete, errors occurred!
See also "/home/emanuele/sonar_ws/build/CMakeFiles/CMakeOutput.log".
See also "/home/emanuele/sonar_ws/build/CMakeFiles/CMakeError.log"
I am running out of ideas on how to solve it. Thanks for pointing in the right direction for solving this issue.
There was a recent improvement to Boost Bind, see Why boost::bind insists pulling `boost::placeholders` into global namespace?
It looks like you want to define BOOST_BIND_GLOBAL_PLACEHOLDERS unless you want to update the calling code. Check that BOOST_BIND_NO_PLACEHOLDERS is not defined
I have trouble replicating your exact problem on my system. If I clone your minimal example from your Bitbucket but leave the line add_definitions(-DBOOST_BIND_NO_PLACEHOLDERS) in the CMakeLists.txt then it gives me the same error you got but if I remove it I do not have these issues and it compiles fine. If this error persists on your system even though you remove this line, the only plausible reason that I can come up with is that for some obscure reason some other package in your workspace or ROS itself adds this definition which makes the compilation of your package then fail. I would actually try to make a new workspace (or put CATKIN_IGNORE files into the other packages in your workspace and then $ catkin clean the workspace followed by $ catkin build) and see if it still occurs with your Bitbucket code as the only package in your workspace. If it compiles keep adding the packages until you find out which of your other packages might be causing it. If it does not then the only way of solving this dilemma that comes to my mind is adding the line
#undef BOOST_BIND_NO_PLACEHOLDERS
to the top of your two .cpp files talker.cpp and subscriber.cpp (before actually including ros/ros.h). This might though lead to problems when combining it with code that relies on BOOST_BIND_NO_PLACEHOLDERS. In order to reduce the chances of it breaking your code do not add it to header files as then it might leak into code including your header file.
I'm new to CMake and after a week of endless errors I'm at my wit's end.
main.cpp
#include <tox/tox.h>
int main(int argc, char **argv) {
Tox* tox = tox_new(NULL, NULL);
return 0;
}
CMakeLists.txt
cmake_minimum_required(VERSION 3.18)
Project(toxtest)
add_library(toxcore SHARED IMPORTED)
set_target_properties(toxcore PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR}/c-toxcore/include"
IMPORTED_IMPLIB "${CMAKE_SOURCE_DIR}/c-toxcore/_build/Debug/toxcore.lib"
IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/c-toxcore/_build/Debug/toxcore.dll"
)
set(BINARY_NAME "toxtest-bin")
add_executable(${BINARY_NAME} main.cpp)
target_link_libraries(${BINARY_NAME} PUBLIC toxcore)
Introduction:
My C++ executable depends on a C-library called toxcore, toxcore depends on two other C-libraries called pthread-win32 and libsodium.
I have compiled the toxcore library with the following flags, to solve a unresolved external symbol error (Not sure if this is the right way):
cmake .. -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=TRUE -DBUILD_SHARED_LIBS=TRUE
I build my executable successfully but now it complains about missing DLL's:
toxcore.dll, libsodium.dll, pthreadVC2.dll
With my patience running out:
I dumped the DLL's into the directory with the executable, and now I got Application Error:
The application was unable to start correctly (0xc000007b)
How do I this properly?
I want to solve the Application Error, and let the executable find the DLL's in their respective directories.
PS: Before anyone marks my question as duplicate.
I have looked thru and tried stackoverflow answers which were not sufficient in detail/clarity for a beginner like me. I need someone to give me a more tailored answer and tell me if my steps are in line with the current best practices.
After digging for hours on this, I finally need some expert help.
I am new to cmake and trying to port my Visual Studio 2008 project to cmake.
My project uses opencv, qt and boost libraries.
Now I have managed to run simple cmake examples with opencv and qt but I am stuck with boost.
The bottleneck is this: CMake finds the correct boost version, finds the libraries and gives no error while configuration.
But when I try to build the project using make, it gives me:
" fatal error: boost/smart_ptr.hpp: No such file or directory"
Assuming the configuration is done right, cmake should be able to find the boost include directories.
I have set BOOST_ROOT to the correct boost root directory and that's why configuration does not give errors. But what happens while running make? Am I missing something simple here? Need help desperately...
I am sorry if this is a stupid question.
Here's my CMakeLists.txt file:
cmake_minimum_required( VERSION 2.6 )
project (CMakeBoostTutorial)
find_package( Boost 1.46.1 COMPONENTS date_time REQUIRED)
link_directories ( ${Boost_LIBRARY_DIRS} )
include_directories ( ${Boost_INCLUDE_DIRS} )
add_executable ( helloworld helloworld.cc )
target_link_libraries (
helloworld
${Boost_LIBRARIES}
)
And here's my helloworld.cc:
#include <iostream>
#include <stdlib.h>
#include <boost/smart_ptr.hpp>
using namespace std;<br/>
int main(int argc, char *argv[]){
cout<<"Hello World";
return 0;
}
PS: This compiles and runs fine if I remove the #include <boost/smart_ptr.hpp> line