Discussion:
[libtorrent] How to overpass winsock2.h error in byteswap.hpp
Nocs ...
2017-05-14 18:05:39 UTC
Permalink
Hi again, i ve managed to build it without errors and use the appropiate client_test to start testing

but i cant build cause of the ntohs ntohl htons htonl error i get refering to winsock2.h


I tried many options about winsock2.h ws2tcpip.h windows.h solutions but nothing came in handy

do i need to define anything ?

i allready tried WIN32_LEAN_AND_MEAN defined first before all in the client_test.cpp

and also _WINSOCKAPI_ but nothing seems to work

i am on msvc2013 and build the latest version from rasterbar


does anyone knows what to change and where so i can make it work ?
Nocs ...
2017-05-14 18:13:47 UTC
Permalink
Here is my errors in the below link

<https://gist.github.com/nocos/dbb3ed6bd76877f21f1cdac75a6b67d3.js>https://gist.github.com/nocos/dbb3ed6bd76877f21f1cdac75a6b67d3

<https://gist.github.com/nocos/dbb3ed6bd76877f21f1cdac75a6b67d3.js>
<https://gist.github.com/nocos/dbb3ed6bd76877f21f1cdac75a6b67d3>

<https://gist.github.com/nocos/dbb3ed6bd76877f21f1cdac75a6b67d3.js><https://gist.github.com/nocos/dbb3ed6bd76877f21f1cdac75a6b67d3>

________________________________
From: Nocs ... <***@hotmail.com>
Sent: Sunday, May 14, 2017 9:05:39 PM
To: libtorrent-***@lists.sourceforge.net
Subject: [libtorrent] How to overpass winsock2.h error in byteswap.hpp

Hi again, i ve managed to build it without errors and use the appropiate client_test to start testing

but i cant build cause of the ntohs ntohl htons htonl error i get refering to winsock2.h


I tried many options about winsock2.h ws2tcpip.h windows.h solutions but nothing came in handy

do i need to define anything ?

i allready tried WIN32_LEAN_AND_MEAN defined first before all in the client_test.cpp

and also _WINSOCKAPI_ but nothing seems to work

i am on msvc2013 and build the latest version from rasterbar


does anyone knows what to change and where so i can make it work ?

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Libtorrent-discuss mailing list
Libtorrent-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libtorrent-discuss
Arvid Norberg
2017-05-14 23:23:07 UTC
Permalink
I've come across this issue a few times on windows too. iirc, there are
cases where you must include windows.h before certain boost/asio headers.

On Sun, May 14, 2017 at 2:13 PM, Nocs ... <***@hotmail.com> wrote:

> Here is my errors in the below link
>
> <https://gist.github.com/nocos/dbb3ed6bd76877f21f1cdac75a6b67d3.js>
> https://gist.github.com/nocos/dbb3ed6bd76877f21f1cdac75a6b67d3
>
> <https://gist.github.com/nocos/dbb3ed6bd76877f21f1cdac75a6b67d3.js>
> <https://gist.github.com/nocos/dbb3ed6bd76877f21f1cdac75a6b67d3>
>
> <https://gist.github.com/nocos/dbb3ed6bd76877f21f1cdac75a6b67d3.js><
> https://gist.github.com/nocos/dbb3ed6bd76877f21f1cdac75a6b67d3>
>
> ________________________________
> From: Nocs ... <***@hotmail.com>
> Sent: Sunday, May 14, 2017 9:05:39 PM
> To: libtorrent-***@lists.sourceforge.net
> Subject: [libtorrent] How to overpass winsock2.h error in byteswap.hpp
>
> Hi again, i ve managed to build it without errors and use the appropiate
> client_test to start testing
>
> but i cant build cause of the ntohs ntohl htons htonl error i get refering
> to winsock2.h
>
>
> I tried many options about winsock2.h ws2tcpip.h windows.h solutions but
> nothing came in handy
>
> do i need to define anything ?
>
> i allready tried WIN32_LEAN_AND_MEAN defined first before all in the
> client_test.cpp
>
> and also _WINSOCKAPI_ but nothing seems to work
>
> i am on msvc2013 and build the latest version from rasterbar
>
>
> does anyone knows what to change and where so i can make it work ?
>
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Libtorrent-discuss mailing list
> Libtorrent-***@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/libtorrent-discuss
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Libtorrent-discuss mailing list
> Libtorrent-***@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/libtorrent-discuss
>



--
Arvid Norberg
Nocs ...
2017-05-15 08:04:37 UTC
Permalink
thanks for the response, yes i understand where is the problem but i dont understand where to put the headers.

I use only the client-test.cpp and the needed for it header and other cpp files in my project.

I tried so far to use them on the byteswap.hpp that gets the error and also in the client_test.cpp

but nothing actually worked.


i would like to know if is possible where should i give the tries in which cpp hpp or where to play around with the order

of the definitions cause there are too many cpp hpp files and even redefinition errors.

Does anyone have a clue about it ?

If i change boost version also could it be of a help or it doesnt matter the version ?


