Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile error on MinGW 32 (inet_pton) #71

Closed
hexedit opened this issue Mar 27, 2015 · 6 comments
Closed

Compile error on MinGW 32 (inet_pton) #71

hexedit opened this issue Mar 27, 2015 · 6 comments

Comments

@hexedit
Copy link

hexedit commented Mar 27, 2015

Getting this error when compiling with mingw32.

../../src/http_utils.cpp: In function 'void httpserver::http::get_ip_str(const sockaddr_, std::string&, socklen_t)':
../../src/http_utils.cpp:258:17: error: 'inet_ntop' was not declared in this scope
);
^
../../src/http_utils.cpp: In function 'const sockaddr httpserver::http::str_to_ip(const string&)':
../../src/http_utils.cpp:296:52: error: 'inet_pton' was not declared in this scope
inet_pton(AF_INET6, src.c_str(), (void_) &s);
^
../../src/http_utils.cpp:300:51: error: 'inet_pton' was not declared in this scope
inet_pton(AF_INET, src.c_str(), (void_) &s);
^
make[2]: *_* [libhttpserver_la-http_utils.lo] Error 1
make[2]: Leaving directory /home/Timofey/libhttpserver-master/build/src' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory/home/Timofey/libhttpserver-master/build'
make: *** [all] Error 2

uname -a
MINGW32_NT-6.2 HEXEDIT-N56DY 1.0.18(0.48/3/2) 2012-11-21 22:34 i686 Msys

Maybe some missing dependency?

@etr
Copy link
Owner

etr commented Mar 30, 2015

Hi hexedit,
which windows version are you using?

@hexedit
Copy link
Author

hexedit commented Mar 30, 2015

Hi.
Windows 8.1 SL x64.
libmicrohttpd is compilled, installed and available via pkg-config.
Everything is configured with --prefix=/mingw

@etr
Copy link
Owner

etr commented Apr 9, 2015

this is weird.

winsock2.h should include inet_ntop and inet_pton from Windows Vista (https://msdn.microsoft.com/en-us/library/windows/desktop/cc805843%28v=vs.85%29.aspx) - this should be the minimum supported by the library due to the definition of _WIN32_WINNT to 0x600 (https://msdn.microsoft.com/en-us/library/windows/desktop/cc805843%28v=vs.85%29.aspx).

There is something still missing here I guess. I am seriously evaluating to implement an internal version of those methods considering the problems that they keep causing on windows.

@etr
Copy link
Owner

etr commented Apr 9, 2015

I changed the code to avoid the usage of inet_pton and inet_ntop replacing them with getnameinfo (that should have a better support on windows).

Can you please let me know if this works for you?

@hexedit
Copy link
Author

hexedit commented Apr 10, 2015

Now it works fine.
Thanks, @etr ;)

PS. Unfortunately, i don't know these functions, but if they're better or more useful, i think this fix:
#ifndef HAVE_INET_PTON // some wrapper #endif
PPS. It's only suggestion ;)

@etr
Copy link
Owner

etr commented Apr 15, 2015

Good :)

getnameinfo is fine and (in general) much more 'cross-platform'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants