View Full Version : getch() equivalent on osx?
smartalco
2006.11.25, 06:22 PM
what is the equivalent of getch() on osx? if there is one
note: if anyone knows of a resource that lists osx equivalents of commonly used windows functions and system calls i would really like the url
PowerMacX
2006.11.25, 06:35 PM
A starting point:
http://developer.apple.com/documentation/Porting/Conceptual/win32porting/win32porting.html
OneSadCookie
2006.11.25, 08:11 PM
Mac OS X has getch, though whether it's the same as the windows one or not, I don't know.
man getch
smartalco
2006.11.26, 06:42 PM
found that^, used it, and i got two different errors depending on if i allow zerolinking or not
if i allow zerolinking i get the error "ZeroLink: unknown symbol '_stdscr'" when i run it, if i disable zerolinking i get an error while building saying "Undefined ymbols:"
the error has something to do with the curses.h header that getch() is in, when i comment out that header and replace getch() with cin just to test it builds and runs fine
little help?
side problem: im also using system("clear"); in the same program and when running it says "TERM environment variable not set.", what do i need for that to work properly
akb825
2006.11.26, 06:52 PM
Under your build rules, add "-lcurses" to your additional linker flags. (basically, you need to link the library before you can actually use it)
OneSadCookie
2006.11.26, 07:20 PM
not -lncurses?
to get TERM set properly, run it from the terminal, instead of from Xcode.
akb825
2006.11.26, 07:27 PM
Or that one. :p
smartalco
2006.11.26, 07:33 PM
i added -lcurses to "other linker flags" (im assuming its the same thing) and i still get the same error if i have zeroLink enabled and it opens the dubugger when i run if i have zeroLink disabled :/
edit: i changed it to -lncurses and it does the same thing...
akb825
2006.11.26, 09:01 PM
Are you sure that it's set in your current build setting? (it would actually be best if you entered it when set to all build settings)
smartalco
2006.11.26, 09:40 PM
^i think so... i went to SCM -> configure SCM, clicked on the "Build" tab, found the "Other Linker Flags" setting and added "-lncurses"
would i have to add something for other headers i included? (theres iostream, string, and curses.h)
OneSadCookie
2006.11.26, 10:19 PM
SCM stands for source code management (CVS, SVN, etc.) so it doesn't sound like the right place. Find your target in the left column, and get info on that.
smartalco
2006.11.27, 06:43 PM
heres a screenshot of the specific error (i think) if any of you have the knowledge to understand what it means
i added curses.h (header getch() is in) to the "Link Binary With Libraries" folder, it just added it to my source files, i ctrl-clicked on "Targets" and clicked "Get Info" and it brings up a box saying "Nothing to inspect", same thing on "Link Binary With Libraries" and it brings up a comment box, same thing again on the pong folder under targets and it brought up a window very similar to the "Configure SCM" window, i checked the "other linker flags" property and -lncurses was already listed there, i then found 3 similar properties "Additional Strip Flags", "Other C Flags", and "Other C++ Flags" and added -lncurses to all of those, still same problem..
P.S. sorry if im giving too many details, just trying to be thorough
http://img484.imageshack.us/img484/2637/picture1vo8.png
OneSadCookie
2006.11.27, 06:44 PM
Right-click on the "pong" target and choose get info.
smartalco
2006.11.27, 09:46 PM
Right-click on the "pong" target and choose get info.
same thing again on the pong folder under targets and it brought up a window very similar to the "Configure SCM" window,
already did
akb825
2006.11.27, 10:06 PM
What's it set at under Configuration? (note that it would be best if you set it to "All Configurations" so the linker flag works under every configuration
smartalco
2006.11.27, 10:58 PM
it is set to "all configurations"
akb825
2006.11.27, 11:23 PM
Try cleaning and re-building, then. If that doesn't work, you may just want to post the project so we can take a look at it.
smartalco
2006.11.28, 07:01 PM
^did that, made a completely new project with the same code, same thing, although adding -lncurses definitely made a difference, different error before and after anyway
here is the project (hosted on wikiupload) http://www.wikiupload.com/download_page.php?id=33515 (if you cant figure it out, its console pong, in an early version...)
akb825
2006.11.28, 07:40 PM
Builds without problems here... (well, 2 warnings, but no errors)
smartalco
2006.11.29, 12:25 AM
maybe its a couple of the additional libraries i have installed... i never use them so i think im just going to reinstall the developer tools, see if that helps (i havent updated xcode in 9 months either anyway...)
smartalco
2006.11.29, 08:35 PM
did that^ still doesnt work :/, anyone have any other ideas?
vBulletin® v3.6.8, Copyright ©2000-2008, Jelsoft Enterprises Ltd.