chuyangliu/snake

OSX build issues

ramonsaraiva opened this issue · 11 comments

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

  • Version of cmake is 3.7.1
  • g++: Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 Apple LLVM version 8.0.0 (clang-800.0.42.1) Target: x86_64-apple-darwin16.3.0 Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin

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

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

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.

Are you using the build-in terminal?

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.

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

Yes, 4.2.1.

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.

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

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

Thank you for your attention!

#9 merged, closing issue.