Howto: Compile zsnes on amd64

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

Moderator: ZSNES Mods

Post Reply
Jester
New Member
Posts: 6
Joined: Wed Jan 26, 2005 9:02 pm

Howto: Compile zsnes on amd64

Post by Jester »

For those who would like to compile the latest WIP on their amd64 linux system, here is a simple procedure I used to compile the WIP from January 5. If you're using Gentoo, you can simply skip to the bottom of this post and grab the modified ebuild I pasted, put it in your overlay and name it something like "zsnes-1.42_p20060105.ebuild". The _p means "patch level", it's just to indicate to portage that the package is more recent than 1.42, the rest is the release date of the WIP. If you don't know how to use an overlay, go there.

Before we start, make sure you have NASM, GCC and zlib installed, and optionally libpng and an opengl driver (refer to documentation). You also need a 32-bit version of libsdl >= 1.2.0. If you are using gentoo, it's as simple as:

Code: Select all

emerge emul-linux-x86-sdl 

For other distros, refer to your package manager or install a 32-bit SDL manually. It should be as easy as getting the rpm here and extracting it (use rpm2targz or alien) somewhere like /usr/lib32.

First get the WIP here and unpack it

Code: Select all

mkdir zsnes && tar xjvf ZSNESS_0105.tar.bz2 -C zsnes && cd zsnes/src/
Now we pass some environment variables before creating the configure script. If you are using another system than gentoo, replace /emul/linux/x86/usr/lib with the dir where you put your 32-bit libsdl (eg. /usr/lib32)

Code: Select all

export CFLAGS="-m32 -L/emul/linux/x86/usr/lib" 
Generate the configure script and run it (some things are optional of course, eg. --enable-opengl). Then compile with make.

Code: Select all

aclocal && autoconf
./configure --prefix=/usr/games --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --mandir=/usr/share/man --infodir=/usr/share/info --datadir=/usr/share/games --sysconfdir=/etc/games --localstatedir=/var/games --enable-libpng --enable-opengl
make 
You've probably noticed at the end of compilation lots of warnings. You can just ignore them except this one:

Code: Select all

