Compiling ZSNES with MinGW - For Beginners

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

Moderator: ZSNES Mods

AspiringSquire
Born to Rule... Impatiently
Posts: 265
Joined: Wed Nov 17, 2004 8:21 pm
Location: Everywhere I want to be.
Contact:

Compiling ZSNES with MinGW - For Beginners

Post by AspiringSquire »

Is anyone willing to give a detailed walkthrough for compiling ZSNES with MinGW? I have downloaded the necessary components, as listed in 'install.txt', but I have no idea where to start (or where to go after that, either). The only compiling I've done before was completely self-contained within the compiler, which was also the source code editor.

As far as I can tell, the information given in the ZSNES installation instructions was meant for experts only. It disregards essential details such as:

* which .exe application(s) to run
* the relative locations of all components (placement required for successful compiling)
* how to compile/deal with zlib and libpng
* how NASM and MinGW relate/interact/whatever

Again, which program should be run when? And for what?

These are the most basic of beginnings for just getting started; why doesn't 'install.txt' offer more than just a pre-starting point (component list) and a single command-line instruction? :?

Help would be greatly appreciated. :)
[url=http://board.zsnes.com/phpBB2/viewtopic.php?t=3298][color=brown]My [u]NES palette[/u][/color][/url] - better colors with any emulator.

"the more you know, and the more you can do... the more you are."
- [url=http://www.danielbohman.com][color=brown][u]daniel bohman[/u][/color][/url]
Nach
ZSNES Developer
ZSNES Developer
Posts: 3904
Joined: Tue Jul 27, 2004 10:54 pm
Location: Solar powered park bench
Contact:

Re: Compiling ZSNES - For Beginners

Post by Nach »

AspiringSquire wrote: * which .exe application(s) to run
Once everything is setup only one thing is required, run the make line mentioned in install.txt
AspiringSquire wrote: * the relative locations of all components (placement required for successful compiling)
* how to compile/deal with zlib and libpng
That is covered by the instrunctions that came with your compiler and libraries.
AspiringSquire wrote: * how NASM and MinGW relate/interact/whatever
They don't.
AspiringSquire wrote: Again, which program should be run when? And for what?

These are the most basic of beginnings for just getting started; why doesn't 'install.txt' offer more than just a pre-starting point (component list) and a single command-line instruction? :?
We tell you what you need to have installed, we'd expect you to read the instructions for the other software to install it. Once you have all the requirements installed, it is only a single command line instruction to compile ZSNES.

True you can have a 10-15 step by step guide to setup all the software ZSNES requires to be compiled, but that's not our job.
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding
Dead
Lurker
Posts: 118
Joined: Sat Sep 25, 2004 10:59 am
Location: I don't know where I am

Re: Compiling ZSNES - For Beginners

Post by Dead »

AspiringSquire wrote:Is anyone willing to give a detailed walkthrough for compiling ZSNES with MinGW?
Nach is right.

However, you got off easy this time. What you want is in this thread.

Don't go by the first walkthrough, instead, scroll to the bottom of the page and follow that one. You may have to improvise. That's where all the fun is!
xamenus
Veteran
Posts: 907
Joined: Fri Jul 30, 2004 12:26 am

Post by xamenus »

Here's NN's how to, with some slight edits, for beginners at compiling ZSNES using Windows. ;)

Code: Select all

First things first: Do this to make it easier to use the command prompt:

   1. In explorer, open Tools, Folder Options.
   2. Select the File Types tab.
   3. For Windows XP: Go to NONE / Folder.
   4. For Windows 2000: Press n to scroll to the N/A section.
   5. For Windows NT/98/95: Press f to scroll to the Folders section.
   6. Select the entry labeled Folder
   7. For Windows 2000/XP: Press Advanced button.
   8. For Windows NT/98/95: Press Edit button.
   9. Select New
  10. In the action block type "Command Prompt" without the quotes.
  11. In the app block type "cmd.exe" without the quotes.
  12. Save and exit Folder Options.

Now you can just right-click on a folder in Windows, choose Command Prompt, and the command prompt will open and will be at that folder. 
Thanks to this site for providing that info! I didn't try that myself, but it should work.

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/

*Make sure that you download the source codes for zlib and libpng, not the binaries.


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


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 nasmw.exe 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) Launch the command prompt at your src\zlib directory (just right click on that folder and choose Command Prompt). Run the two 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) Launch the command prompt your src\libpng directory. Run the two following commands:
   
   copy scripts\makefile.gcc makefile
   mingw32-make
   
   Now copy png.h and pngconf.h to MinGW\include and libpng.a
   to MinGW\lib.


