Problem with compiling a c++ file

Joël

Veteran
Joined
Mar 14, 2006
Messages
637
Location
3rd rock from the sun
WCA ID
2004NOOR01
Hey guys,

I am not really sure if this section is also used to ask for help, but I am sure nobody would mind if I ask this. I found an algorithm for generating mazes:

http://www.vulcanware.com/cpp_maze/maze.cpp

And I am trying to compile this with the command g++ -Wall -o maze maze.cpp, but I get a few errors (for example "maze.cpp:220: error: ‘string’ does not name a type" and some other messages like "variable name" has not been declared in this scope), a whole bunch of the same kind of errors. On the website it says g++ ... should compile it, so I am not sure what the problem is... Can anyone tell me what's wrong?

Thanks ;).
 
I don't get anything like the errors you described. However, if I comment out "using std::string;" and "using std::vector;", then I do. Maybe your g++ doesn't understand those two lines correctly? (Mine is version 4.4.3 on Arch Linux.) Try replacing them with "using namespace std;" or, if that doesn't work either, replace all uses of string and vector with std::string and std::vector.

Here are the changes I made to make it compile without warnings: http://codepad.org/HR6DTbdP and the file after the changes: http://codepad.org/4pLTaRVY.

Btw I think this should be in off-topic since it's not about cubing software.
 
Last edited:
maze.cpp: In function ‘bool equalsIC(char*, char*)’:
maze.cpp:620: error: ‘strlen’ was not declared in this scope
maze.cpp: In function ‘bool getArgs(int, char**, int*, int*, bool*, bool*, std::string&)’:
maze.cpp:659: warning: deprecated conversion from string constant to ‘char*’
maze.cpp:671: error: ‘strchr’ was not declared in this scope
maze.cpp:704: warning: deprecated conversion from string constant to ‘char*’
maze.cpp:708: warning: deprecated conversion from string constant to ‘char*’

I don't get the errors you report. Including <cstring> fixed the above for me. Maybe try that.

What version of g++ are you using? I have 4.4.1.
 
Back
Top