加载共享库时出错:libbsoncxx.so._noabi:无法打开共享库文件:没有这样的文件或目录 [英] Error while loading shared libraries: libbsoncxx.so._noabi: cannot open shared object file: No such file or directory

查看:869
本文介绍了加载共享库时出错:libbsoncxx.so._noabi:无法打开共享库文件:没有这样的文件或目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我安装了mongocxx驱动程序,如 http://mongodb.github.io/mongo-cxx-driver/mongocxx-v3/installation/和 当我测试驱动程序时,一切看起来都很好,但是如果更改一点代码,则在加载共享库时出现错误:libbsoncxx.so._noabi:无法打开共享对象文件:没有这样的文件或目录.

I installed the mongocxx driver, as shown by http://mongodb.github.io/mongo-cxx-driver/mongocxx-v3/installation/ and when I test driver everything looks fine, but if change a little code I get error while loading shared libraries: libbsoncxx.so._noabi: cannot open shared object file: No such file or directory.

代码:

CMakeLists.txt

cmake_minimum_required(VERSION 3.10)

if(POLICY CMP0025)
    cmake_policy(SET CMP0025 NEW)
endif()

project(test_mongodb LANGUAGES C CXX)

if(NOT DEFINED CMAKE_CXX_STANDARD)
    set(CMAKE_CXX_STANDARD 11)
endif()

set(CMAKE_PREFIX_PATH CMAKE_PREFIX_PATH "~/opt/mongo-cxx-driver/install")
set(CMAKE_CXX_EXTENSIONS OFF)

if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror")
endif()


add_executable(test_mongodb main.cpp)

find_package(libmongocxx REQUIRED)

target_include_directories(test_mongodb
        PRIVATE ${LIBMONGOCXX_INCLUDE_DIRS}
        )

target_link_libraries(test_mongodb
        PRIVATE ${LIBMONGOCXX_LIBRARIES}
        )

target_compile_definitions(test_mongodb
        PRIVATE ${LIBMONGOCXX_DEFINITIONS}
        )

add_custom_target(run
        COMMAND test_mongodb
        DEPENDS test_mongodb
        WORKING_DIRECTORY ${CMAKE_PROJECT_DIR}
        )

list(FIND LIBMONGOCXX_DEFINITIONS "BSONCXX_STATIC" LIST_IDX)
if (${LIST_IDX} GREATER -1)
    message(FATAL_ERROR "Expected BSONCXX_STATIC to not be defined")
endif()
list(FIND LIBMONGOCXX_DEFINITIONS "MONGOCXX_STATIC" LIST_IDX)
if (${LIST_IDX} GREATER -1)
    message(FATAL_ERROR "Expected MONGOCXX_STATIC to not be defined")
endif()

main.cpp

#include <iostream>

#include <bsoncxx/builder/stream/document.hpp>
#include <bsoncxx/json.hpp>

#include <mongocxx/client.hpp>
#include <mongocxx/instance.hpp>
#include <mongocxx/cursor.hpp>


int main(int argc, char* argv[]) {
    using bsoncxx::builder::basic::kvp;
    using bsoncxx::builder::basic::make_document;

    mongocxx::instance inst;

    try {
        const auto uri = mongocxx::uri{(argc >= 2) ? argv[1] : mongocxx::uri::k_default_uri};

        auto client = mongocxx::client{uri};
        auto admin = client["admin"];
        auto result = admin.run_command(make_document(kvp("isMaster", 1)));
        std::cout << bsoncxx::to_json(result) << std::endl;

        return EXIT_SUCCESS;
    } catch (const std::exception& xcp) {
        std::cout << "connection failed: " << xcp.what() << std::endl;
        return EXIT_FAILURE;
    }
}

如果我从代码中删除了auto result = admin.run_command(make_document(kvp("isMaster", 1)));,则在加载共享库libbsoncxx.so._noabi 时出现错误,如果无法正常运行.知道为什么它会那样吗?

If I remove auto result = admin.run_command(make_document(kvp("isMaster", 1))); from code i get error while loading shared libraries: libbsoncxx.so._noabi, if not works fine. Any idea why it behaves like that ?

Ubuntu 18.04 cc 7.3.0, C ++ 7.3.0, CMake 3.11.3

Ubuntu 18.04 cc 7.3.0, c++ 7.3.0, CMake 3.11.3

推荐答案

https://www.cnblogs.com/pluse/p/5491300.html 对于erros而言,reson是关于库链接的.只需重新链接库,如下所示就可以解决问题

https://www.cnblogs.com/pluse/p/5491300.html reson for erros is about the library link.Just relink the library like below will reslove the problem


    sudo ln -s /usr/local/lib/libmogocxx.so.3.4.0 libmongocxx.so._noabi
    sudo ln -s /usr/local/lib/libmongocxx.so._noabi /usr/local/lib/libmongocxx.so

这篇关于加载共享库时出错:libbsoncxx.so._noabi:无法打开共享库文件:没有这样的文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