-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Automatic Lib Init (NetworkInitializer) is not working on MinGW #661
Comments
Network initialization is a Windows-specific thing and we have it done for the supported Visual Studio compiler. We don't officially support mingw, but we encourage contributions; so, you'll either have to come up with a solution or wait for one of the mingw contributors to help. |
I understand. Thanks for your comment. |
The issue is inside Poco/Net/Net.h file. I update this to fix issue: http://pastebin.com/3fWrnw0q |
With MinGW-w64 7.2.0 and poco-1.8.1-release, this problem recurs but only if POCO_STATIC=1 and we static link to Poco. (It worked correctly for a DLL-based POCO build). I work around this by explicitly calling Poco::Net::initializeNetwork() in my code. |
@OldWolf2 See if this helps and let us know, we may add it: diff --git a/Net/include/Poco/Net/Net.h b/Net/include/Poco/Net/Net.h
index 0d7bd35..f5bd912 100644
--- a/Net/include/Poco/Net/Net.h
+++ b/Net/include/Poco/Net/Net.h
@@ -92,7 +92,9 @@ void Net_API uninitializeNetwork();
extern "C" const struct Net_API NetworkInitializer pocoNetworkInitializer;
-#if defined(Net_EXPORTS)
+#if defined(__GNUC__)
+ #define POCO_NET_FORCE_SYMBOL(x) void *__ ## x ## _fp =(void*)&x;
+#elif defined(Net_EXPORTS)
#if defined(_WIN64) || defined(_WIN32_WCE)
#define POCO_NET_FORCE_SYMBOL(s) __pragma(comment (linker, "/export:"#s))
#elif defined(_WIN32) |
obviously |
@aleks-f The following patch I have tested and verified the following patch (building on your proposal) works with mingw gcc on windows. Will propose the change in a merge request if this is still something you would want to have implemented here. diff --git a/Net/include/Poco/Net/Net.h b/Net/include/Poco/Net/Net.h
index 2e9735ab2..785de0ef0 100644
--- a/Net/include/Poco/Net/Net.h
+++ b/Net/include/Poco/Net/Net.h
@@ -93,11 +93,13 @@ std::string htmlize(const std::string& str);
// Automate network initialization (only relevant on Windows).
//
-#if defined(POCO_OS_FAMILY_WINDOWS) && !defined(POCO_NO_AUTOMATIC_LIB_INIT) && !defined(__GNUC__)
+#if defined(POCO_OS_FAMILY_WINDOWS) && !defined(POCO_NO_AUTOMATIC_LIB_INIT)
extern "C" const struct Net_API NetworkInitializer pocoNetworkInitializer;
-#if defined(Net_EXPORTS)
+#if defined(__GNUC__)
+ #define POCO_NET_FORCE_SYMBOL(x) static void *__ ## x ## _fp = (void*)&x;
+#elif defined(Net_EXPORTS)
#if defined(_WIN64) || (defined(_WIN32_WCE) && !defined(x86))
#define POCO_NET_FORCE_SYMBOL(s) __pragma(comment (linker, "/export:"#s))
#elif defined(_WIN32) |
@jackorobot I don't mind it, you can send a pull. but it would be good to also have a CI job for that |
I'm writing a network client using Poco and MinGW.
It seems that I have to call Poco::Net::initializeNetwork() before calling any network-related functions, otherwise I get an exception like "DNS error: EAI: 10093", which means WSANOTINITIALISED (according to http://support.microsoft.com/kb/819124/) -- is it intended?
I think I'd be happy if I can always omit initializeNetwork() calls. Thanks.
The text was updated successfully, but these errors were encountered: