ScummVM on Windows x64 with MinGW-w64

Discussion about other and unofficial ports of ScummVM

Moderator: ScummVM Team

Post Reply
Tobis87
Posts: 23
Joined: Thu Feb 05, 2009 9:41 pm

ScummVM on Windows x64 with MinGW-w64

Post by Tobis87 »

Hi,

I've already compiled scummvm with a crosscompiler from Linux x86_64 to Win32.

So the next thing I wanted to try out was if it is possible to compile scummvm with the new MinGW-w64 for the target Win64. As far as I could get I could compile SDL, zlib, libogg, libvorbis, libmad, FLAC and libmpeg2.

But when I try to crosscompile scummvm, I get the following error:

Code: Select all

make
mkdir -p backends/platform/sdl/.deps
x86_64-pc-mingw32-g++ -Wp,-MMD,"backends/platform/sdl/.deps/events.d",-MQ,"backends/platform/sdl/events.o",-MP -Wall -g -W -Wno-unused-parameter -Wno-parentheses -Wno-empty-body -Wno-long-long -Wno-multichar -Wno-unknown-pragmas -Wno-reorder -pedantic -Wpointer-arith -Wcast-qual -Wcast-align -Wshadow -Wimplicit -Wnon-virtual-dtor -Wwrite-strings -fno-rtti -fno-exceptions -fcheck-new -DHAVE_CONFIG_H -DWIN32 -D__USE_MINGW_ANSI_STDIO=0 -DDATA_PATH=\"/usr/local/share/scummvm\" -DPLUGIN_DIRECTORY=\"/usr/local/lib/scummvm\" -DSDL_BACKEND -DENABLE_SCUMM=STATIC_PLUGIN -DENABLE_SCUMM_7_8 -DENABLE_HE -DENABLE_AGI=STATIC_PLUGIN -DENABLE_AGOS=STATIC_PLUGIN -DENABLE_CINE=STATIC_PLUGIN -DENABLE_DRASCULA=STATIC_PLUGIN -DENABLE_GOB=STATIC_PLUGIN -DENABLE_GROOVIE=STATIC_PLUGIN -DENABLE_KYRA=STATIC_PLUGIN -DENABLE_LURE=STATIC_PLUGIN -DENABLE_PARALLACTION=STATIC_PLUGIN -DENABLE_QUEEN=STATIC_PLUGIN -DENABLE_SAGA=STATIC_PLUGIN -DENABLE_IHNM -DENABLE_SKY=STATIC_PLUGIN -DENABLE_SWORD1=STATIC_PLUGIN -DENABLE_SWORD2=STATIC_PLUGIN -DENABLE_TOUCHE=STATIC_PLUGIN -DENABLE_TUCKER=STATIC_PLUGIN -I. -I. -I./engines -I/usr/local/mingw64-cross/x86_64-pc-mingw32/include/SDL -D_GNU_SOURCE=1 -Dmain=SDL_main -c backends/platform/sdl/events.cpp -o backends/platform/sdl/events.o
mkdir -p backends/platform/sdl/.deps
x86_64-pc-mingw32-g++ -Wp,-MMD,"backends/platform/sdl/.deps/graphics.d",-MQ,"backends/platform/sdl/graphics.o",-MP -Wall -g -W -Wno-unused-parameter -Wno-parentheses -Wno-empty-body -Wno-long-long -Wno-multichar -Wno-unknown-pragmas -Wno-reorder -pedantic -Wpointer-arith -Wcast-qual -Wcast-align -Wshadow -Wimplicit -Wnon-virtual-dtor -Wwrite-strings -fno-rtti -fno-exceptions -fcheck-new -DHAVE_CONFIG_H -DWIN32 -D__USE_MINGW_ANSI_STDIO=0 -DDATA_PATH=\"/usr/local/share/scummvm\" -DPLUGIN_DIRECTORY=\"/usr/local/lib/scummvm\" -DSDL_BACKEND -DENABLE_SCUMM=STATIC_PLUGIN -DENABLE_SCUMM_7_8 -DENABLE_HE -DENABLE_AGI=STATIC_PLUGIN -DENABLE_AGOS=STATIC_PLUGIN -DENABLE_CINE=STATIC_PLUGIN -DENABLE_DRASCULA=STATIC_PLUGIN -DENABLE_GOB=STATIC_PLUGIN -DENABLE_GROOVIE=STATIC_PLUGIN -DENABLE_KYRA=STATIC_PLUGIN -DENABLE_LURE=STATIC_PLUGIN -DENABLE_PARALLACTION=STATIC_PLUGIN -DENABLE_QUEEN=STATIC_PLUGIN -DENABLE_SAGA=STATIC_PLUGIN -DENABLE_IHNM -DENABLE_SKY=STATIC_PLUGIN -DENABLE_SWORD1=STATIC_PLUGIN -DENABLE_SWORD2=STATIC_PLUGIN -DENABLE_TOUCHE=STATIC_PLUGIN -DENABLE_TUCKER=STATIC_PLUGIN -I. -I. -I./engines -I/usr/local/mingw64-cross/x86_64-pc-mingw32/include/SDL -D_GNU_SOURCE=1 -Dmain=SDL_main -c backends/platform/sdl/graphics.cpp -o backends/platform/sdl/graphics.o
backends/platform/sdl/graphics.cpp: In member function 'virtual void OSystem_SDL::copyRectToScreen(const byte*, int, int, int, int, int)':
backends/platform/sdl/graphics.cpp:796: error: cast from 'const byte*' to 'long int' loses precision
backends/platform/sdl/graphics.cpp: In member function 'void OSystem_SDL::addDirtyRgnAuto(const byte*)':
backends/platform/sdl/graphics.cpp:1000: error: cast from 'const byte*' to 'long int' loses precision
make: *** [backends/platform/sdl/graphics.o] Fehler 1
Scummvm was configured with:

