Mingw, boost, and runtime “procedure entry point c

2019-07-22 21:01发布

问题:

Problem

I'm making a simple server app with websocketpp on Windows using mingw. I got my code to compile and link successfully. However, when I start the app it gives me the following error window:

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

My setup

Here's how I compile and link my code:

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

And this is how I build 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;
}

I have a feeling that the problem is in my #define on the first raw that could cause the change of the dll's interface. But if I remove it, code won't compile:

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

Questions

  1. Is #define _WIN32_WINNT 0x0501 messes up usage of the boost libraries?
  2. Am I linking to boost correctly?
  3. If answer to 1 and 2 is yes than what do I do to make this work?

回答1:

I got this resolved.

Using dependency walker I found out that the missing function was expected to be in the libstd++6.dll. Apparently I had two of those: one belonging to Windows and the other one provided by MinGW. And it looks like the Windows one was used when I run my app.

Moving the .exe into the folder with MinGW libs did the trick. But I also discovered that there's a compiler flag -static-libstdc++ you can use to link to the functions provided by the libstd++6 statically.