chuyangliu / snake

Artificial intelligence for the Snake game.
Apache License 2.0
1.65k stars 481 forks source link

OSX build issues #8

Closed ramonsaraiva closed 7 years ago

ramonsaraiva commented 7 years ago

I'm having some issues when trying to build it in OSX. I know it is not yet supported, maybe someone fixed it and could help?

[ 33%] Building CXX object CMakeFiles/snake.dir/src/GameCtrl.cpp.o /Users/ramon/fun/snake/src/GameCtrl.cpp:56:5: error: use of undeclared identifier 'exit' exit(0); ^ 1 error generated. make[2]: *** [CMakeFiles/snake.dir/src/GameCtrl.cpp.o] Error 1 make[1]: *** [CMakeFiles/snake.dir/all] Error 2 make: *** [all] Error 2

chuyangliu commented 7 years ago

OK. Maybe I forgot to add include <cstdio> in GameCtrl.h. I will fix it soon.

chuyangliu commented 7 years ago

@ramonsaraiva Try to build it again. Is it OK?

ramonsaraiva commented 7 years ago

It builds now, besides that, when i run bin/snake i only see the screen clearing itself and nothing else. But it is probably related to the terminal i'm using.

chuyangliu commented 7 years ago

Are you using the build-in terminal?

ramonsaraiva commented 7 years ago

Tried with iTerm2 and also with the built-in. Also disabled zsh when trying it. I'll explore about it later and if i have a fix i'll submit a PR.

chuyangliu commented 7 years ago

Thanks. By the way, what's your g++ version? 4.2.1?

ramonsaraiva commented 7 years ago

Yes, 4.2.1.

chuyangliu commented 7 years ago

That's weird. It requires minimum g++ version of 4.8 to build this project. I don't know why the build on OS X passed. Maybe you should update your g++ version or using clang to build instead.

chuyangliu commented 7 years ago

I guess I know the reason. File Console.cpp controls the console output. However, currently there are no codes handling platform except Linux & Windows . You could see the #Ifdef command in this file.

So I think should modify commands below in those methods:

// Since the OS X terminal is similar to the linux's, maybe they could share same config.
#ifdef __linux__ || OSX_IDENTIFIER

But I do not have a OS X machine, could you test it and send a PR? I would really appreciate it! @ramonsaraiva

ramonsaraiva commented 7 years ago

For sure, @stevennL. I will do it as soon as possible, still at work for now.

Thank you for your attention!

ramonsaraiva commented 7 years ago

9 merged, closing issue.