8) Launch the command prompt at your src\zsnes\src directory. Run the following command:
   
   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 (optional), which can be downloaded at http://upx.sf.net.
This will reduce the filesize from over 3MB to around 500KB.
Last edited by xamenus on Wed Mar 09, 2005 1:33 am, edited 2 times in total.
Noxious Ninja
Dark Wind
Posts: 1271
Joined: Thu Jul 29, 2004 8:58 pm
Location: Texas
Contact:

Post by Noxious Ninja »

hit wrote:
AspiringSquire wrote:Is anyone willing to give a detailed walkthrough for compiling ZSNES with MinGW?
Nach is right.

However, you got off easy this time. What you want is in this thread.
Go me. :P Nach could have at least mentioned it...
Don't go by the first walkthrough, instead, scroll to the bottom of the page and follow that one. You may have to improvise. That's where all the fun is!
Both of them work, just the bottom one is a bit easier to do.
IceFox wrote:Now you can just right-click on a folder in Windows, choose Command Prompt, and the command prompt will open and will be at that folder.

Thanks to this site for providing that info! I didn't try that myself, but it should work.
For Windows XP, you can just install the Command Here Powertoy, which happens to be linked on that page. :P
[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: Go me. :P Nach could have at least mentioned it...
Yes, I could have.
Noxious Ninja wrote: For Windows XP, you can just install the Command Here Powertoy, which happens to be linked on that page. :P
PowerToys for Win95 has it too.
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding
Rondoudou
Rookie
Posts: 13
Joined: Sun Nov 07, 2004 5:48 pm

Post by Rondoudou »

it's work fine, thank you very much!
AspiringSquire
Born to Rule... Impatiently
Posts: 265
Joined: Wed Nov 17, 2004 8:21 pm
Location: Everywhere I want to be.
Contact:

Post by AspiringSquire »

Nach wrote:True you can have a 10-15 step by step guide to setup all the software ZSNES requires to be compiled, but that's not our job.
I know that. I wasn't asking for help directly from developers; I was just pointing out the limited usefulness of the instructions in 'install.txt'.

IceFox, and especially Noxious Ninja, thanks for that detailed walkthrough! :)
Unfortunately, though, I can't figure out what I need to do to set the PATH variable:

Code: Select all

1) Install MinGW. From here on, the directory you installed it to will be
   referred to as MinGW\.
   
   After you finish the installation, add your MinGW\bin directory to your
   PATH environment variable.
I've only managed to get through the first 5 steps, and that is because this part of step 1 still isn't clear. I tried having that directory as the starting location and alternatively tried entering the full path when executing the commands, but neither method got very far.

May I ask for a bit more help, please? ;)

