问题
我正在使用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;
}
我有一种感觉,问题出在我的第一行的#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
。我发现在Windows 10
上,使用mingw
编译和运行时,将_WIN32_WINNT _WIN32_WINNT_WIN7
(0x0601)和NTDDI_VERSION NTDDI_WIN7
都可以正常工作。 - kenba#define _WIN32_WINNT 0x0602
和#define NTDDI_VERSION NTDDI_WIN8
,但遗憾的是没有起到作用。 - Kirill Daybov