#162 '' was not declared in this scope

linux
open
nobody
Other (21)
5
2014-08-23
2011-08-29
Livin4Jesus
No

Hey, guys. Every time I attempted to compile ZSNES 1.51, I get a ton of "'<word> was not declared in this scope" errors. In case you need more information, I'm currently stuck on this error when compiling:
tools/depbuild gcc " -pipe -I. -I/usr/local/include -I/usr/include -D__UNIXSDL__ -I/usr/local/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -D__OPENGL__ -march=native -O3 -fomit-frame-pointer -s" nasm " -w-orphan-labels -D__UNIXSDL__ -f elf -DELF -D__OPENGL__ -O1" cfg.o endmem.o init.o initc.o input.o md.o patch.o ui.o vcache.o version.o zloader.o zmovie.o zpath.o zstate.o ztime.o ztimec.o chips/c4emu.o chips/c4proc.o chips/dsp1emu.o chips/dsp1proc.o chips/dsp2proc.o chips/dsp3emu.o chips/dsp3proc.o chips/dsp4emu.o chips/dsp4proc.o chips/fxemu2.o chips/fxemu2b.o chips/fxemu2c.o chips/fxtable.o chips/obc1emu.o chips/obc1proc.o chips/sa1proc.o chips/sa1regs.o chips/sdd1emu.o chips/seta10.o chips/sfxproc.o chips/st10proc.o chips/7110proc.o chips/seta11.o chips/st11proc.o cpu/dma.o cpu/dsp.o cpu/dspproc.o cpu/execute.o cpu/executec.o cpu/irq.o cpu/memory.o cpu/memtable.o cpu/spc700.o cpu/stable.o cpu/table.o cpu/tablec.o debugasm.o debugger.o gui/gui.o gui/guifuncs.o gui/menu.o effects/burn.o effects/smoke.o effects/water.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 mmlib/mm.o mmlib/linux.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/m716text.o video/newg162.o video/newgfx.o video/newgfx16.o video/newgfx2.o video/procvid.o video/procvidc.o video/sw_draw.o video/2xsaiw.o video/hq2x16.o video/hq2x32.o video/hq3x16.o video/hq3x32.o video/hq4x16.o video/hq4x32.o video/ntsc.o video/copyvwin.o linux/audio.o linux/battery.o linux/sdlintrf.o linux/sdllink.o linux/gl_draw.o linux/sw_draw.o linux/safelib.o zip/unzip.o zip/zpng.o > makefile.dep
g++ -pipe -I. -I/usr/local/include -I/usr/include -D__UNIXSDL__ -I/usr/local/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -D__OPENGL__ -march=native -O3 -fomit-frame-pointer -s -fno-rtti -o parsegen parsegen.cpp -lz
parsegen.cpp: In function ‘char* get_token(char*, const char*)’:
parsegen.cpp:131: error: ‘strchr’ was not declared in this scope
parsegen.cpp:140: error: ‘strchr’ was not declared in this scope
parsegen.cpp: In function ‘variable::ctype variable::GetCType(const char*)’:
parsegen.cpp:425: error: ‘strcmp’ was not declared in this scope
parsegen.cpp: In function ‘const char* convert_asm_type(const char*, bool)’:
parsegen.cpp:615: error: ‘strcasecmp’ was not declared in this scope
parsegen.cpp:644: error: ‘strlen’ was not declared in this scope
parsegen.cpp:644: error: ‘strncmp’ was not declared in this scope
parsegen.cpp: In function ‘void handle_directive(const char*, const char*)’:
parsegen.cpp:1369: error: ‘strcasecmp’ was not declared in this scope
parsegen.cpp: In function ‘char* get_comment(char)’:
parsegen.cpp:1500: error: ‘strlen’ was not declared in this scope
parsegen.cpp: In function ‘void output_header_conditional(std::ostream&, const char*, const char*)’:
parsegen.cpp:1519: error: ‘strcasecmp’ was not declared in this scope
parsegen.cpp: In function ‘void parser_generate(std::istream&, std::ostream&, std::ostream&, const std::string&)’:
parsegen.cpp:1552: error: ‘strlen’ was not declared in this scope
parsegen.cpp:1577: error: ‘strcasecmp’ was not declared in this scope
parsegen.cpp:1584: error: ‘strncasecmp’ was not declared in this scope
parsegen.cpp:1595: error: ‘strchr’ was not declared in this scope
parsegen.cpp:1667: error: ‘strncmp’ was not declared in this scope
parsegen.cpp:1675: error: ‘strcmp’ was not declared in this scope
parsegen.cpp: At global scope:
parsegen.cpp:1825: warning: first argument of ‘int main(size_t, const char* const*)’ should be ‘int’
parsegen.cpp: In function ‘int main(size_t, const char* const*)’:
parsegen.cpp:1833: error: ‘strncmp’ was not declared in this scope
parsegen.cpp:1837: error: ‘strcmp’ was not declared in this scope
parsegen.cpp:1954: warning: ignoring return value of ‘int system(const char*)’, declared with attribute warn_unused_result
make: *** [parsegen] Error 1

I had already fixed a couple of errors, but this seems to be something much more difficult... Can anyone lend me a hand here?

Discussion

  • Hi!
    I Coudn't compile neither until I found what was the problem

    I added the following code in every archive it needed(or it gets an error):

    * In src/parsegen.cpp:
    ** Added the following after line 33:

    #include <string.h>

    ** And after line 49(It may be unnecessary but it worked...):

    using namespace std;

    * In src/tools/strutils.h I added the following:
    ** After line 27 :

    #include <stdlib.h>
    #include <string.h>

    using namespace std;

    Now try to compile and it works!

    If other archives appears, take a look wich file is and try to add the library it needs and ensure "using namespace std;" is there.

    The simple explanation of this is that these snippets of code add the most GNU/Linux commons libraries(the library string.h is not the same as string: one adds functions from C and the others adds objects from C++).
    Also, using the namspace "std" makes all the C functions available.

    Cheers!