问题
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:
- add
#define __MSABI_LONG(x) x
at the top. - chilly, I know :) - 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