Cygwin 2.876 64bit - Boost 1.60 asio does not compile

Tommaso Fabbri t.fabbri@yahoo.com
Mon Oct 10 11:03:00 GMT 2016


> Il giorno 08/ott/2016, alle ore 00:55, Yaakov Selkowitz <yselkowitz@cygwin.com> ha scritto:
> 
> On 2016-10-07 10:19, Tommaso Fabbri wrote:
>> I have a Windows 10 system running the latest version of Cygwin 64 bit.
>> I’ve installed all the Boost libraries and cmake, make packages to develop
>> under Windows like on *nix systems.
>> When I try to compile a simple application including the boost-asio library
>> like the following, it fails.
>> 
>> #include <boost/asio.hpp>
>> int main(int argc, char**argv)
>> {
>>    return 0;
>> }
> 
> WFM, but then again you didn't tell us *how* were trying to compile it until...
> 
>> I report the stackoverflow discussion link:
>> http://stackoverflow.com/questions/39894006/how-to-use-boost-asio-library-with-cygwin-64-bit


Sorry for the missing parts. I attach here the cmakelists I used at the beginning:

cmake_minimum_required(VERSION 3.1)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
find_package(Boost REQUIRED COMPONENTS system)

add_executable(Test test_asio.cpp )

INCLUDE_DIRECTORIES ( ${Boost_INCLUDE_DIR} )
INCLUDE_DIRECTORIES ( /usr/include )
INCLUDE_DIRECTORIES ( ./ )

target_link_libraries(Test ${Boost_SYSTEM_LIBRARY})

Then I tried to add all the things found in discussions on the internet (__USE_W32_SOCKETS …), included the one I linked in the past mail.  

> 
> Which shows you're making several mistakes:
> 
> * -std=c++11; use -std=gnu++11 instead;

I have  to include the following change

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")

> 
> * -D__USE_W32_SOCKETS; winsock cannot be combined with Cygwin's *NIX socket APIs, so do NOT define this.  If you want a pure Windows build of this code without the Cygwin dependency, then use mingw64-*-boost with the mingw64 toolchains (and also link with -lws2_32);

I install mingw64 and I see what happens by adding -lws2_32. 

> 
> * not linking with -lboost_system;

target_link_libraries(Test ${Boost_SYSTEM_LIBRARY})

> 
> * attempting to get authoritative answers outside of this list.

Anyway, I am not the author of the question on stackoverflow.com :) 
 
> 
> 
> -- 
> Yaakov



More information about the Cygwin-apps mailing list