anúncios

segunda-feira, 6 de outubro de 2014

Instalando ZSNES no Linux

Acredito que todos já tiveram um Super Nintendo (SNES) né, e pensa em recordar os jogos do SNES no computador com sistema operacional Linux.
Nesse caso é necessário instalar o ZSNES que é um emulador de Super Nintendo, assim pode fazer download das rooms [1] do jogo que tinha nas fitas do Super Nintendo.
Então nesse post, compartilho os procedimentos que realizei para instalar o ZSNES na distribuição Linux Debian.

No Slackware FULL, simplesmente executei $./configure && make; #make install e fez a instalação do ZSNES normalmente.
No Debian precisou fazer algumas configurações adicionais.
Download do ZSNES no site http://www.zsnes.com no link Linux, Download ZSNES Linux, será redirecionado o download do arquivo zsnes151src.tar.bz2.

Nota que optei por salvar o arquivo zsnes151src.tar.bz2 no diretório Downloads do meu /home, no seu caso escolha salvar onde achar melhor.
Antes de iniciar, é necessário instalar o compilador C e C++, se caso não tiver instalado no Debian.
#apt-get install gcc g++
Extrair o arquivo zsnes151src.tar.bz2 do download
reginaldo@Saitam:~/Downloads/$ tar -jxvf zsnes151src.tar.bz2
Acessar o diretório correspondente da extração
reginaldo@Saitam:~/Downloads$ cd zsnes_1_51/src
Executar o arquivo configure
reginaldo@Saitam:~/Downloads/zsnes_1_51/src$ ./configure
loading cache ./config.cache
checking for gcc... gcc
checking whether the C compiler (gcc -pipe -I. -Wall ) works... yes
checking whether the C compiler (gcc -pipe -I. -Wall ) is a cross-compiler... no
checking whether we are using GNU C... yes
checking whether gcc accepts -g... yes
checking for nasm... error:: command not found
checking for a BSD compatible install... /usr/bin/install -c
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
checking build system type... i686-pc-linux-gnu
checking how to run the C preprocessor... gcc -E
checking for X... libraries , headers
checking for sdl-config... /usr/bin/sdl-config
checking for SDL - version >= 1.2.0... no
*** Could not run SDL test program, checking why...
*** The test program failed to compile or link. See the file config.log for the
*** exact error that occured. This usually means SDL was incorrectly installed
*** or that you have moved SDL since it was installed. In the latter case, you
*** may want to edit the sdl-config script: /usr/bin/sdl-config
configure: error: SDL >= 1.2.0 is required


Solução: Instalar os pacotes Nasm e SDL correspondente.
root@Saitam:~/Downloads/zsnes_1_51/src# apt-get install nasm libsdl1.2-dev
Execute novamente o arquivo configure.
reginaldo@Saitam:~/Downloads/zsnes_1_51/src$ ./configure
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking for nasm... nasm
checking for sdl-config... /usr/bin/sdl-config
checking for SDL - version >= 1.2.0... yes
checking for zlib - version >= 1.2.3... yes
checking for libpng - version >= 1.2.0... yes
checking if you want the zsnes debugger... yes
checking for initscr in -lcurses... no
checking for initscr in -lncurses... no
checking for initscr in -lpdcurses... no
configure: error: A curses library is required to use the debugger


Solução: Instalar os pacotes ncurses e libncurses5-dev como segue:
root@Saitam:~/Downloads/zsnes_1_51/src# apt-get install ncurses libncurses5-dev Execute novamente o arquivo configure. reginaldo@Saitam:~/Downloads/zsnes_1_51/src$ ./configure
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking for nasm... nasm
checking for sdl-config... /usr/bin/sdl-config
checking for SDL - version >= 1.2.0... yes
checking for zlib - version >= 1.2.3... yes
checking for libpng - version >= 1.2.0... yes
checking if you want the zsnes debugger... yes
checking for initscr in -lcurses... yes
checking for initscr in -lncurses... yes
checking for initscr in -lpdcurses... no
checking if you want libao support... no
checking how to run the C preprocessor... gcc -E
checking for X... libraries , headers
checking for glGetError in -lGL... yes
checking for OpenGL... yes
checking for JMA support... yes
checking for cpu info... found
checking if you want gdb friendly executable... no
checking which cpu architecture to optimize for... native
checking if you want crazy optimizations... no
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking whether sys/types.h defines makedev... yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating config.h
ZSNES v1.51
SDL support Version 1.2.15
NASM support NASM version 2.10.01 compiled on Jun 14 2012
zlib support Version 1.2.7
PNG support Yes, version 1.2.49
OpenGL support Yes
JMA support Yes
ZSNES debugger Enabled
The binary will be installed in /usr/local/bin
Configure complete, now type 'make' and pray.
Nota que agora a execução do configure está OK, execute o make.
reginaldo@Saitam:~/Downloads/zsnes_1_51/src$ make
g++ -pipe -I. -I/usr/local/include -I/usr/include -D__UNIXSDL__ -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -
D__OPENGL__ -march=native -O3 -fomit-frame-pointer -s -fno-rtti -o tools/strutil.o -c tools/strutil.cpp
In file included from tools/strutil.cpp:22:0:
tools/strutil.h: In static member function ‘static int ci_char_traits::compare(const char*, const char*, size_t)’:
tools/strutil.h:34:96: error: ‘strncasecmp’ was not declared in this scope
make: ** [tools/strutil.o] Erro 1


