Segmentation fault on Slam initialization
I got Segmentation fault in mini project. libLidarSlam.so I got from ROS2 wrapper (in ~/work/ROS2_slam/install/lidar_slam/lib)
gdb
(gdb) ba#0 0x00007ffff7eabab0 in LidarSlam::Slam::Slam()
() from /home/user/work/research/kw/lidarSlam/lib_x86_64/libLidarSlam.so
#1 (closed) 0x0000555555558d0f in main ()
c++ version
Using built-in specs. COLLECT_GCC=c++ COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/12/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu 12.1.0-2ubuntu1~22.04' --with-bugurl=file:///usr/share/doc/gcc-12/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-12 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-12-sZcx2y/gcc-12-12.1.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-12-sZcx2y/gcc-12-12.1.0/debian/tmp-gcn/usr --enable-offload-defaulted --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 12.1.0 (Ubuntu 12.1.0-2ubuntu1~22.04)
kw.cpp
#include "LidarSlam/Slam.h"
int main(int argc, char **argv)
{
std::unique_ptr
LidarSlam::Slam
slam {std::make_unique
LidarSlam::Slam
()};
return EXIT_SUCCESS;
}
CMakeLists.txt
CMAKE_MINIMUM_REQUIRED(VERSION 3.5)
PROJECT(kw)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR})
find_package(PCL REQUIRED COMPONENTS common)
include_directories(${PCL_INCLUDE_DIRS} "lidarSlam/include")
link_directories("lidarSlam/lib_x86_64")
add_executable(${PROJECT_NAME} "kw.cpp")
target_link_libraries(${PROJECT_NAME} "LidarSlam")
target_link_options(
{PROJECT_NAME} PRIVATE -Wl,-rpath,
{SLAM_LIBRARY_DIR})
build.sh
#!/bin/bash
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
cmake --build . -j
cd ..
Project structure
kw└─
build
└─
lidarSlam
`└─`include
`└─`LidarSlam
`└─`\*.h
`└─`lib_x86_64
`└─`libLidarSlam.so
└─
CMakeLists.txt
└─
build.sh
└─
kw.cpp