Mingw、boost 和运行时“无法找到过程入口点”

Kir*_*bov 3 c++ boost mingw c++-chrono

问题

我正在使用 mingw 在 Windows 上使用 websocketpp 制作一个简单的服务器应用程序。我让我的代码编译和链接成功。但是,当我启动应用程序时,它给了我以下错误窗口:

The procedure entry point _ZNSt6chrono3_V212steady_clock3nowEv could not be located in the DLL D:\work\wild_web\a.exe
Run Code Online (Sandbox Code Playgroud)

我的设置

这是我编译和链接我的代码的方法:

g++ -std=c++11 -march=i686 d:/work/wild_web/main.cpp -o a.exe -ID:/work/libs/boost_1_61_0 -ID:/work/websocketpp-master/websocketpp-master -LD:/work/libs/boost_1_61_0/stage/lib -lboost_system-mgw49-mt-s-1_61 -lws2_32 -lwsock32 -lboost_chrono-mgw49-mt-s-1_61

Compilation finished at Sun Jul 24 16:48:09
Run Code Online (Sandbox Code Playgroud)

这就是我建立提升的方式:

b2 --build-dir=build-directory toolset=gcc --build-type=complete stage
Run Code Online (Sandbox Code Playgroud)

主.cpp:

#define _WIN32_WINNT 0x0501

#include <iostream>

#include <websocketpp/config/asio_no_tls.hpp>
#include <websocketpp/server.hpp>

#include <boost/chrono.hpp>

#include <string>
#include <sstream>
#include <vector>
#include <map>

//bunch of structs
int main() {
  //working with websocketpp
  return 0;
}
Run Code Online (Sandbox Code Playgroud)

我有一种感觉,问题出在我的第一个原始文件上的 #define 中,这可能会导致 dll 的接口发生变化。但是如果我删除它,代码将无法编译:

error: '::VerSetConditionMask' has not been declared
const uint64_t condition_mask = ::VerSetConditionMask(
Run Code Online (Sandbox Code Playgroud)

问题

  1. #define _WIN32_WINNT 0x0501 是否会干扰 boost 库的使用?
  2. 我是否正确链接到提升?
  3. 如果对 1 和 2 的回答是肯定的,那么我该怎么做才能使这项工作发挥作用?

Kir*_*bov 5

我解决了这个问题。

使用dependency walker,我发现缺少的函数应该在libstd++6.dll 中。显然我有两个:一个属于 Windows,另一个由 MinGW 提供。看起来我运行我的应用程序时使用的是 Windows 版本。

将 .exe 移动到带有 MinGW 库的文件夹中就可以了。但我也发现有一个编译器标志-static-libstdc++可以用来静态链接到 libstd++6 提供的函数。