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!

14 comentários:

  1. Segui todos passos corretamente, porem na parte do erro de compilacao nao consegui importar as informacoes de forma correta no codigo fonte.

    Alguma dica?

    Abri os arquivos e inclui as informacoes.

    ResponderExcluir
    Respostas
    1. Dan Cargnin Faust, bom antes de editar os arquivos de códigos fontes é necessário ter instalado o compilador gcc e g++ que são compiladores de C e C++, com isso permite fazer compilação dos códigos fontes alterados.
      Após as alterações feitas nos fonte, execute o ./configure que irá informar se falta alguma dependência que informa no final quando ocorre erro de algum pacote. Finalizando o ./configure, hora de compilar com make e finalmente instalar com make install.

      Tente fazer, qualquer coisa deixe um comentário informando com detalhes do erro e a distribuição Linux que está utilizando.

      Excluir
  2. Olá, muito boa sua explicação, segui todos os passos e deu tudo certo, somente na hora de processar o "make" que apareceu outro erro...não to sabendo copiar e colar do terminal para cá, se puder, manda teu contato pra eu mandar! Muito obrigado.

    ResponderExcluir
    Respostas
    1. Unknown (Carlos David Silveira), faz o seguinte seleciona o erro no terminal, coloca no local onde deseja colar e clique no scroll do mouse.
      Mas antes verifique se instalou o compilador C (gcc) apt-get install gcc.
      Tente novamente.

      Excluir
  3. Suas dicas ajudaram a passar por todos os erros. Mas após alterar o código fonte, mudou o erro.
    Alguma dica para o erro abaixo? :)

    (Hist: 1601)-> $ 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
    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:168:37: error: ‘F_OK’ was not declared in this scope
    if (!access(asm_suffix.c_str(), F_OK))
    ^
    tools/depbuild.cpp:168:41: error: ‘access’ was not declared in this scope
    if (!access(asm_suffix.c_str(), F_OK))
    ^
    tools/depbuild.cpp: In function ‘void dependency_calculate_asm(const char*)’:
    tools/depbuild.cpp:134:26: warning: ignoring return value of ‘int system(const char*)’, declared with attribute warn_unused_result [-Wunused-result]
    system(command.c_str());
    ^
    Makefile:118: recipe for target 'tools/depbuild' failed
    make: *** [tools/depbuild] Error 1

    ResponderExcluir
    Respostas
    1. Vitor Junior, pelo que entendi no erro, diz que falta instalar a biblioteca SDL.

      Debian
      # apt-get install libsdl1.2-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev

      Feito!

      Excluir
  4. Fiz tudo certo mas esta aparecendo o seguinte erro de compilação.
    Na parte em que make e make install

    g++ -o zsnes chips/sfxproc.o chips/fxemu2.o chips/dsp1proc.o chips/fxemu2b.o chips/fxemu2c.o chips/fxtable.o chips/sa1proc.o chips/sa1regs.o chips/dsp1emu.o chips/st10proc.o chips/seta10.o chips/dsp2proc.o chips/sdd1emu.o cpu/addrni.o cpu/dma.o cpu/dsp.o cpu/dspproc.o cpu/execute.o cpu/executec.o cpu/irq.o cpu/memory.o cpu/spc700.o cpu/stable.o cpu/table.o cpu/tableb.o cpu/tablec.o linux/copyvwin.o linux/sdlintrf.o linux/sdllink.o linux/sw_draw.o linux/zloaderw.o linux/ztcp.o linux/zipxw.o linux/zfilew.o dos/debug.o dos/joy.o dos/modemrtn.o dos/vesa2.o dos/initvid.o dos/sw.o dos/gppro.o dos/vesa12.o gui/gui.o gui/menu.o video/makev16b.o video/makev16t.o video/makevid.o video/mode716.o video/mode716b.o video/mode716d.o video/mode716e.o video/mode716t.o video/mode7.o video/mode7ext.o video/mv16tms.o video/newg162.o video/newgfx16.o video/newgfx2.o video/newgfx.o video/m716text.o video/2xsaiw.o video/procvid.o video/sw_draw.o video/hq2x16.o video/hq2x32.o video/hq3x16.o video/hq3x32.o video/hq4x16.o video/hq4x32.o cfgload.o endmem.o init.o initc.o uic.o patch.o ui.o vcache.o version.o zip/unzip.o zip/zpng.o effects/burn.o effects/water.o effects/smoke.o jma/7zlzma.o jma/crc32.o jma/iiostrm.o jma/inbyte.o jma/jma.o jma/lzma.o jma/lzmadec.o jma/winout.o jma/zsnesjma.o -pipe -I. -Wall -I/usr/local/include -I/usr/include -D__LINUX__ -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -O3 -ffast-math -fomit-frame-pointer -fexpensive-optimizations -s -L/usr/local/lib -L/usr/lib -lz -L/usr/lib/x86_64-linux-gnu -lSDL -lpng -lm -L
    g++: error: missing argument to ‘-L’
    Makefile:91: recipe for target 'zsnes' failed
    make: *** [zsnes] Error 1

    ResponderExcluir
    Respostas
    1. Tem o compilador gcc e g++ instalado ? Qual versão ?
      Antes executou o ./configure conforme o howto?

      Excluir


  5. Alguma dica? Não estou conseguindo passar daqui...

    g++ -pipe -I. -I/usr/local/include -I/usr/include -D__UNIXSDL__ -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -march=native -O3 -fomit-frame-pointer -s -fno-rtti -o tools/strutil.o -c tools/strutil.cpp
    tools/strutil.cpp:59:21: error: ‘string_ci’ does not name a type
    void Tokenize(const string_ci& str, vector& tokens, const string_ci&
    ^
    tools/strutil.cpp:59:44: error: ‘string_ci’ was not declared in this scope
    void Tokenize(const string_ci& str, vector& tokens, const string_ci&
    ^
    tools/strutil.cpp:59:53: error: template argument 1 is invalid
    void Tokenize(const string_ci& str, vector& tokens, const string_ci&
    ^
    tools/strutil.cpp:59:53: error: template argument 2 is invalid
    tools/strutil.cpp:59:70: error: ‘string_ci’ does not name a type
    oid Tokenize(const string_ci& str, vector& tokens, const string_ci&
    ^
    tools/strutil.cpp: In function ‘void Tokenize(const int&, int&, const int&)’:
    tools/strutil.cpp:62:35: error: request for member ‘find_first_not_of’ in ‘str’, which is of non-class type ‘const int’
    string::size_type lastPos = str.find_first_not_of(delimiters, 0);
    ^
    tools/strutil.cpp:65:35: error: request for member ‘find_first_of’ in ‘str’, which is of non-class type ‘const int’
    string::size_type pos = str.find_first_of(delimiters, lastPos);
    ^
    tools/strutil.cpp:70:12: error: request for member ‘push_back’ in ‘tokens’, which is of non-class type ‘int’
    tokens.push_back(str.substr(lastPos, pos - lastPos));
    ^
    tools/strutil.cpp:70:26: error: request for member ‘substr’ in ‘str’, which is of non-class type ‘const int’
    tokens.push_back(str.substr(lastPos, pos - lastPos));
    ^
    tools/strutil.cpp:73:19: error: request for member ‘find_first_not_of’ in ‘str’, which is of non-class type ‘const int’
    lastPos = str.find_first_not_of(delimiters, pos);
    ^
    tools/strutil.cpp:76:15: error: request for member ‘find_first_of’ in ‘str’, which is of non-class type ‘const int’
    pos = str.find_first_of(delimiters, lastPos);
    ^
    Makefile:96: recipe for target 'tools/strutil.o' failed
    make: *** [tools/strutil.o] Error 1

    ResponderExcluir
  6. Alguma dica?



    Alguma dica? Não estou conseguindo passar daqui...

    g++ -pipe -I. -I/usr/local/include -I/usr/include -D__UNIXSDL__ -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -march=native -O3 -fomit-frame-pointer -s -fno-rtti -o tools/strutil.o -c tools/strutil.cpp
    tools/strutil.cpp:59:21: error: ‘string_ci’ does not name a type
    void Tokenize(const string_ci& str, vector& tokens, const string_ci&
    ^
    tools/strutil.cpp:59:44: error: ‘string_ci’ was not declared in this scope
    void Tokenize(const string_ci& str, vector& tokens, const string_ci&
    ^
    tools/strutil.cpp:59:53: error: template argument 1 is invalid
    void Tokenize(const string_ci& str, vector& tokens, const string_ci&
    ^
    tools/strutil.cpp:59:53: error: template argument 2 is invalid
    tools/strutil.cpp:59:70: error: ‘string_ci’ does not name a type
    oid Tokenize(const string_ci& str, vector& tokens, const string_ci&
    ^
    tools/strutil.cpp: In function ‘void Tokenize(const int&, int&, const int&)’:
    tools/strutil.cpp:62:35: error: request for member ‘find_first_not_of’ in ‘str’, which is of non-class type ‘const int’
    string::size_type lastPos = str.find_first_not_of(delimiters, 0);
    ^
    tools/strutil.cpp:65:35: error: request for member ‘find_first_of’ in ‘str’, which is of non-class type ‘const int’
    string::size_type pos = str.find_first_of(delimiters, lastPos);
    ^
    tools/strutil.cpp:70:12: error: request for member ‘push_back’ in ‘tokens’, which is of non-class type ‘int’
    tokens.push_back(str.substr(lastPos, pos - lastPos));
    ^
    tools/strutil.cpp:70:26: error: request for member ‘substr’ in ‘str’, which is of non-class type ‘const int’
    tokens.push_back(str.substr(lastPos, pos - lastPos));
    ^
    tools/strutil.cpp:73:19: error: request for member ‘find_first_not_of’ in ‘str’, which is of non-class type ‘const int’
    lastPos = str.find_first_not_of(delimiters, pos);
    ^
    tools/strutil.cpp:76:15: error: request for member ‘find_first_of’ in ‘str’, which is of non-class type ‘const int’
    pos = str.find_first_of(delimiters, lastPos);
    ^
    Makefile:96: recipe for target 'tools/strutil.o' failed
    make: *** [tools/strutil.o] Error 1

    ResponderExcluir
    Respostas
    1. Alexandre Benatto Cadan, está usando a versão 4.3 do GCC? Pergunto isso porque a partir da versão 4.3 do GCC, algumas coisas mudaram nas dependências dos cabeçalhos na libstdc++. sendo assim, códigos mais antigos que não sigam esse padrão podem apresentar problemas do gênero, por coincidência eu mesmo já compilei o zsnes e, por experiência própria, você precisará fazer uma intervenção manual no código. Edite o tools/strutil.h e adicione a header cstring: # include < cstring > mais adiante um ou mais arquivos fonte (que não lembro quais, claro), apresentarão erros semelhantes, e basta fazer a mesma coisa para cada um, outro problema que você precisará corrigir manualmente será mudar os tipos de argc em algumas funções main - de size_t para int. o gcc vai te avisar onde, aí basta editar e modificar, isso também é fator da versão 4.3 do GCC fechou o cerco quanto às exigências para a função main. Na data de publicação do tutorial de instalação do ZSNES, compilei na versão anterior do GCC 4.3

      Excluir
    2. Consegui Reginaldo, mas a única forma que funcionou foi instalando diretamente pela loja do Mint... Realmente vc tem razão ele não reconhece muitas bibliotecas desse código...
      Obrigado pela ajuda!

      Excluir
  7. Olá pessoal!

    Alguma dica para esse erro?
    collect2: error: ld returned 1 exit status
    Makefile:103: recipe for target 'main' failed
    make: *** [main] Error 1

    ResponderExcluir
    Respostas
    1. Edvaldo, é necessário ter instalado o compilador gcc e g++ que são compiladores de C e C++, também o make a lib ncurses para compilação.
      Se a distro que estiver usando for derivada do Debian, como o Ubuntu, Mint, pode instalar com o repositório apt-get.
      Caso a distro seja derivada no Redhat, como CentOS, Fedora, pode instalar com o repositório yum.

      Feito!

      Excluir