gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-28 01:47:04 25 4
gpt4 key购买 nike

我有一个带有以下源代码的 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 是否有任何错误可以解释错误?

最佳答案

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

在这种情况下,.LIB 文件将从 ../../installed_mongocxx/lib 获取,但 .DLL 可能不是。 DLL 将在运行时根据 Windows 规则找到。

关于C++ 可执行文件继续寻找序号入口点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44635373/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com