Category : dlopen

I wrote the code below, std::unordered_map<std::string_view, std::any> symbols_; symbols_["foo"] = dlsym(handle_), "foo"); When i use any_cast return (std::any_cast<void(*)()>(symbols_["foo"]))();, the program will throw a error: bad any_cast. I found the main reason because of the function . template<typename _Tp> void* __any_caster(const any* __any) It would judge the condition as false and then return nullptr. else if ..

Read more

I have the following setup: prog -> dynamically links to library A (version 1) -> loads plugin library at runtime (via dlopen) plugin -> statically links to library A (version 2) I load the plugin library at runtime into prog with dlopen and import my test function lib2(): void * soPlugin = dlopen( "libplugin.so", RTLD_NOW|RTLD_LOCAL ..

Read more

For some reason, I can not set $LD_LIBRARY_PATH to global env. I try to set it up in golang code use os.Setenv. os.Setenv("LD_LIBRARY_PATH", my_library_paths) lib := C.dlopen(C.CString(libpath), C.RTLD_LAZY) I use another C++ function to get $LD_LIBRARY_PATH, it shows corretly. But lib returns ‘<nil>’, and C.dlerror() shows >> %!(EXTRA string=libhasp_linux_x86_64_demo.so: cannot open shared object file: No ..

Read more

I am trying to use the prebuilt tensorflow c-api with a cpp-wrapper in my package. Unfortunately I am getting a segfault error. After searching I found out that there is a Git Issue about it: Linking to both tensorflow and protobuf causes segmentation fault during static initializers. So I could resolve the Issues by doing: ..

Read more

I’m trying to compile a code with cmake and get this error (I’m pretty new with cmake): /usr/bin/ld: cannot find -lMPC Here is my CMakeLists.txt file: cmake_minimum_required(VERSION 3.0.2) project(PX4Vision_AutonomousLanding) find_package(catkin REQUIRED COMPONENTS roscpp nav_msgs geometry_msgs mavros_msgs ) include_directories( ${catkin_INCLUDE_DIRS} ) catkin_package( CATKIN_DEPENDS roscpp nav_msgs geometry_msgs mavros_msgs ) add_executable(offboard_node src/offboard_node.cpp ) target_link_libraries(offboard_node MPC ${CMAKE_DL_LIBS} ${catkin_LIBRARIES} ) ..

Read more