C++可执行文件继续寻找序号入口点



我有一个C++应用程序,源代码如下:

#include <cstdint>
#include <iostream>
#include <vector>
#include <bsoncxx/json.hpp>
#include <mongocxx/client.hpp>
#include <mongocxx/stdx.hpp>
#include <mongocxx/uri.hpp>
#include <mongocxx/client.hpp>
#include <mongocxx/instance.hpp>
using bsoncxx::builder::stream::close_array;
using bsoncxx::builder::stream::close_document;
using bsoncxx::builder::stream::document;
using bsoncxx::builder::stream::finalize;
using bsoncxx::builder::stream::open_array;
using bsoncxx::builder::stream::open_document;
int main(int argc, char** argv)
{
    std::cout << "nJust to be sure!" << std::endl;
    // Making a connection to Mongo
    mongocxx::instance instance{};
    mongocxx::client client{mongocxx::uri{}};
    // Access a database
    mongocxx::database db = client["results"];
    std::cout << "ndone." << std::endl;
    return 0;
}

我使用以下CMakeLists.txt文件编译它:

cmake_minimum_required(VERSION 3.7)
project(testing)
set(APP_SOURCES
    test.cpp
)
link_directories(../../installed_mongocxx/lib)
add_executable(testapp ${APP_SOURCES})
target_link_libraries(testapp mongocxx bsoncxx)
target_include_directories(testapp PUBLIC 
                            ../../installed_mongocxx/include/mongocxx/v_noabi
                            ../../installed_mongocxx/include/bsoncxx/v_noabi
                            E:/Softwares/Libraries/Boost/boost_1_64_0
)
install(TARGETS testapp 
        DESTINATION bin)

我在 Windows 10 64 位上使用 MSBuild 编译程序而没有错误,并且在运行时会出现此错误;

The ordinal 4694 could not be located in the dynamic library libmongoc-1.0.dll

C++代码或CMakeLists有什么问题.txt这可能是错误的解释吗?

这不太可能。问题是什么.用于链接 DLL 的 LIB 文件。当您构建 DLL 时,也会创建一个小的 .LIB 文件。这基本上只是一个目录。如果混合使用 .一个构建中的 LIB 文件与另一个构建中的.DLL,您可能会遇到不兼容的问题。

在本例中,.LIB文件将从../../installed_mongocxx/lib中获取,但.DLL可能不是。DLL将在运行时通过Windows规则找到。

我注意到你最近一直在问一些与使用 mongocxx 开发相关的问题,这些问题似乎都是相关的。我鼓励您在我们的mongodb用户Google群组或我们的Jira项目上提问,这将使我们更容易帮助您解决您可能遇到的任何后续问题,而无需在多个地方进行对话。

(很抱歉将此作为答案而不是评论发布;StackOverflow似乎对评论有长度限制,我无法将其放在一个中(

最新更新