ZSNES with MinGW and MSYS

General area for talk about ZSNES. The best place to ask for related questions as well as troubleshooting.

Moderator: ZSNES Mods

Noxious Ninja
Dark Wind
Posts: 1271
Joined: Thu Jul 29, 2004 8:58 pm
Location: Texas
Contact:

ZSNES with MinGW and MSYS

Post by Noxious Ninja »

Well, I'm trying to compile ZSNES with MinGW and realizing that the docs are pretty minimal in this area.

Anyway, so far I've got the latest versions of MinGW and msys. I've manged to get zlib compiled and installed fine. There doesn't seem to be a MinGW makefile for libpng, but the libpng-lib package seems to work OK. I got the patched nasm, and that seems to work fine, too.

The thing I'm stuck on now is DirectX. Will the official DX SDK work or do I need something special for MinGW?

Once I get it working, I'll update install.txt with better instructions.


Oh, also, make clean doesn't work right. First, it doesn't work at all in msys since it tries to do del instead of rm. Not a big deal. The big deal is it deletes everything, not just the object files.
Last edited by Noxious Ninja on Tue Feb 01, 2005 4:38 am, edited 1 time in total.
[u][url=http://bash.org/?577451]#577451[/url][/u]
Nach
ZSNES Developer
ZSNES Developer
Posts: 3904
Joined: Tue Jul 27, 2004 10:54 pm
Location: Solar powered park bench
Contact:

Post by Nach »

1) Use ZSNES CVS, I made a quite few changes for this today.
2) The libpng-lib you have is probably no good. You have to compile it yourself. Don't look for a specific MinGW makefile, look for a GCC or DJGPP makefile.
3) Do not use msys.
4) DX should come with the latest Win32API, if not, get it from the Allegro team.
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding
Noxious Ninja
Dark Wind
Posts: 1271
Joined: Thu Jul 29, 2004 8:58 pm
Location: Texas
Contact:

Post by Noxious Ninja »

Nach wrote:1) Use ZSNES CVS, I made a quite few changes for this today.
Already doing that.
2) The libpng-lib you have is probably no good. You have to compile it yourself. Don't look for a specific MinGW makefile, look for a GCC or DJGPP makefile.
Works fine, thanks.
3) Do not use msys.
I found that a small addition to the makefile fixes my problems. Besides, it eliminates the need to get a copy of GNU make from DGJPP.
4) DX should come with the latest Win32API, if not, get it from the Allegro team.
For some strange reason, it comes with the libs, but not the headers. The headers from the Allegro package work fine.


I'll finish up the instructions and post them along with the makefile fix.
Last edited by Noxious Ninja on Fri Jan 21, 2005 4:58 am, edited 1 time in total.
[u][url=http://bash.org/?577451]#577451[/url][/u]
Aerdan
Winter Knight
Posts: 467
Joined: Mon Aug 16, 2004 10:16 pm
Contact:

Post by Aerdan »

The latest Win32API does not include the DX headers for some reason I have yet to fathom.
Noxious Ninja
Dark Wind
Posts: 1271
Joined: Thu Jul 29, 2004 8:58 pm
Location: Texas
Contact:

Post by Noxious Ninja »

OK, first the makefile. Add the following block after the ifeq (${CROSS},no) block.

Code: Select all

ifeq (${ENV},msys)
  DELETECOMMAND=rm -f
  SLASH=/
endif
You can also add this in there somewhere:

Code: Select all

ifeq (${RELGRADE},yes)
  ASMOPT=-O999
endif

Now for the instructions. Somebody please double-check these to make sure I didn't miss anything.

Code: Select all

Building the Windows port with MinGW:

Things you need:

- The ZSNES source code. You can download a package or get this from CVS.

- MinGW: http://www.mingw.org/
- Win32API: http://www.mingw.org/
- MSYS: http://www.mingw.org/

- Minimal DirectX 8 SDK for MinGW: http://www.talula.demon.co.uk/allegro/

Win32API 3.2 includes the DirectX libraries required for ZSNES, but it doesn't
include all the headers. Future versions of Win32API may eliminate this
requirement.

- NASM v0.98.39: http://nasm.sf.net/ 

- zlib: http://www.gzip.org/zlib/
- libpng: http://www.libpng.org/


1) Install MinGW. From here on, the directory you installed it to will be
   referred to as MinGW\.


