2016-07-24 107 views
2

問題

我正在使用mingw在Windows上使用websocketpp製作一個簡單的服務器應用程序。我有我的代碼編譯和鏈接成功。然而,當我啓動應用程序它給了我下面的錯誤窗口:Mingw,boost和運行時「程序入口點無法找到」

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 

而且我這是怎麼建提高:

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(

問題

  1. 是的#define _WIN32_WINNT 0x0501打亂了Boost庫的使用情況如何?
  2. 我鏈接到正確提升?
  3. 如果對1和2的回答是肯定的,那麼我該如何回答這個問題?
+0

'0x0501'用於'Windows XP'。它需要在'XP'上運行嗎?您必須將'_WIN32_WINNT'設置爲'boost:asio'。我發現'_WIN32_WINNT _WIN32_WINNT_WIN7'(0x0601)和'NTDDI_VERSION NTDDI_WIN7'可以在'Windows 10'上用'mingw'編譯和運行。 – kenba

+0

我在Windows 8上。嘗試了'#define _WIN32_WINNT 0x0602'和'#define NTDDI_VERSION NTDDI_WIN8',但不幸的是它沒有幫助。 –

回答

2

我得到了這個解決。

使用依賴關係walker我發現缺少的函數應該在libstd ++ 6.dll中。顯然我有兩個:一個屬於Windows,另一個屬於MinGW。它看起來像我運行我的應用程序時使用的Windows。

將.exe文件移動到MinGW庫的文件夾中就行了。但我也發現有一個編譯器標誌-static-libstdc++可以用來靜態鏈接到libstd ++ 6提供的函數。

相關問題