[And would asking how to download all files from CVS be opening a whole new can of worms? :P]
[url=http://board.zsnes.com/phpBB2/viewtopic.php?t=3298][color=brown]My [u]NES palette[/u][/color][/url] - better colors with any emulator.

"the more you know, and the more you can do... the more you are."
- [url=http://www.danielbohman.com][color=brown][u]daniel bohman[/u][/color][/url]
Dead
Lurker
Posts: 118
Joined: Sat Sep 25, 2004 10:59 am
Location: I don't know where I am

Post by Dead »

AspiringSquire wrote:[And would asking how to download all files from CVS be opening a whole new can of worms? :P]
Yes.
The instructions are all on the Sourceforge CVS page.


Here's how to set the PATH:

In WinXP, press WindowsKey + Pause/Break to bring up System Properties
Navigate to the Advanced tab
press alt + N for Environment Variables
alt + S for System Variables scrollbox
navigate to the "path" entry
add the path to ~\mingw\bin
Last edited by Dead on Thu Feb 03, 2005 12:31 am, edited 1 time in total.
funkyass
"God"
Posts: 1128
Joined: Tue Jul 27, 2004 11:24 pm

Post by funkyass »

its should be "x:\MinGW\bin", where x is the drive you installed mingw to, thats what you add the path statement.

you add the path statement via Control Panel->System->Advanced->Environment Varibles.

in user varibles, select PATH, add a semi-colon to the end, then add the above.

click ok, close the system control panel, then log off and log back on.


IF you need a 15-step guide, you shouldn't be compiling zsnes - you gain little benefit in doing so.
Dead
Lurker
Posts: 118
Joined: Sat Sep 25, 2004 10:59 am
Location: I don't know where I am

Post by Dead »

funkyass wrote:IF you need a 15-step guide, you shouldn't be compiling zsnes - you gain little benefit in doing so.
That's a really good point. It is possible to get source code that compiles into a "broken" ZSNES if you fetch it from CVS. Also, the ZSNES devs have good judgment. They know when it is an appropriate time to release a WIP.


So, since I was able to learn to get the source from CVS and compile it myself with absolutely no prior experience with this stuff, and without asking for help, does that mean I have a shot at one day learning enough to contribute to the development of an emulator? I would really like to help, but I have yet to learn to code, and I don't yet have an in-depth understanding of the SNES hardware.
Last edited by Dead on Thu Feb 03, 2005 12:40 am, edited 1 time in total.
Nach
ZSNES Developer
ZSNES Developer
Posts: 3904
Joined: Tue Jul 27, 2004 10:54 pm
Location: Solar powered park bench
Contact:

Post by Nach »

hit wrote:
funkyass wrote:IF you need a 15-step guide, you shouldn't be compiling zsnes - you gain little benefit in doing so.
That's a really good point. It is possible to get source code that compiles into a "broken" ZSNES if you fetch it from CVS. Also, the ZSNES devs have good judgment. They know when it is an appropriate time to release a WIP.
Excellent point. Currently the code in developer CVS right now is good and should be made into a WIP, but ipher isn't around...
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding
AspiringSquire
Born to Rule... Impatiently
Posts: 265
Joined: Wed Nov 17, 2004 8:21 pm
Location: Everywhere I want to be.
Contact:

Post by AspiringSquire »

hit wrote:
funkyass wrote:IF you need a 15-step guide, you shouldn't be compiling zsnes - you gain little benefit in doing so.
That's a really good point. It is possible to get source code that compiles into a "broken" ZSNES if you fetch it from CVS. Also, the ZSNES devs have good judgment. They know when it is an appropriate time to release a WIP.
Hey, I'm just trying to have the fun of using a feature before an official or WIP release. :) Even if the CVS code isn't completely stable, I can still use the lastest versions of specific files that have implemented a new feature or fix that I want to try.

And what if a new version is unstable, but it flawlessly implements something new? Solution: use the updated files for that one thing, and use the previous source release for everything else.
[url=http://board.zsnes.com/phpBB2/viewtopic.php?t=3298][color=brown]My [u]NES palette[/u][/color][/url] - better colors with any emulator.

"the more you know, and the more you can do... the more you are."
- [url=http://www.danielbohman.com][color=brown][u]daniel bohman[/u][/color][/url]
Dead
Lurker
Posts: 118
Joined: Sat Sep 25, 2004 10:59 am
Location: I don't know where I am

Post by Dead »

AspiringSquire wrote:Hey, I'm just trying to have the fun of using a feature before an official or WIP release. :)
That's a good point too. Seems like good points are all the rage these days..


I thought about this for awhile. In most cases, by the time you updated the source from anonymous CVS, the devs would have found and fixed any major problems anyway. So maybe my original point wasn't so good after all.
AspiringSquire
Born to Rule... Impatiently
Posts: 265
Joined: Wed Nov 17, 2004 8:21 pm
Location: Everywhere I want to be.
Contact:

Post by AspiringSquire »

Okay, now I have no idea what's wrong.

Code: Select all

D:\Games\Emulators\SNES emu\ZSNES Source\ZSNESS_0131\zlib>copy win32\makefile.gc
c makefile.gcc
Overwrite makefile.gcc? (Yes/No/All): y
        1 file(s) copied.

D:\Games\Emulators\SNES emu\ZSNES Source\ZSNESS_0131\zlib>mingw32-make -f makefi
le.gcc
gcc  -O3 -Wall -c -o adler32.o adler32.c
gcc  -O3 -Wall -c -o compress.o compress.c
gcc  -O3 -Wall -c -o crc32.o crc32.c
gcc  -O3 -Wall -c -o deflate.o deflate.c
gcc  -O3 -Wall -c -o gzio.o gzio.c
gcc  -O3 -Wall -c -o infback.o infback.c
gcc  -O3 -Wall -c -o inffast.o inffast.c
gcc  -O3 -Wall -c -o inflate.o inflate.c
gcc  -O3 -Wall -c -o inftrees.o inftrees.c
gcc  -O3 -Wall -c -o trees.o trees.c
gcc  -O3 -Wall -c -o uncompr.o uncompr.c
gcc  -O3 -Wall -c -o zutil.o zutil.c
ar rcs libz.a adler32.o compress.o crc32.o deflate.o gzio.o infback.o inffast.o
inflate.o inftrees.o trees.o uncompr.o zutil.o
windres --define GCC_WINDRES -o zlibrc.o win32/zlib1.rc
windres: win32/zlib1.rc:9: syntax error
mingw32-make: *** [zlibrc.o] Error 1
(Text is wrapping to the window size.)

I followed the instructions for setting PATH under 'User'.
[url=http://board.zsnes.com/phpBB2/viewtopic.php?t=3298][color=brown]My [u]NES palette[/u][/color][/url] - better colors with any emulator.

"the more you know, and the more you can do... the more you are."
- [url=http://www.danielbohman.com][color=brown][u]daniel bohman[/u][/color][/url]
funkyass
"God"
Posts: 1128
Joined: Tue Jul 27, 2004 11:24 pm

Post by funkyass »

now you need a compiled version of zlib, and the zlib sources.
Noxious Ninja
Dark Wind
Posts: 1271
Joined: Thu Jul 29, 2004 8:58 pm
Location: Texas
Contact:

Post by Noxious Ninja »

AspiringSquire wrote:Okay, now I have no idea what's wrong.
What zlib source package are you using?
[u][url=http://bash.org/?577451]#577451[/url][/u]
AspiringSquire
Born to Rule... Impatiently
Posts: 265
Joined: Wed Nov 17, 2004 8:21 pm
Location: Everywhere I want to be.
Contact:

Post by AspiringSquire »

Noxious Ninja wrote:What zlib source package are you using?
I have 1.2.2 — should I try an earlier version?
[url=http://board.zsnes.com/phpBB2/viewtopic.php?t=3298][color=brown]My [u]NES palette[/u][/color][/url] - better colors with any emulator.

"the more you know, and the more you can do... the more you are."
- [url=http://www.danielbohman.com][color=brown][u]daniel bohman[/u][/color][/url]
Noxious Ninja
Dark Wind
Posts: 1271
Joined: Thu Jul 29, 2004 8:58 pm
Location: Texas
Contact:

Post by Noxious Ninja »

AspiringSquire wrote:
Noxious Ninja wrote:What zlib source package are you using?
I have 1.2.2 — should I try an earlier version?
I didn't even know there was a 1.2.2. :shock: I finally found it on the libpng SF page - is that where you got yours? Try 1.2.1 from the official zlib site.

EDIT: Nevermind, I now see that zlib.net and gzip.org/zlib are different; apparantly the latter hasn't been updated in some time.

That doesn't explain the problem, though.
[u][url=http://bash.org/?577451]#577451[/url][/u]
AspiringSquire
Born to Rule... Impatiently
Posts: 265
Joined: Wed Nov 17, 2004 8:21 pm
Location: Everywhere I want to be.
Contact:

Post by AspiringSquire »

Noxious Ninja wrote:
AspiringSquire wrote:
Noxious Ninja wrote:What zlib source package are you using?
I have 1.2.2 — should I try an earlier version?
I didn't even know there was a 1.2.2. :shock: I finally found it on the libpng SF page - is that where you got yours? Try 1.2.1 from the official zlib site.

EDIT: Nevermind, I now see that zlib.net and gzip.org/zlib are different; apparantly the latter hasn't been updated in some time.

That doesn't explain the problem, though.
Yeah, I already tried 1.2.1, and that worked just fine. ;)
The png files compiled fine, too [1.2.8]. But I can't get zsnes to compile after everything else. :(
(I did copy the files as the instructions say.)

When ZSNES tries compiling, it gets through many things just fine, but there are two warnings for 'cfgload.c', and a really long list of warnings and errors with 'zunzip.h' and 'initc.c'—so long that I don't want to post it, but I could. What else do you think could have gone wrong?

EDIT: Nevermind. I double-checked and found that I had accidentally copied one wrong file instead of the right one. :oops:
I have zsnesw.exe! :D :P ;) :roll:

Thanks to all! :)
[url=http://board.zsnes.com/phpBB2/viewtopic.php?t=3298][color=brown]My [u]NES palette[/u][/color][/url] - better colors with any emulator.

"the more you know, and the more you can do... the more you are."
- [url=http://www.danielbohman.com][color=brown][u]daniel bohman[/u][/color][/url]
ipher
ZSNES Developer
ZSNES Developer
Posts: 269
Joined: Wed Jul 28, 2004 2:37 am
Contact:

Post by ipher »

Ahh, brings back memories of trying to get ZSNESW compiled for the first time with DJGPP and MSVC....
[url=http://www.ipherswipsite.com]ipher's WIP Site[/url]
Noxious Ninja
Dark Wind
Posts: 1271
Joined: Thu Jul 29, 2004 8:58 pm
Location: Texas
Contact:

Post by Noxious Ninja »

I was building it with DJGPP... 4 years ago? 5? Right after CVS opened up. It wasn't so hard, since ZSNES didn't have PNG output and I didn't have to mess with zlib or libpng.

I was even posting WIP version for a while on my old site. I don't know if anybody ever downloaded them or not. Heh.

I never had the money to buy MSVC, and by the time I found a copy on the net you had started doing your builds.
[u][url=http://bash.org/?577451]#577451[/url][/u]
Dead
Lurker
Posts: 118
Joined: Sat Sep 25, 2004 10:59 am
Location: I don't know where I am

Post by Dead »

Isn't MSVC a free download for Windows owners?
Noxious Ninja
Dark Wind
Posts: 1271
Joined: Thu Jul 29, 2004 8:58 pm
Location: Texas
Contact:

Post by Noxious Ninja »

Nope.
[u][url=http://bash.org/?577451]#577451[/url][/u]
Dead
Lurker
Posts: 118
Joined: Sat Sep 25, 2004 10:59 am
Location: I don't know where I am

Post by Dead »

Noxious Ninja wrote:Nope.
My bad. I thought this was it.
Post Reply