2) Install Win32API by copying it to your MinGW directory and overwriting
   any existing files.


3) Extract the Minimal DirectX 8 SDK archive and copy everything in the
   include directory to your MinGW\include directory. Do not overwrite any
   existing files. You do not need the files in the lib directory of
   the archive.


4) Install MSYS. Follow the directions in the post-install script and point
   it to your MinGW installation. Make sure to use forward slashes and not
   backslashes.
   
   
5) Install NASM. Extract nasmw.exe to your MinGW\bin directory and rename it
   to nasm.exe.


6) Extract zlib, libpng, and the ZSNES source. You should extract libpng and zlib to the same root directory. To make it easy, pleace the ZSNES source there, as well.
   
   |-src
   |----zlib
   |----libpng
   |----zsnes
   
   When you extract zlib and libpng, you will get directories with version
   numbers in the name, such as libpng-1.2.8 and zlib-1.2.1. You will need to
   rename these and remove the version numbers as shown in the diagram, or libpng won't compile properly.


7) Start MSYS. Since MSYS mimics a Unix shell, you won't have drive letters.
   To access your drives, you will prepend the drive letter with a forward
   slash. For example, your C: drive is /c and C:\src\zlib is /c/src/zlib.


8) Go to your src/zlib directory. Run the following commands:
   
   cp win32/makefile.gcc makefile.gcc
   make -f makefile.gcc
   
   After zlib compiles, copy zlib.h and zconf.h to MinGW\include
   and libz.a to MinGW\lib.


9) Go to your src/libpng directory. Run the following commands:
   
   cp scripts/makefile.gcc makefile
   make
   
   Now copy png.h and pngconf.h to MinGW\include and libpng.a
   to MinGW\lib.


10) Go to your src/zsnes/src directory. Run the following commands:
    
    make -f makefile.ms PLATFORM=win32 ENV=msys

If everything went well, you will end up with a zsnesw.exe file.

You may want to compress zsnesw.exe with upx (http://upx.sourceforge.net).
This will reduce the filesize from over 3MB to around 500KB.
Last edited by Noxious Ninja on Tue Feb 01, 2005 4:44 am, edited 5 times in total.
[u][url=http://bash.org/?577451]#577451[/url][/u]
Nach
ZSNES Developer
ZSNES Developer
Posts: 3904
Joined: Tue Jul 27, 2004 10:54 pm
Location: Solar powered park bench
Contact:

Post by Nach »

1) I don't see why you seem so bent on using msys.
2) I said use latest CVS for a reason, GNUWIN32 patch from TRAC is no longer required, as we now use TRAC's object converter.
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding
Noxious Ninja
Dark Wind
Posts: 1271
Joined: Thu Jul 29, 2004 8:58 pm
Location: Texas
Contact:

Post by Noxious Ninja »

Nach wrote:1) I don't see why you seem so bent on using msys.
You don't have to, I just like it better than the Windows command line. Besides, like I said, it comes with a perfectly working make so you don't have to hunt one down.
2) I said use latest CVS for a reason, GNUWIN32 patch from TRAC is no longer required, as we now use TRAC's object converter.
Oh. OK. I updated, but I guess I didn't get your changes for some reason. I changed the instructions.


