Compiling Boost example projects with Cygwin + gcc

无人久伴 提交于 2020-01-04 09:19:29

问题


While trying to compile the boost asio example project async_tcp_echo_server.cpp

I get errors like the following:

__MSABI_LONG was not declared in this file scope
BOOST_ASIO_NATIVE_ERROR(ERROR_BROKEN_PIPE)

__MSABI_LONG was not declared in this file scope
BOOST_ASIO_NATIVE_ERROR(ERROR_OPERATION ABORTED)

This is with Boost 1.55.0 and gcc version 4.8.3

boost was compiled with gcc and the following commands

./bootstrap.sh
./b2 cxxflags="-D__USE_W32_SOCKETS -D_WIN32_WINNT=0x0501
./b2 install

I attempted to compile the sample project with

gcc -std=C++11 -D__USE_W32_SOCKETS -D_WIN32_WINNT=0x0501 -I C:\boost_1_55_0 C:\boost_1_55_0\boost\asio.hpp async_tcp_echo_server.cpp

回答1:


I know this is kind of old thread. I managed to fix it by reinstalling the boost lib via Cygwin setup_x86.exe. The version I installed is 1.57. And you don't have to put -D option in the command line. Hope this may help.




回答2:


1_57 version from cygwin setup doesn't help for me, it gives me fd_set errors.

This is what I tried to make the boost example code work:

  1. add #define __MSABI_LONG(x) x at the top. - chilly, I know :)
  2. add these flags to g++:-D_WIN32_WINNT=0x0501 -D__USE_W32_SOCKETS -std=c++11 -lboost_system -lws2_32

Voila!



来源:https://stackoverflow.com/questions/25115192/compiling-boost-example-projects-with-cygwin-gcc

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!