ZSNES with MinGW and MSYS
Moderator: ZSNES Mods
-
- Dark Wind
- Posts: 1271
- Joined: Thu Jul 29, 2004 8:58 pm
- Location: Texas
- Contact:
ZSNES with MinGW and MSYS
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.
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]
-
- ZSNES Developer
- Posts: 3904
- Joined: Tue Jul 27, 2004 10:54 pm
- Location: Solar powered park bench
- Contact:
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.
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
_____________
Insane Coding
-
- Dark Wind
- Posts: 1271
- Joined: Thu Jul 29, 2004 8:58 pm
- Location: Texas
- Contact:
Already doing that.Nach wrote:1) Use ZSNES CVS, I made a quite few changes for this today.
Works fine, thanks.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.
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.3) Do not use msys.
For some strange reason, it comes with the libs, but not the headers. The headers from the Allegro package work fine.4) DX should come with the latest Win32API, if not, get it from the Allegro team.
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]
-
- Dark Wind
- Posts: 1271
- Joined: Thu Jul 29, 2004 8:58 pm
- Location: Texas
- Contact:
OK, first the makefile. Add the following block after the ifeq (${CROSS},no) block.
You can also add this in there somewhere:
Now for the instructions. Somebody please double-check these to make sure I didn't miss anything.
Code: Select all
ifeq (${ENV},msys)
DELETECOMMAND=rm -f
SLASH=/
endif
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]
-
- ZSNES Developer
- Posts: 3904
- Joined: Tue Jul 27, 2004 10:54 pm
- Location: Solar powered park bench
- Contact:
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.
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
_____________
Insane Coding
-
- Dark Wind
- Posts: 1271
- Joined: Thu Jul 29, 2004 8:58 pm
- Location: Texas
- Contact:
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.Nach wrote:1) I don't see why you seem so bent on using msys.
Oh. OK. I updated, but I guess I didn't get your changes for some reason. I changed the instructions.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.
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]
-
- ZSNES Developer
- Posts: 3904
- Joined: Tue Jul 27, 2004 10:54 pm
- Location: Solar powered park bench
- Contact:
It does. But since you're using msys it probably doesn't work.Noxious Ninja wrote:so even if the exe doesn't exist, it will remove everything else.
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
_____________
Insane Coding
-
- Dark Wind
- Posts: 1271
- Joined: Thu Jul 29, 2004 8:58 pm
- Location: Texas
- Contact:
-
- ZSNES Developer
- Posts: 3904
- Joined: Tue Jul 27, 2004 10:54 pm
- Location: Solar powered park bench
- Contact:
Which detail mentioned in install.txt couldn't you figure out?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.
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding
_____________
Insane Coding
-
- Dark Wind
- Posts: 1271
- Joined: Thu Jul 29, 2004 8:58 pm
- Location: Texas
- Contact:
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.
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.
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?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
[u][url=http://bash.org/?577451]#577451[/url][/u]
-
- Dark Wind
- Posts: 1271
- Joined: Thu Jul 29, 2004 8:58 pm
- Location: Texas
- Contact:
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]
-
- ZSNES Developer
- Posts: 3904
- Joined: Tue Jul 27, 2004 10:54 pm
- Location: Solar powered park bench
- Contact:
You have that completely backwards.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.
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.
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.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?
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding
_____________
Insane Coding
-
- Dark Wind
- Posts: 1271
- Joined: Thu Jul 29, 2004 8:58 pm
- Location: Texas
- Contact:
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?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.
[u][url=http://bash.org/?577451]#577451[/url][/u]
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:You have that completely backwards.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.
I don't know why you're having problems, but ipher and I use DJGPP make and have no problems.
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 wrote:MinGW make is so stupid, it doesn't even recognize DOS commands, and hence does not work.
-
- ZSNES Developer
- Posts: 3904
- Joined: Tue Jul 27, 2004 10:54 pm
- Location: Solar powered park bench
- Contact:
\, del to rm -f, possibly other things. Again, why aren't you just cross compiling?Noxious Ninja wrote: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?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.
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: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:You have that completely backwards.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.
I don't know why you're having problems, but ipher and I use DJGPP make and have no problems.
It doesn't give an error that del is not found?Vareni Stargazer wrote: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 wrote:MinGW make is so stupid, it doesn't even recognize DOS commands, and hence does not work.
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding
_____________
Insane Coding
-
- ZSNES Developer
- Posts: 3904
- Joined: Tue Jul 27, 2004 10:54 pm
- Location: Solar powered park bench
- Contact:
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
_____________
Insane Coding
-
- ZSNES Developer
- Posts: 3904
- Joined: Tue Jul 27, 2004 10:54 pm
- Location: Solar powered park bench
- Contact:
My attack is more directed at MinGW's make.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.
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
_____________
Insane Coding
-
- Dark Wind
- Posts: 1271
- Joined: Thu Jul 29, 2004 8:58 pm
- Location: Texas
- Contact:
-
- ZSNES Developer
- Posts: 3904
- Joined: Tue Jul 27, 2004 10:54 pm
- Location: Solar powered park bench
- Contact:
Then cross compile it.Noxious Ninja wrote: 1) I like bash. cmd.exe is kind of limiting.
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding
_____________
Insane Coding
-
- Dark Wind
- Posts: 1271
- Joined: Thu Jul 29, 2004 8:58 pm
- Location: Texas
- Contact:
-
- ZSNES Developer
- Posts: 3904
- Joined: Tue Jul 27, 2004 10:54 pm
- Location: Solar powered park bench
- Contact:
Apparently.
Read the instructions for cross compilation. You're not using a cross compiler, but you're using a cross enviroment.
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
_____________
Insane Coding
-
- Dark Wind
- Posts: 1271
- Joined: Thu Jul 29, 2004 8:58 pm
- Location: Texas
- Contact: