PDA

View Full Version : C++/Terminal questions




toothyXdip
Apr 15, 2009, 04:31 PM
I'm making a little game in c++ (using terminal) and I have a few questions for doing some things.

1.) Is there a way where I can position something (like a variable) towards the bottom of the terminal and stay there?

2.) Is there a way where I can clear the terminal? Like have it ask a question then erase that question and ask another one.

3.) If I wear to have a perm. placed var, how could I update that var without calling it again. (Lets say you have a money variable equal to 10 and you subtract 5 from it and without doing anything the number automatically updates with the new value of 5.



garethlewis2
Apr 15, 2009, 04:35 PM
You need the ncurses library.

Google it.

toothyXdip
Apr 15, 2009, 04:55 PM
I looked into it and thats what I need but i just need some help compiling it.
When i compile using gcc <filename> -lncurses I get this error:

Undefined symbols:
"___gxx_personality_v0", referenced from:
___gxx_personality_v0$non_lazy_ptr in ccbYsUJs.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

even if I just copy a example file from the web.
:confused:

toothyXdip
Apr 15, 2009, 08:19 PM
Ok I installed ncurses by following this guide: http://ncurses.darwinports.com/

Now I am wondering what to do with a "Hello, world" example file using ncurses:

#include <ncurses.h>

int main()
{
initscr(); /* Start curses mode */
printw("Hello World !!!"); /* Print Hello World */
refresh(); /* Print it on to the real screen */
getch(); /* Wait for user input */
endwin(); /* End curses mode */

return 0;
}


I decided to start using xcode so if someone would tell me how to get this working I would be very appreciative.

When i try to compile using gcc <filename.cpp> -lncurses
I still get the error:

Undefined symbols:
"___gxx_personality_v0", referenced from:
___gxx_personality_v0$non_lazy_ptr in ccbYsUJs.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

Image:http://i149.photobucket.com/albums/s67/toothyXdip/NCurses_TermError.jpg


I still get the same

Sander
Apr 16, 2009, 06:28 AM
Try g++ instead of gcc.

toothyXdip
Apr 16, 2009, 12:45 PM
Lol..thanks that worked...I should have tried that after installing it....

ChrisA
Apr 16, 2009, 01:01 PM
When i try to compile using gcc <filename.cpp> -lncurses
I still get the error:

Undefined symbols:
"___gxx_personality_v0", referenced from:
___gxx_personality_v0$non_lazy_ptr in ccbYsUJs.o
ld: symbol(s) not found
collect2: ld returned 1 exit status


Looks like you have the "-l" flage correct but you need a "-L" (upper case L) flage to point to the directory where the library is. Either that or set a library path

This is not a "Mac" thing. It's a compiler issue and it works the same on all unix-like OSes