reginaldo@Saitam:~/Downloads/zsnes_1_51/src$ make
g++ -pipe -I. -I/usr/local/include -I/usr/include -D__UNIXSDL__ -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -
D__OPENGL__ -march=native -O3 -fomit-frame-pointer -s -fno-rtti -o tools/depbuild tools/depbuild.cpp tools/fileutil.o tools/strutil.o
tools/depbuild.cpp: In function ‘void dependency_calculate(const char*, stat&)’:
tools/depbuild.cpp:167:37: error: ‘F_OK’ was not declared in this scope
tools/depbuild.cpp:167:41: error: ‘access’ was not declared in this scope
tools/depbuild.cpp: At global scope:
tools/depbuild.cpp:186:5: warning: first argument of ‘int main(size_t, const char* const*)’ should be ‘int’ [-Wmain]
make: ** [tools/depbuild] Erro 1


Opa, erro de compilação, aqui nesse ponto, deve incluir diretamente no código fonte do ZSNES.
No fonte /src/tools/strutil.h incluir a biblioteca como segue.
#include < string.h >
No mesmo diretório acima, no fonte depbuild.cpp incluir a biblioteca e o argumento da função main, como segue. #include < cstdlib >
int main (int argc, const char *const *const argv)
No fonte /src/parsegen.cpp incluir as bibliotecas , e mesma modificação feita no passo anterior da função main, como segue.
#include < cstdlib >
#include < cstring >
...
int main (int argc, const char *const *const argv)

Com as alterações necessárias realizadas corretamente como descritas aqui, pode executar o ./configure, make e make install como segue.

Execute novamente o arquivo configure.
reginaldo@Saitam:~/Downloads/zsnes_1_51/src$ ./configure
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking for nasm... nasm
checking for sdl-config... /usr/bin/sdl-config
checking for SDL - version >= 1.2.0... yes
checking for zlib - version >= 1.2.3... yes
checking for libpng - version >= 1.2.0... yes
checking if you want the zsnes debugger... yes
checking for initscr in -lcurses... yes
checking for initscr in -lncurses... yes
checking for initscr in -lpdcurses... no
checking if you want libao support... no
checking how to run the C preprocessor... gcc -E
checking for X... libraries , headers
checking for glGetError in -lGL... yes
checking for OpenGL... yes
checking for JMA support... yes
checking for cpu info... found checking if you want gdb friendly executable... no
checking which cpu architecture to optimize for... native
checking if you want crazy optimizations... no
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking whether sys/types.h defines makedev... yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating config.h

ZSNES v1.51

SDL support Version 1.2.15
NASM support NASM version 2.10.01 compiled on Jun 14 2012
zlib support Version 1.2.7
PNG support Yes, version 1.2.49
OpenGL support Yes
JMA support Yes
ZSNES debugger Enabled
The binary will be installed in /usr/local/bin
Configure complete, now type 'make' and pray.


Execute make para compilar.
reginaldo@Saitam:~/Downloads/zsnes_1_51/src$ make
Aguarde terminar compilação.

Execute make install como root para instalar
root@Saitam:~/Downloads/zsnes_1_51/src# make install

Procederá instalação, o binário do zsnes ficará em /usr/local/bin, utilize esse caminho para criar um atalho no menu.
Veja o resultado do room Top Gear clássico!


[1] Rooms SNES. http://www.roxdownload.net/roms/snes
Feito!