【发布时间】: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(
问题
- #define _WIN32_WINNT 0x0501 是否会影响 boost 库的使用?
- 我是否正确链接到 boost?
- 如果对 1 和 2 的回答是肯定的,那么我该怎么做才能完成这项工作?
【问题讨论】:
-
0x0501用于Windows XP。它需要在XP上运行吗?您必须将_WIN32_WINNT设置为boost:asio。我发现_WIN32_WINNT _WIN32_WINNT_WIN7(0x0601) 和NTDDI_VERSION NTDDI_WIN7在Windows 10上使用mingw构建并运行良好。 -
我在 Windows 8 上。尝试了
#define _WIN32_WINNT 0x0602和#define NTDDI_VERSION NTDDI_WIN8,但很遗憾,它没有帮助。