【问题标题】:Mingw, boost, and runtime "procedure entry point could not be located"Mingw、boost 和运行时“找不到过程入口点”
【发布时间】:2016-07-24 17:49:05
【问题描述】:

问题

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

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

我的设置

这是我如何编译和链接我的代码:

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. 我是否正确链接到 boost?
  3. 如果对 1 和 2 的回答是肯定的,那么我该怎么做才能完成这项工作?

【问题讨论】:

  • 0x0501 用于Windows XP。它需要在XP 上运行吗?您必须将_WIN32_WINNT 设置为boost:asio。我发现_WIN32_WINNT _WIN32_WINNT_WIN7 (0x0601) 和NTDDI_VERSION NTDDI_WIN7Windows 10 上使用mingw 构建并运行良好。
  • 我在 Windows 8 上。尝试了 #define _WIN32_WINNT 0x0602#define NTDDI_VERSION NTDDI_WIN8,但很遗憾,它没有帮助。

标签: c++ boost mingw chrono


【解决方案1】:

我解决了这个问题。

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

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

【讨论】:

    猜你喜欢
    • 2021-08-10
    • 2018-07-08
    • 2014-01-18
    • 2015-04-13
    • 1970-01-01
    • 2021-06-01
    • 1970-01-01
    相关资源
    最近更新 更多