I am trying to compile using Mingw64 under MSys
Obviously it is not working because the cmake file under windows is tailored for msvc.
I removed the /Zi part in the CMakeList.test and added flags:
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")
I also changed target system to -G "MinGW Makefiles"
This improved situation but using mingw32-make is it still not working:
D:\Projects\awsapi\aws-sdk-cpp-master\aws-cpp-sdk-core\source\external\tinyxml2\
tinyxml2.cpp:1639:15: error: definition of static data member 'Aws::External::ti
nyxml2::XMLDocument::_errorNames' of dllimport'd class
const char* XMLDocument::_errorNames[XML_ERROR_COUNT] = {
^
aws-cpp-sdk-core\CMakeFiles\aws-cpp-sdk-core.dir\build.make:187: recipe for targ
et 'aws-cpp-sdk-core/CMakeFiles/aws-cpp-sdk-core.dir/source/external/tinyxml2/ti
nyxml2.cpp.obj' failed
Thanks,
Nico.
I'm also seeing the same error. I added add_definitions(-std=c++11) to my CMakeLists.txt, and ran
aws-sdk-cpp>cmake . -G "MinGW Makefiles" -DBUILD_ONLY="aws-cpp-sdk-s3"
Following that I did
aws-sdk-cpp>mingw32-make install
and got
aws-sdk-cpp\aws-cpp-sdk-core\source\external\tinyxml2\tinyxml2.cpp:1639:15: error: definition of static data member 'Aws::External::tinyxml2::XMLDocument::_errorNames' of dllimport'd class
const char* XMLDocument::_errorNames[XML_ERROR_COUNT] = {
^
aws-cpp-sdk-core\CMakeFiles\aws-cpp-sdk-core.dir\build.make:187: recipe for target 'aws-cpp-sdk-core/CMakeFiles/aws-cpp-sdk-core.dir/source/external/tinyxml2/tinyxml2.cpp.obj' failed
mingw32-make[2]: *** [aws-cpp-sdk-core/CMakeFiles/aws-cpp-sdk-core.dir/source/external/tinyxml2/tinyxml2.cpp.obj] Error 1
CMakeFiles\Makefile2:84: recipe for target 'aws-cpp-sdk-core/CMakeFiles/aws-cpp-sdk-core.dir/all' failed
mingw32-make[1]: *** [aws-cpp-sdk-core/CMakeFiles/aws-cpp-sdk-core.dir/all] Error 2
Makefile:126: recipe for target 'all' failed
mingw32-make: *** [all] Error 2
I am using gcc (x86_64-posix-seh-rev1, Built by MinGW-W64 project) 5.2.0 on Windows 10, 64 bit.
I am able to successfully compile the sdk using visual studio 2015 but ran into issues with stdext when trying to integrate with mingw compiled code
For the stdext problem with MinGW-W64 this change in Array.h allows compilation
-#ifdef _WIN32
+#ifdef _MSC_VER
Array.txt
More things that I did to compile with MinGW-W64:
diff --git a/aws-cpp-sdk-core/source/http/HttpClientFactory.cpp b/aws-cpp-sdk-core/source/http/HttpClientFactory.cpp
index c6864c7..111d08a 100644
--- a/aws-cpp-sdk-core/source/http/HttpClientFactory.cpp
+++ b/aws-cpp-sdk-core/source/http/HttpClientFactory.cpp
@@ -18,6 +18,9 @@
#if ENABLE_CURL_CLIENT
#include <aws/core/http/curl/CurlHttpClient.h>
#include <signal.h>
+#ifndef SIGPIPE
+#define SIGPIPE 13
+#endif
#elif ENABLE_WINDOWS_CLIENT
#include <aws/core/client/ClientConfiguration.h>
diff --git a/aws-cpp-sdk-core/source/platform/windows/Environment.cpp b/aws-cpp-sdk-core/source/platform/windows/Environment.cpp
index fd8d58f..e690def 100644
--- a/aws-cpp-sdk-core/source/platform/windows/Environment.cpp
+++ b/aws-cpp-sdk-core/source/platform/windows/Environment.cpp
@@ -29,6 +29,7 @@ that would need to be manually freed in all the client functions, just copy it i
*/
Aws::String GetEnv(const char *variableName)
{
+#ifdef _MSC_VER
char* variableValue = nullptr;
std::size_t valueSize = 0;
auto queryResult = _dupenv_s(&variableValue, &valueSize, variableName);
@@ -39,7 +40,9 @@ Aws::String GetEnv(const char *variableName)
result.assign(variableValue, valueSize - 1); // don't copy the c-string terminator byte
free(variableValue);
}
-
+#else
+ Aws::String result = std::getenv(variableName);
+#endif
return result;
}
diff --git a/aws-cpp-sdk-core/source/platform/windows/FileSystem.cpp b/aws-cpp-sdk-core/source/platform/windows/FileSystem.cpp
index c4a4850..6b15e1f 100644
--- a/aws-cpp-sdk-core/source/platform/windows/FileSystem.cpp
+++ b/aws-cpp-sdk-core/source/platform/windows/FileSystem.cpp
@@ -279,6 +279,8 @@ Aws::String CreateTempFilePath()
{
#ifdef _MSC_VER
#pragma warning(disable: 4996) // _CRT_SECURE_NO_WARNINGS
+#else
+ #define L_tmpnam_s 4095 // FIXME: Put the correct value
#endif
char s_tempName[L_tmpnam_s+1];
To anyone interested in compiling with MinGW-W64: (7.2.0_seh):
1) in "Environment.cpp" don't use std::getenv (deprecated) - rather use instead GetEnvironmentVariable If you still like to use std::getenv handle returned null pointer, ie:
Aws::String result;
char* value = std::getenv(variableName);
if(value!=NULL) result = value;
2) you can use Curl 7.57.0-win64 (ie. this prebuild package)
3) use rather openssl 1.1.0 not 1.0.2 (Curl package don't have all required dll's) ie: this prebuild package