________________________________
From: Arvid Norberg <***@gmail.com>
Sent: Monday, May 15, 2017 2:23:07 AM
To: General discussion about libtorrent
Subject: Re: [libtorrent] How to overpass winsock2.h error in byteswap.hpp

I've come across this issue a few times on windows too. iirc, there are
cases where you must include windows.h before certain boost/asio headers.

On Sun, May 14, 2017 at 2:13 PM, Nocs ... <***@hotmail.com> wrote:

> Here is my errors in the below link
>
> <https://gist.github.com/nocos/dbb3ed6bd76877f21f1cdac75a6b67d3.js>
> https://gist.github.com/nocos/dbb3ed6bd76877f21f1cdac75a6b67d3
>
> <https://gist.github.com/nocos/dbb3ed6bd76877f21f1cdac75a6b67d3.js>
> <https://gist.github.com/nocos/dbb3ed6bd76877f21f1cdac75a6b67d3>
>
> <https://gist.github.com/nocos/dbb3ed6bd76877f21f1cdac75a6b67d3.js><
> https://gist.github.com/nocos/dbb3ed6bd76877f21f1cdac75a6b67d3>
>
> ________________________________
> From: Nocs ... <***@hotmail.com>
> Sent: Sunday, May 14, 2017 9:05:39 PM
> To: libtorrent-***@lists.sourceforge.net
> Subject: [libtorrent] How to overpass winsock2.h error in byteswap.hpp
>
> Hi again, i ve managed to build it without errors and use the appropiate
> client_test to start testing
>
> but i cant build cause of the ntohs ntohl htons htonl error i get refering
> to winsock2.h
>
>
> I tried many options about winsock2.h ws2tcpip.h windows.h solutions but
> nothing came in handy
>
> do i need to define anything ?
>
> i allready tried WIN32_LEAN_AND_MEAN defined first before all in the
> client_test.cpp
>
> and also _WINSOCKAPI_ but nothing seems to work
>
> i am on msvc2013 and build the latest version from rasterbar
>
>
> does anyone knows what to change and where so i can make it work ?
>
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Libtorrent-discuss mailing list
> Libtorrent-***@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/libtorrent-discuss
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Libtorrent-discuss mailing list
> Libtorrent-***@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/libtorrent-discuss
>



--
Arvid Norberg
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Libtorrent-discuss mailing list
Libtorrent-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libtorrent-discuss
Arvid Norberg
2017-05-15 13:22:24 UTC
Permalink
On Mon, May 15, 2017 at 4:04 AM, Nocs ... <***@hotmail.com> wrote:

> thanks for the response, yes i understand where is the problem but i dont
> understand where to put the headers.
>
> I use only the client-test.cpp and the needed for it header and other cpp
> files in my project.
>
> I tried so far to use them on the byteswap.hpp that gets the error and
> also in the client_test.cpp
>
> but nothing actually worked.
>

Did you try to include windows.h as the first header to include in
client_test.cpp?

i would like to know if is possible where should i give the tries in which
> cpp hpp or where to play around with the order
> of the definitions cause there are too many cpp hpp files and even
> redefinition errors.
> Does anyone have a clue about it ?
>

In the .cpp file that fails to build, try including windows.h at the top of
it to see if that helps.


> If i change boost version also could it be of a help or it doesnt matter
> the version ?
>

It might, but I don't know.

--
Arvid Norberg
Nocs ...
2017-05-15 14:25:17 UTC
Permalink
I think i found the solution and in case anyone else strugle upon the same issue

In the byteswap.hpp in the #ifdef TORRENT_WINDOWS #include <winsock.h> instead of <winsock2.h>

that solved for me the problem on compiling the client_test.cpp in windows

1.1.3 rasterbar and latest boost build msvc2013


Cheers

i am on my way to test it

thanks

________________________________
From: Arvid Norberg <***@gmail.com>
Sent: Monday, May 15, 2017 4:22:24 PM
To: General discussion about libtorrent
Subject: Re: [libtorrent] How to overpass winsock2.h error in byteswap.hpp

On Mon, May 15, 2017 at 4:04 AM, Nocs ... <***@hotmail.com> wrote:

> thanks for the response, yes i understand where is the problem but i dont
> understand where to put the headers.
>
> I use only the client-test.cpp and the needed for it header and other cpp
> files in my project.
>
> I tried so far to use them on the byteswap.hpp that gets the error and
> also in the client_test.cpp
>
> but nothing actually worked.
>

Did you try to include windows.h as the first header to include in
client_test.cpp?

i would like to know if is possible where should i give the tries in which
> cpp hpp or where to play around with the order
> of the definitions cause there are too many cpp hpp files and even
> redefinition errors.
> Does anyone have a clue about it ?
>

In the .cpp file that fails to build, try including windows.h at the top of
it to see if that helps.


> If i change boost version also could it be of a help or it doesnt matter
> the version ?
>

It might, but I don't know.