One more thing: for the CLEAN target in the makefile, you should move the line ${DELETECOMMAND} ${EXE} ${TRUTH} from the top of the lsit to the bottom, so even if the exe doesn't exist, it will remove everything else.
[u][url=http://bash.org/?577451]#577451[/url][/u]
Nach
ZSNES Developer
ZSNES Developer
Posts: 3904
Joined: Tue Jul 27, 2004 10:54 pm
Location: Solar powered park bench
Contact:

Post by Nach »

Noxious Ninja wrote:so even if the exe doesn't exist, it will remove everything else.
It does. But since you're using msys it probably doesn't work.

Is it so hard to download this? ftp://ftp.delorie.com/pub/djgpp/current ... k3791b.zip

Don't use msys, use a real make, don't start renaming files and stuff, it's not a big deal.
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding
Noxious Ninja
Dark Wind
Posts: 1271
Joined: Thu Jul 29, 2004 8:58 pm
Location: Texas
Contact:

Post by Noxious Ninja »

EDIT: Then could you please give me instructions on how to get it working without MSYS? I frankly can't figure it out. :?
[u][url=http://bash.org/?577451]#577451[/url][/u]
Nach
ZSNES Developer
ZSNES Developer
Posts: 3904
Joined: Tue Jul 27, 2004 10:54 pm
Location: Solar powered park bench
Contact:

Post by Nach »

Noxious Ninja wrote:EDIT: Then could you please give me instructions on how to get it working without MSYS? I frankly can't figure it out. :?
Which detail mentioned in install.txt couldn't you figure out?
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding
Noxious Ninja
Dark Wind
Posts: 1271
Joined: Thu Jul 29, 2004 8:58 pm
Location: Texas
Contact:

Post by Noxious Ninja »

Never mind, I got it to work.

Frankly, the DJGPP make sucks. As in, it doesn't work right and won't compile. MinGW comes with a version of make, and while it hasn't been updated in a while, it works fine.
DJGPP make wrote:C:\src\ZSNES-~3\src>make -f makefile.ms PLATFORM=win32
gcc -O3 -march=i586 -ffast-math -fomit-frame-pointer -fno-unroll-loops -Wall -Wno-unused -D__WIN32__ -o chips/dsp1emu.obj -c chips/dsp1emu.c
make.exe: *** [chips/dsp1emu.obj] Error -1
I'll change the instructions. But could you please just add that block to the makefile so I personally can use msys and be happy?
[u][url=http://bash.org/?577451]#577451[/url][/u]
Noxious Ninja
Dark Wind
Posts: 1271
Joined: Thu Jul 29, 2004 8:58 pm
Location: Texas
Contact:

Post by Noxious Ninja »

How's this? The renaming thing isn't me, it comes straight from the libpng compile instructions.

Code: Select all

Building the Windows port with MinGW:

Things you need:

- The ZSNES source code. You can download a package or get this from CVS.

- MinGW: http://www.mingw.org/
- Win32API: http://www.mingw.org/

- Minimal DirectX 8 SDK for MinGW: http://www.talula.demon.co.uk/allegro/

Win32API 3.2 includes the DirectX libraries required for ZSNES, but it doesn't
include all the headers. Future versions of Win32API may eliminate this
requirement.

- NASM v0.98.39: http://nasm.sf.net/ 

- zlib: http://www.gzip.org/zlib/
- libpng: http://www.libpng.org/


1) Install MinGW. From here on, the directory you installed it to will be
   referred to as MinGW\.
   
   After you finish the installation, and your MinGW\bin directory to your
   PATH.


2) Install Win32API by copying it to your MinGW directory and overwriting
   any existing files.


3) Extract the Minimal DirectX 8 SDK archive and copy everything in the
   include directory to your MinGW\include directory. Do not overwrite any
   existing files. You do not need the files in the lib directory of
   the archive.


4) Install NASM. Extract nasmw.exe to your MinGW\bin directory and rename it
   to nasm.exe.


5) Extract zlib, libpng, and the ZSNES source. To ease compilation, we
   recommend placing everything in the same root directory. Like so:
   
   |-src
   |----zlib
   |----libpng
   |----zsnes
   
   When you extract zlib and libpng, you will get directories with version
   numbers in the name, such as libpng-1.2.8 and zlib-1.2.1. You will need to
   rename these and remove the version numbers as shown in the diagram.


6) Go to your src\zlib directory. Run the following commands:
   
   copy win32\makefile.gcc makefile.gcc
   mingw32-make -f makefile.gcc
   
   After zlib compiles, copy zlib.h and zconf.h to MinGW\include
   and libz.a to MinGW\lib.


7) Go to your src\libpng directory. Run the following commands:
   
   cp scripts\makefile.gcc makefile
   mingw32-make
   
   Now copy png.h and pngconf.h to MinGW\include and libpng.a
   to MinGW\lib.


