-
Notifications
You must be signed in to change notification settings - Fork 15
Description
Hi.
It's possible to compile a console application with mingw32, though you need some manual config
- I needed to create a ./m4 subfolder and put pkg.m4 inside in order to configure properly. I used this https://github.com/pkgconf/pkgconf/blob/master/pkg.m4 and changed Makefile.am and configure.ac accordingly:
diff --git a/Makefile.am b/Makefile.am
index dd9a7fc..66ea5e4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -3,3 +3,5 @@ SUBDIRS = src doc
EXTRA_DIST = adplay.spec adplay.qpg
AUTOMAKE_OPTIONS = dist-bzip2
+
+ACLOCAL_AMFLAGS = -I m4
diff --git a/configure.ac b/configure.ac
index 565acb2..cdb8938 100644
--- a/configure.ac
+++ b/configure.ac
@@ -15,6 +15,8 @@ AC_PROG_CXX
AC_PROG_CPP
AC_PROG_CXXCPP
+AC_CONFIG_MACRO_DIRS([m4])
+
# Nothing works without these libraries...
AC_CHECK_LIB(stdc++,main,,AC_MSG_ERROR([libstdc++ not installed]))
PKG_CHECK_MODULES([adplug], [adplug >= 2.0],,[
Only after that the command autoreconf --install
finished successfully
-
After that I was able to execute
./configure --prefix=/mingw CXXFLAGS=-fpermissive
. But before configuring it's better to fix SDL (below) -
SDL config problem. By default
sdl-config
script forces your application to be a windows app, not console, and it intercepts output to sderr and stdout and redirects it into files.
I've found if you edit sdl-config the configure will fail (sdl won't be found) so I had to edit the resulting Makefile in the following way: removed-Dmain=SDL_main
and-lSDLmain
and changed-mwindows
into-mconsole
Another important thing: insert#undef main
in the adplug.cc right before the main(). -
sdl.h header problem.
As noted in another issue, windows fs is not case-sensitive, so#include <SDL.h>
and#include "sdl.h"
are misinterpreted as 'include local sdl.h` by the compiler. To overcome this, better rename ./src/sdl.h into ./src/sdlx.h and change all #includes accordingly -
Strange typecast is needed in adplug.cc:
diff --git a/src/adplay.cc b/src/adplay.cc
index d93d16f..2973ca0 100644
--- a/src/adplay.cc
+++ b/src/adplay.cc
@@ -239,7 +239,7 @@ static int decode_switches(int argc, char **argv)
{NULL, 0, NULL, 0} // end of options
};
- while ((c = getopt_long(argc, argv, "8f:b:d:irms:ol:hVe:O:D:qv",
+ while ((c = getopt_long(argc, (char* const** (*)())argv, "8f:b:d:irms:ol:hVe:O:D:qv",
long_options, (int *)0)) != EOF) {
switch (c) {
case '8': cfg.bits = 8; break;
After all above the make will succeed and the resulting adplay.exe will show output in the console