--
Arvid Norberg
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Libtorrent-discuss mailing list
Libtorrent-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libtorrent-discuss
Nocs ...
2017-05-15 14:45:07 UTC
Permalink
Congruts to all the devs and Arvid ofcourse ^.^ is working as a charm in the client_test.cpp fast easy and efficient


________________________________
From: Nocs ... <***@hotmail.com>
Sent: Monday, May 15, 2017 5:25:17 PM
To: General discussion about libtorrent
Subject: Re: [libtorrent] How to overpass winsock2.h error in byteswap.hpp

I think i found the solution and in case anyone else strugle upon the same issue

In the byteswap.hpp in the #ifdef TORRENT_WINDOWS #include <winsock.h> instead of <winsock2.h>

that solved for me the problem on compiling the client_test.cpp in windows

1.1.3 rasterbar and latest boost build msvc2013


Cheers

i am on my way to test it

thanks

________________________________
From: Arvid Norberg <***@gmail.com>
Sent: Monday, May 15, 2017 4:22:24 PM
To: General discussion about libtorrent
Subject: Re: [libtorrent] How to overpass winsock2.h error in byteswap.hpp

On Mon, May 15, 2017 at 4:04 AM, Nocs ... <***@hotmail.com> wrote:

> thanks for the response, yes i understand where is the problem but i dont
> understand where to put the headers.
>
> I use only the client-test.cpp and the needed for it header and other cpp
> files in my project.
>
> I tried so far to use them on the byteswap.hpp that gets the error and
> also in the client_test.cpp
>
> but nothing actually worked.
>

Did you try to include windows.h as the first header to include in
client_test.cpp?

i would like to know if is possible where should i give the tries in which
> cpp hpp or where to play around with the order
> of the definitions cause there are too many cpp hpp files and even
> redefinition errors.
> Does anyone have a clue about it ?
>

In the .cpp file that fails to build, try including windows.h at the top of
it to see if that helps.


> If i change boost version also could it be of a help or it doesnt matter
> the version ?
>

It might, but I don't know.

--
Arvid Norberg
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Libtorrent-discuss mailing list
Libtorrent-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libtorrent-discuss
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Libtorrent-discuss mailing list
Libtorrent-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libtorrent-discuss
Arvid Norberg
2017-05-15 21:52:34 UTC
Permalink
On Mon, May 15, 2017 at 10:25 AM, Nocs ... <***@hotmail.com> wrote:

> I think i found the solution and in case anyone else strugle upon the same
> issue
>
> In the byteswap.hpp in the #ifdef TORRENT_WINDOWS #include <winsock.h>
> instead of <winsock2.h>
>

I was under the impression that including winsock.h would *select* winsock1
as the API to use, unless winsock2.h had already been included in the
current translation unit.

Everywhere in libtorrent I include winsock2.h. Are you suggesting I should
change all of them? Or should I just include all of windows.h instead?
I thought I was clever to avoid that beast, but maybe that's too clever.

I would like to sort this out for the 1.1.4 release. Do you have any
insight or advice?

--
Arvid Norberg
Nocs ...
2017-05-16 00:07:16 UTC
Permalink
I am not expert on such complex combilation Arvid but for the specific client_test.cpp

it worked fine and tested also by downloading a torrent without errors.

I just changed to winsock.h instead of winsock2.h and only in byteswap.hpp

Any other option i tried with defines includes etc etc didnt work.


I believe is better to have it as comment in client_test.cpp or somewhere for windows builds (if errors)

if anyone has the same error in windows he may try this option too cause windows always have such errors.

Better to use the latest winsock2.h and give an option to anyone who has errors to swap to winsock.h than changing anything in the build

I cant be of any other suggestion cause i really dont have the knowledge to say for sure if it needs

any other change anywhere else.


Other examples worked without errors except that they need the Iphlpapi.h in each one of them to be included as well as the lib of Iphlpapi


While i will create a client out of it

I will gather as much problems or suggestions if any and post them here so you can decide what to do.

________________________________
From: Arvid Norberg <***@gmail.com>
Sent: Tuesday, May 16, 2017 12:52:34 AM
To: General discussion about libtorrent
Subject: Re: [libtorrent] How to overpass winsock2.h error in byteswap.hpp

On Mon, May 15, 2017 at 10:25 AM, Nocs ... <***@hotmail.com> wrote:

> I think i found the solution and in case anyone else strugle upon the same
> issue
>
> In the byteswap.hpp in the #ifdef TORRENT_WINDOWS #include <winsock.h>
> instead of <winsock2.h>
>

I was under the impression that including winsock.h would *select* winsock1
as the API to use, unless winsock2.h had already been included in the
current translation unit.

Everywhere in libtorrent I include winsock2.h. Are you suggesting I should
change all of them? Or should I just include all of windows.h instead?
I thought I was clever to avoid that beast, but maybe that's too clever.

I would like to sort this out for the 1.1.4 release. Do you have any
insight or advice?

--
Arvid Norberg
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Libtorrent-discuss mailing list
Libtorrent-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libtorrent-discuss
Loading...