8) Go to your src\zsnes\src directory. Run the following commands:
    
   mingw32-make -f makefile.ms PLATFORM=win32

If everything went well, you will end up with a zsnesw.exe file.

You may want to compress zsnesw.exe with upx (http://upx.sourceforge.net).
This will reduce the filesize from over 3MB to around 500KB.
[u][url=http://bash.org/?577451]#577451[/url][/u]
Nach
ZSNES Developer
ZSNES Developer
Posts: 3904
Joined: Tue Jul 27, 2004 10:54 pm
Location: Solar powered park bench
Contact:

Post by Nach »

Noxious Ninja wrote: Frankly, the DJGPP make sucks. As in, it doesn't work right and won't compile. MinGW comes with a version of make, and while it hasn't been updated in a while, it works fine.
You have that completely backwards.

I don't know why you're having problems, but ipher and I use DJGPP make and have no problems.

MinGW make is so stupid, it doesn't even recognize DOS commands, and hence does not work.
Noxious Ninja wrote: I'll change the instructions. But could you please just add that block to the makefile so I personally can use msys and be happy?
No since to work for msys it would need a lot of changes what you have alone does not work as you've already mentioned in some ways. I don't see why you're not cross compiling if you're using msys.
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding
Noxious Ninja
Dark Wind
Posts: 1271
Joined: Thu Jul 29, 2004 8:58 pm
Location: Texas
Contact:

Post by Noxious Ninja »

Nach wrote:No since to work for msys it would need a lot of changes what you have alone does not work as you've already mentioned in some ways. I don't see why you're not cross compiling if you're using msys.
The problem with make clean was actually with the return code from rm when the file didn't exist. I changed it to rm -f and now it's been working for me with seemingly zero issues. What exactly are these lots of changes?
[u][url=http://bash.org/?577451]#577451[/url][/u]
Aerdan
Winter Knight
Posts: 467
Joined: Mon Aug 16, 2004 10:16 pm
Contact:

Post by Aerdan »

Nach wrote:
Noxious Ninja wrote: Frankly, the DJGPP make sucks. As in, it doesn't work right and won't compile. MinGW comes with a version of make, and while it hasn't been updated in a while, it works fine.
You have that completely backwards.

I don't know why you're having problems, but ipher and I use DJGPP make and have no problems.
DJGPP's make is a bit myopic and doesn't handle LFNs. This is fine for ZSNES, where nothing exceeds 8.3 standards, but not for compiling anything else.
Nach wrote:MinGW make is so stupid, it doesn't even recognize DOS commands, and hence does not work.
Explain why I am able to compile ZSNES just fine with mingw32-make, then? I haven't gotten any errors in cmd.exe about it not finding a command. [And no, I haven't been using the make from unxtools because I don't see the point in doing that when mingw32-make works just fine, despite your comments saying otherwise.]
Nach
ZSNES Developer
ZSNES Developer
Posts: 3904
Joined: Tue Jul 27, 2004 10:54 pm
Location: Solar powered park bench
Contact:

Post by Nach »

Noxious Ninja wrote:
Nach wrote:No since to work for msys it would need a lot of changes what you have alone does not work as you've already mentioned in some ways. I don't see why you're not cross compiling if you're using msys.
The problem with make clean was actually with the return code from rm when the file didn't exist. I changed it to rm -f and now it's been working for me with seemingly zero issues. What exactly are these lots of changes?
\, del to rm -f, possibly other things. Again, why aren't you just cross compiling?
Vareni Stargazer wrote:
Nach wrote:
Noxious Ninja wrote: Frankly, the DJGPP make sucks. As in, it doesn't work right and won't compile. MinGW comes with a version of make, and while it hasn't been updated in a while, it works fine.
You have that completely backwards.

I don't know why you're having problems, but ipher and I use DJGPP make and have no problems.
DJGPP's make is a bit myopic and doesn't handle LFNs. This is fine for ZSNES, where nothing exceeds 8.3 standards, but not for compiling anything else.
For this reason, I am now recommending to use unxutils make in the latest install.txt, as it offers the correctness of DJGPP's with full LFN support.
Vareni Stargazer wrote:
Nach wrote:MinGW make is so stupid, it doesn't even recognize DOS commands, and hence does not work.
Explain why I am able to compile ZSNES just fine with mingw32-make, then? I haven't gotten any errors in cmd.exe about it not finding a command. [And no, I haven't been using the make from unxtools because I don't see the point in doing that when mingw32-make works just fine, despite your comments saying otherwise.]
It doesn't give an error that del is not found?
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding
Aerdan
Winter Knight
Posts: 467
Joined: Mon Aug 16, 2004 10:16 pm
Contact:

Post by Aerdan »

Okay, I remembered wrongly...

However, msys's make works the same way Linux's make does; e.g., if the shell doesn't catch it, then it looks in $PATH, otherwise it returns 127.

Blame the Linux operating style, since 'rm' is not a shell command, but a program in and of itself.
Nach
ZSNES Developer
ZSNES Developer
Posts: 3904
Joined: Tue Jul 27, 2004 10:54 pm
Location: Solar powered park bench
Contact:

Post by Nach »

No, I blame whoever made a make without putting in an exception list.
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding
Aerdan
Winter Knight
Posts: 467
Joined: Mon Aug 16, 2004 10:16 pm
Contact:

Post by Aerdan »

Actually, MSYS's make shouldn't support what isn't there in the first place ['del' is not a valid command in MSYS], so there's no reason to be acting like msys's make is a PoS just because it doesn't recognise commands that sh doesn't recognise or that aren't in MSYS's $PATH.
Nach
ZSNES Developer
ZSNES Developer
Posts: 3904
Joined: Tue Jul 27, 2004 10:54 pm
Location: Solar powered park bench
Contact:

Post by Nach »

Vareni Stargazer wrote:Actually, MSYS's make shouldn't support what isn't there in the first place ['del' is not a valid command in MSYS], so there's no reason to be acting like msys's make is a PoS just because it doesn't recognise commands that sh doesn't recognise or that aren't in MSYS's $PATH.
My attack is more directed at MinGW's make.
If you're going to make a Windows program, make it work with Windows.

I still don't understand why you're using MSYS when if you follow instructions, it compiles fine.
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding
Noxious Ninja
Dark Wind
Posts: 1271
Joined: Thu Jul 29, 2004 8:58 pm
Location: Texas
Contact:

Post by Noxious Ninja »

Nach wrote:I still don't understand why you're using MSYS when if you follow instructions, it compiles fine.
1) I like bash. cmd.exe is kind of limiting.

2) Using a recent ATi card makes running Linux kind of bleh.
[u][url=http://bash.org/?577451]#577451[/url][/u]
Nach
ZSNES Developer
ZSNES Developer
Posts: 3904
Joined: Tue Jul 27, 2004 10:54 pm
Location: Solar powered park bench
Contact:

Post by Nach »

Noxious Ninja wrote: 1) I like bash. cmd.exe is kind of limiting.
Then cross compile it.
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding
Noxious Ninja
Dark Wind
Posts: 1271
Joined: Thu Jul 29, 2004 8:58 pm
Location: Texas
Contact:

Post by Noxious Ninja »

Nach wrote:
Noxious Ninja wrote: 1) I like bash. cmd.exe is kind of limiting.
Then cross compile it.
If my response #2 didn't answer that, then you must be using some definition of cross-compile I am not familiar with
[u][url=http://bash.org/?577451]#577451[/url][/u]
Nach
ZSNES Developer
ZSNES Developer
Posts: 3904
Joined: Tue Jul 27, 2004 10:54 pm
Location: Solar powered park bench
Contact:

Post by Nach »

Apparently.
Read the instructions for cross compilation. You're not using a cross compiler, but you're using a cross enviroment.
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding
Noxious Ninja
Dark Wind
Posts: 1271
Joined: Thu Jul 29, 2004 8:58 pm
Location: Texas
Contact:

Post by Noxious Ninja »

Oh, I see. Unfortunately, that doesn't quite work perfectly because MSYS needs rm -f instead of rm, but that's probably an MSYS issue. Thanks for putting up with my "annoying bordering on moronic" comments. :D
[u][url=http://bash.org/?577451]#577451[/url][/u]
Post Reply