Lichtso / netLink

Socket and Networking Library using msgpack.org[C++11]
GNU General Public License v3.0
217 stars 48 forks source link

Runs only on Unix #26

Closed 014972304505347 closed 6 years ago

014972304505347 commented 6 years ago

You should probably state that this library only compiles on Unix systems, as the following block in Core.h:

include <arpa/inet.h>

include <sys/fcntl.h>

include

include <sys/ioctl.h>

include

are not available on Windows. I get errors for each line saying "Cannot open source file ____".

Lichtso commented 6 years ago

It is switched by a macro:

#ifdef WINVER
#include <SDKDDKVer.h>
#include <Ws2tcpip.h>
#else
#include <arpa/inet.h>
#include <sys/fcntl.h>
#include <netdb.h>
#include <sys/ioctl.h>
#include <unistd.h>
#endif

How are you trying to compile it (operating system, platform, compiler, versions etc) ? Try setting the WINVER macro manually if it is not done by your compilation environment already.

014972304505347 commented 6 years ago

Hi Lichtso,

Thanks for your reply. Yeah, I noticed the macro switch after posting this.

Specifics: Windows 10, Visual Studio 2017 version 15.7.2 (updated yesterday) building to x86. Using the Clang/LLVM compiler for x64 machine, LLVM version 6.0.0.

014972304505347 commented 6 years ago

Adding

define WINVER 0x0A00

define _WIN32_WINNT 0x0A00

to a header file fixes this issue.

(taken from here: https://msdn.microsoft.com/en-us/library/6sehtctf.aspx)

Lichtso commented 6 years ago

You could also try to add the macro as command line option like this: clang++ ... -DWINVER=0x0A00 ...

014972304505347 commented 6 years ago

Hi Lichtso, I think you should consider changing the switch from

     #ifdef WINVER

to

     #ifdef _MSC_VER

as according to this Microsoft document, WINVER is not guaranteed to be defined by MSVC. _MSC_VER however, is.

That might explain the problem I had in this thread where my compiler didn't hit the switch even though it was MSVC.

Lichtso commented 6 years ago

Can you try replacing all 6 occurrences (across the source code) of WINVER by _MSC_VER ?