Code: Select all

./configure --host=x86_64-pc-mingw32 --with-sdl-prefix=/usr/local/mingw64-cross/x86_64-pc-mingw32
Does anyone know how to get around this error?
Last edited by Tobis87 on Sun Feb 15, 2009 11:20 pm, edited 1 time in total.
User avatar
eriktorbjorn
ScummVM Developer
Posts: 3523
Joined: Mon Oct 31, 2005 7:39 am

Re: ScummVM on Windows x64 with MinGW-w64

Post by eriktorbjorn »

Tobis87 wrote: backends/platform/sdl/graphics.cpp:796: error: cast from 'const byte*' to 'long int' loses precision
backends/platform/sdl/graphics.cpp: In member function 'void OSystem_SDL::addDirtyRgnAuto(const byte*)':
backends/platform/sdl/graphics.cpp:1000: error: cast from 'const byte*' to 'long int' loses precision
That would be these lines:

Code: Select all

if (((long)src & 3) == 0 && ...

assert(((long)buf & 3) == 0);
They're both trying to determine if the pointer is aligned. They're only interested in the two least significant bits of the pointer, so it shouldn't really matter that the casting loses precision. Of course, the compiler clearly has a different opinion in your case.

It's possible that you could use a larger integer type. If memory serves me, GCC should understand "long long" to be a 64-bit integer, for instance.

On the other hand, both lines are part of the "automatically compute dirty rectangles" code that I don't think any engine actually uses, at least not in the development version of ScummVM, so you could simply remove that code.
Tobis87
Posts: 23
Joined: Thu Feb 05, 2009 9:41 pm

Post by Tobis87 »

It compiled!!:shock:

I had to:

-replace every long with long long

-add -O2 to CXXFLAGS, because of a GCC mingw ld bug:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=484299

I can't test it yet, because I don't have a Windows x64 OS, but if somebody wants to build their Win64 version, with an cross compiler:

1. Get the latest MinGW-w64 snapshot:
http://sourceforge.net/projects/mingw-w64

2. Read the mingw-w64-howto-build.txt (inside tar.bz2)

3. Get the GCC toolchain (get the versions described in the howto)
http://ubuntuforums.org/showpost.php?p= ... ostcount=4

4. Build the GCC crosscompiler (but replaced the Win32 API and Mingw runtime with the mingw-w64 headers, the Win32 runtime with mingw-w64-crt and --target=i686-pc-mingw32 with --target=x86_64-pc-mingw32)
http://ubuntuforums.org/showpost.php?p= ... stcount=20

Or if you have an i686 Windows or Linux just get the automated build. (Which I hadn't tested)

1. Build the mingw libs (Ignore Nasm, add --prefix=/usr/local/foo/x86_64-pc-mingw32 --host=x86_64-pc-mingw32 to every configure)
http://wiki.scummvm.org/index.php/Compi ... mmVM/MinGW

2. You will have to build SDL and strip SDL.dll (don't disable shared, also with prefix and host)

Code: Select all

x86_64-pc-mingw32-strip /usr/local/foo/x86_64-pc-mingw32/bin/SDL.dll
3. Build scummvm (if gcc fails on a file open the file and replace "long" with "long long"

Code: Select all

CXXFLAGS="-O2" ./configure --host=x86_64-pc-mingw32 --with-sdl-prefix=/usr/local/foo/x86_64-pc-mingw32
make
4. Strip scummvm and copy 64bit SDL.dll

Code: Select all

x86_64-pc-mingw32-strip scummvm.exe
cp /usr/local/foo/x86_64-pc-mingw32/bin/SDL.dll .
Windows XP x64 or Windows Vista x64 with SP1 is needed for Mingw-w64 applications.
Tobis87
Posts: 23
Joined: Thu Feb 05, 2009 9:41 pm

Post by Tobis87 »

Scummvm compiled with MinGW-w64 does run and is recognized as an 64bit application by Windows. :lol:
Tobis87
Posts: 23
Joined: Thu Feb 05, 2009 9:41 pm

Post by Tobis87 »

1.0.0 Release compiles fine, but with the latest svn I have a problem with compiling:

Code: Select all

make
    C++      backends/platform/sdl/events.o
    C++      backends/platform/sdl/graphics.o
    C++      backends/platform/sdl/hardwarekeys.o
    C++      backends/platform/sdl/main.o
    C++      backends/platform/sdl/sdl.o
In file included from ./common/savefile.h:31,
                 from ./common/EventRecorder.h:32,
                 from backends/platform/sdl/sdl.cpp:36:
./common/stream.h: In static member function 'static void Common::WriteStream::writeSint16LE(int16)':
./common/stream.h:130: error: cannot call member function 'void Common::WriteStream::writeUint16LE(uint16)' without object
./common/stream.h: In static member function 'static void Common::WriteStream::writeSint32LE(int32)':
./common/stream.h:134: error: cannot call member function 'void Common::WriteStream::writeUint32LE(uint32)' without object
./common/stream.h: In static member function 'static void Common::WriteStream::writeSint16BE(int16)':
./common/stream.h:138: error: cannot call member function 'void Common::WriteStream::writeUint16BE(uint16)' without object
./common/stream.h: In static member function 'static void Common::WriteStream::writeSint32BE(int32)':
./common/stream.h:142: error: cannot call member function 'void Common::WriteStream::writeUint32BE(uint32)' without object
./common/stream.h: In static member function 'static int8 Common::ReadStream::readSByte()':
./common/stream.h:198: error: cannot call member function 'byte Common::ReadStream::readByte()' without object
./common/stream.h: In static member function 'static int16 Common::ReadStream::readSint16LE()':
./common/stream.h:261: error: cannot call member function 'uint16 Common::ReadStream::readUint16LE()' without object
./common/stream.h: In static member function 'static int32 Common::ReadStream::readSint32LE()':
./common/stream.h:272: error: cannot call member function 'uint32 Common::ReadStream::readUint32LE()' without object
./common/stream.h: In static member function 'static int16 Common::ReadStream::readSint16BE()':
./common/stream.h:283: error: cannot call member function 'uint16 Common::ReadStream::readUint16BE()' without object
./common/stream.h: In static member function 'static int32 Common::ReadStream::readSint32BE()':
./common/stream.h:294: error: cannot call member function 'uint32 Common::ReadStream::readUint32BE()' without object
./common/stream.h: In static member function 'static int16 Common::SeekableSubReadStreamEndian::readSint16()':
./common/stream.h:483: error: cannot call member function 'uint16 Common::SeekableSubReadStreamEndian::readUint16()' without object
./common/stream.h: In static member function 'static int32 Common::SeekableSubReadStreamEndian::readSint32()':
./common/stream.h:487: error: cannot call member function 'uint32 Common::SeekableSubReadStreamEndian::readUint32()' without object
./common/stream.h: In static member function 'static int16 Common::MemoryReadStreamEndian::readSint16()':
./common/stream.h:607: error: cannot call member function 'uint16 Common::MemoryReadStreamEndian::readUint16()' without object
./common/stream.h: In static member function 'static int32 Common::MemoryReadStreamEndian::readSint32()':
./common/stream.h:611: error: cannot call member function 'uint32 Common::MemoryReadStreamEndian::readUint32()' without object
make: *** [backends/platform/sdl/sdl.o] Fehler 1
ScummVM was configured with:

Code: Select all

CXXFLAGS="-O2" ./configure --host=x86_64-pc-mingw32 --with-sdl-prefix=/usr/local/mingw64-cross/x86_64-pc-mingw32 --enable-lol --enable-mohawk --disable-debug --disable-cine --disable-cruise --disable-draci --disable-lure --disable-parallaction --disable-queen --disable-teenagent --disable-touche --disable-tucker --disable-saga
Running ScummVM configure...
Looking for C++ compiler... x86_64-pc-mingw32-g++
Checking for compiler version... 4.3.2, ok
Checking endianness... little
Type with 1 byte... char
Type with 2 bytes... short
Type with 4 bytes... int
Compiling for x86... no
Checking hosttype... mingw32
Cross-compiling to x86_64-pc-mingw32, forcing endianness, alignment and type sizes
Checking whether to have a verbose build... no
Checking whether building plugins was requested... no
Checking for Ogg Vorbis... yes
Checking for Tremor... no (Ogg Vorbis/Tremor support is mutually exclusive)
Checking for FLAC >= 1.0.1... yes
Checking for MAD... yes
Checking for ALSA >= 0.9... no
Checking for zlib... yes
Checking for libmpeg2 >= 0.3.2... no
Checking for libfluidsynth... yes
Checking for readline... skipping (text console disabled)
Backend... sdl, 16bit color, HQ scalers, MT-32 emu, Indeo3 decoder
Looking for sdl-config... /usr/local/mingw64-cross/x86_64-pc-mingw32/bin/sdl-config
dynamic modules = no
plugins default = static

Engines (builtin):
    SCUMM [all games]
    AGI
    AGOS [all games]
    Drascula: The Vampire Strikes Back
    Gobli*ns
    Groovie
    Legend of Kyrandia [all games]
    MADE
    Mohawk
    SCI
    Beneath a Steel Sky
    Broken Sword
    Broken Sword II
    Tinsel

Engines Skipped:
    Cinematique evo 1
    Cinematique evo 2
    Dragon History
    Groovie [Groovie 2 games]
    Lure of the Temptress
    M4/MADS
    Parallaction
    Flight of the Amazon Queen
    SAGA
    SCI [SCI32 games]
    Teen Agent
    Touche: The Adventures of the Fifth Musketeer
    Bud Tucker in Double Trouble


Creating config.h
Creating config.mk
GCC Version:

Code: Select all

x86_64-pc-mingw32-g++ -v
Using built-in specs.
Target: x86_64-pc-mingw32
Configured with: ../configure --prefix=/usr/local/mingw64-cross --target=x86_64-pc-mingw32 --with-headers=/usr/local/mingw64-cross/x86_64-pc-mingw32/include --with-gcc --with-gnu-ld --with-gnu-as --enable-languages=c,c++ --enable-threads=win32 --enable-sjlj-exceptions --disable-win32-registry --disable-nls --disable-shared --disable-debug
Thread model: win32
gcc version 4.3.2 (GCC)
mingw-w64-snapshot-20081115
SDL-devel-1.2.13-mingw64
User avatar
bobdevis
Posts: 567
Joined: Fri Jan 16, 2009 10:52 am

Post by bobdevis »

Just compiled svn20100105 here with no probs on Ubuntu64, so at least you know it's a windows-specific problem.

On an unrelated note; You can combine the enable/disable-all argument with specific engines.

Code: Select all

 ./configure --disable-all-engines --enable-cruise
This gives you only the cruise engine for example. This saves some copy-pasting ;)
User avatar
LordHoto
ScummVM Developer
Posts: 1029
Joined: Sun Oct 30, 2005 3:58 pm
Location: Germany

Post by LordHoto »

Tobis87 wrote:1.0.0 Release compiles fine, but with the latest svn I have a problem with compiling:
That looks really strange. There shouldn't be a static in front of the readSint* methods. The code uses FORCEINLINE there, but your compiler errors suggest that your compiler put static there...

Do you have any source patches applied or the like? At least the vanilla ScummVM source should only define FORCEINLINE as:
"inline __attribute__((__always_inline__))" on your compiler.
Tobis87
Posts: 23
Joined: Thu Feb 05, 2009 9:41 pm

Post by Tobis87 »

No, I haven't applied any patches to ScummVM, and scummsys.h reads:

Code: Select all

//
// GCC specific stuff
//
#if defined(__GNUC__)
	#define NORETURN_POST __attribute__((__noreturn__))
	#define PACKED_STRUCT __attribute__((__packed__))
	#define GCC_PRINTF(x,y) __attribute__((__format__(printf, x, y)))

	#if !defined(FORCEINLINE) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
		#define FORCEINLINE inline __attribute__((__always_inline__))
	#endif
#else
	#define PACKED_STRUCT
	#define GCC_PRINTF(x,y)
#endif
Maybe it is a bug in the mingw-w64-crt or they changed something around. I'm not a big programmer :oops:

Edit: If I delete these lines:

Code: Select all

---#if !defined(FORCEINLINE) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
		#define FORCEINLINE inline __attribute__((__always_inline__))
---#endif
I get this warning:

Code: Select all

./common/scummsys.h:382:1: warning: "FORCEINLINE" redefined
In file included from /usr/local/mingw64-cross/lib/gcc/x86_64-pc-mingw32/4.3.2/../../../../x86_64-pc-mingw32/include/windef.h:122,
                 from /usr/local/mingw64-cross/lib/gcc/x86_64-pc-mingw32/4.3.2/../../../../x86_64-pc-mingw32/include/windows.h:62,
                 from backends/platform/sdl/main.cpp:31:
/usr/local/mingw64-cross/lib/gcc/x86_64-pc-mingw32/4.3.2/../../../../x86_64-pc-mingw32/include/winnt.h:129:1: warning: this is the location of the previous definition
And in the mingw-w64-snapshot-20081115 headers, in winnt.h FORCEINLINE is defined as:

Code: Select all

#ifndef FORCEINLINE
#define FORCEINLINE static __inline__
#endif
While in the new mingw-w64-v1.0-snapshot-20091224 headers, in winnt.h FORCEINLINE is defined as:

Code: Select all

#ifndef FORCEINLINE
#define FORCEINLINE __inline__ __attribute__((always_inline))
#endif
Anyway, it now compiled, and it runs! Thank you for the hint.
Post Reply