Mingw、boost 和运行时 "procedure entry point could not be located"

Mingw, boost, and runtime "procedure entry point could not be located"

问题

我正在使用 mingw 在 Windows 上使用 websocketpp 制作一个简单的服务器应用程序。我得到了我的代码编译和 link 成功。但是,当我启动应用程序时,出现以下错误 window:

The procedure entry point _ZNSt6chrono3_V212steady_clock3nowEv could not be located in the DLL D:\work\wild_web\a.exe

我的设置

以下是我的编译方式和link我的代码:

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

这就是我构建 boost 的方式:

b2 --build-dir=build-directory toolset=gcc --build-type=complete stage

main.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;
}

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

error: '::VerSetConditionMask' has not been declared
const uint64_t condition_mask = ::VerSetConditionMask(

问题

  1. #define _WIN32_WINNT 0x0501 是否打乱了 boost 库的使用?
  2. 我 link 提升正确吗?
  3. 如果对 1 和 2 的回答是肯定的,那么我该怎么做才能完成这项工作?

我解决了这个问题。

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

将 .exe 移动到包含 MinGW 库的文件夹中就可以了。但我还发现有一个编译器标志 -static-libstdc++ 可以用于 link 由 libstd++6 静态提供的函数。