/usr/lib/gcc/x86_64-pc-linux-gnu/3.4.4/../../../../x86_64-pc-linux-gnu/bin/ld: warning: i386:x86-64 architecture of input file `cfgparse.o' is incompatible with i386 output 
I've found that cfgparse was the only object that didn't compile in 32-bit instead of 64-bit, for some reason. So we are just going to recompile it and re-link the zsnes executable. If you don't do that, zsnes will just segfault when you run it. Finally install zsnes.

Code: Select all

./parsegen -D__UNIXSDL__ temppsr.c cfgparse.psr
x86_64-pc-linux-gnu-gcc -m32 -I. -O1 -o cfgparse.o -c temppsr.c
make
make install 
Notes:
-This will NOT work for zsnes 1.42, apparently gentoo applies a patch to configure.in file before compiling. I can't find this patch on the bugzilla, but if someone wants it to be able to compile this version, just ask I'll post it
-This probably works for FreeBSD 64-bit also, just use gmake instead of make

Ebuild modified to install the WIP instead of 1.42. I'd be interested to know if that ebuild works on x86 systems too :

Code: Select all

# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

inherit eutils flag-o-matic games

DESCRIPTION="SNES (Super Nintendo) emulator that uses x86 assembly"
HOMEPAGE="http://www.zsnes.com/ http://ipherswipsite.com/zsnes/"
MY_P="ZSNESS_0105"
SRC_URI="http://files.ipherswipsite.com/zsnes/${MY_P}.tar.bz2"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="-* amd64 x86"
IUSE="opengl png"

RDEPEND=">=media-libs/libsdl-1.2.0
    >=sys-libs/zlib-1.1
    amd64? ( app-emulation/emul-linux-x86-sdl )
    opengl? ( virtual/opengl )
    png? ( media-libs/libpng )"
DEPEND="${RDEPEND}
    >=dev-lang/nasm-0.98
    sys-devel/automake
    >=sys-devel/autoconf-2.58"

S="${WORKDIR}"

pkg_setup() {
    use amd64 || return 0
    if has_m32 ; then
        export ABI=x86
    else
        eerror "Your compiler seems to be unable to compile 32bit code."
        eerror "Make sure you compile gcc with:"
        echo
        eerror "    USE=multilib FEATURES=-sandbox"
        die "Cannot produce 32bit code"
    fi
    games_pkg_setup
}

src_unpack() {
    unpack ${A}
    cd "${S}"/src
    cp "icons/48x48x32.png" "${T}/zsnes.png"
    aclocal && autoconf || die "autotools failed"
}

src_compile() {
    cd src
    egamesconf \
        $(use_enable png libpng) \
        $(use_enable opengl) \
        || die
    emake || die "emake failed"
}

src_install() {
    dogamesbin src/zsnes || die "dogamesbin failed"
    newman src/linux/zsnes.1 zsnes.6
    dodoc docs/{*.txt,README.LINUX}
    dohtml -r docs/Linux/*
    make_desktop_entry zsnes ZSNES zsnes.png
    doicon "${T}/zsnes.png"
    prepgamesdirs
}
Last edited by Jester on Sat Feb 11, 2006 4:59 am, edited 2 times in total.
Hyos
Regular
Posts: 207
Joined: Mon Aug 15, 2005 2:15 pm

Post by Hyos »

Although I do not have an amd64 it is nice to see someone contributing. Perhaps this could/should be added to the documentation?
Jipcy
Veteran
Posts: 768
Joined: Thu Feb 03, 2005 8:18 pm
Contact:

Post by Jipcy »

Traditionally, build instructions haven't been added to the main docs, but instead included with the source as separate instructions with the source.

I suppose at some point in the future this could change.
[url=http://zsnes-docs.sf.net]Official ZSNES Docs[/url] | [url=http://zsnes-docs.sf.net/nsrt]NSRT Guide[/url] | [url=http://endoftransmission.net/phpBB3/viewtopic.php?t=394]Using a Wiimote w/ emulators[/url]
gozza11

not working on fedora 4

Post by gozza11 »

nice to see that zsnes works on x86_64.

However i just cannot get it to work on fedora core 4 x86_64. i have tried the rpm provided by yum, tried the 32 bit rpm, tried manually compiling and even tried to follow your steps for compiling on 64. none of them worked. your steps and any other compiling process returns an error message

Code: Select all

g++ -m32 -L/usr/lib -pipe -I. -I/usr/local/include -I/usr/include -D__UNIXSDL__  -I/usr/include/SDL -D_REENTRANT -DNO_PNG -D__OPENGL__ -O3 -fomit-frame-pointer -s -march=athlon64 -fno-rtti -o parsegen parsegen.cpp
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/4.0.2/libstdc++.so when searching for -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/4.0.2/libstdc++.a when searching for -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/4.0.2/libstdc++.so when searching for -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/4.0.2/libstdc++.a when searching for -lstdc++
/usr/bin/ld: cannot find -lstdc++
collect2: ld returned 1 exit status
make: *** [parsegen] Error 1

the 64bit rpm just return "Illegal instruction" and segmentation faults when attempting to run.

the 32bit rpm is the closest i could get where the gui loads but no rom would load popping out an error about libc.so (glib i think).

all i really want to do is run this emulator since nothing else works.


so i guess what i am asking here is whether anyone knows how to get this compiled in fedora core 4.
even if someone could give me binarys for a 64 build (could that work?)

anything really, i tried wine and vmware but nothing seems to work.


thanks
goran
xgylee

Re: not working on fedora 4

Post by xgylee »

I run the 0219 WIP under Fedora Core 4 x86_64 and have no problem whatsoever.

It is not the 64-bit version though, since the latter always fails during compilation.

What I did was to compile the source under Fedora Core 4 i386 (32-bit), and copy the resulting zsnes executable to my 64-bit machine.

I don't know what kind of dependencies are required under the 64-bit machine though. I guess, it might need the 32-bit version of the glibc, but it should be available in the distro's CDs.
Post Reply