C++ executable keep looking for ordinal entry point

烈酒焚心 提交于 2019-12-25 08:38:51

问题


I have a C++ application with the below source code:

#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;
}

I compile it using the below CMakeLists.txt file:

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)

I compile the program using MSBuild on Windows 10 64bit without errors, and upon running it gives this error;

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

Is there anything wrong with the C++ code or CMakeLists.txt that could be explanation of the error?


回答1:


That's unlikely. The question is what .LIB file you're using to link the DLL. When you build a DLL, that also creates a small .LIB file. This is basically just a table of contents. If you mix the .LIB file from one build with the .DLL from another build, you may run into incompatibilities.

In this case, the .LIB file will be taken from ../../installed_mongocxx/lib, but the .DLL might not be. The DLL will be found at runtime, by Windows rules.




回答2:


I notice that you've been asking a number of questions related to developing with mongocxx lately that all seem related. I encourage you to either ask a question on our mongodb-user Google Group or on our Jira project, which will make it easier for us to assist you in any follow-up questions you might have without needing to have a conversation in multiple places.

(Apologies for posting this as an answer rather than a comment; StackOverflow seems to have a length limit on comments, and I couldn't fit this in one)



来源:https://stackoverflow.com/questions/44635373/c-executable-keep-looking-for-ordinal-entry-point

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!