amkozlov / raxml-ng

RAxML Next Generation: faster, easier-to-use and more flexible
GNU Affero General Public License v3.0
374 stars 62 forks source link

Error "'asprintf' was not declared in this scope" when building with MinGW-W64 #146

Open jdx-gh opened 1 year ago

jdx-gh commented 1 year ago

Here is the patch:

diff --git a/src/bootstrap/SupportTree.cpp b/src/bootstrap/SupportTree.cpp
index 388744a..e028b1d 100644
--- a/src/bootstrap/SupportTree.cpp
+++ b/src/bootstrap/SupportTree.cpp
@@ -1,3 +1,10 @@
+#ifdef __MINGW32__
+// for asprintf
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+#endif
+
 #include "SupportTree.hpp"

 using namespace std;
diff --git a/src/io/NewickStream.cpp b/src/io/NewickStream.cpp
index 9b7eb34..b06a528 100644
--- a/src/io/NewickStream.cpp
+++ b/src/io/NewickStream.cpp
@@ -1,3 +1,10 @@
+#ifdef __MINGW32__
+// for asprintf
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+#endif
+
 #include "file_io.hpp"

 using namespace std;