Davide Simoncini
Davide Simoncini

Reputation: 75

Problems with curses.h on OSX Lion

I'm trying to use curses.h library for the first time, but no matter which function I call I still get an error that says

-Symbol(s) not found for Architecture x86_64-

Am i missing some kind of initialization? This is my code

#include <iostream>
#include <unistd.h>
#include<time.h>
#include <sys/ioctl.h>
#include <iomanip>
#include <ncurses.h>

using namespace std;

int main(int argc, const char * argv[]){
    string a,b = ("...");
    WINDOW *mywindow;
    mywindow = initscr();
    refresh();
    cout<<"Inserisci la frase da passare in coolprint ->";
    cin>>a;
    coolprint(a);
    cout<<endl;
    hackprint(a);
    coolprint(b);
    cout<<endl;
    slideprint(a);
    fflush(stdin);
    getchar();
    return 0;
}

I didn't post all the functions but if i take out the calls from curses.h and use system("clear") instead, everything works fine. It's probably some really stupid issue, but i'm kind a newbie with c++. Hope somebody can help Thanks.

Upvotes: 4

Views: 4794

Answers (2)

RuiKQ
RuiKQ

Reputation: 51

use gcc in terminal:

-> gcc filename.c -lncurses

-> ./a.out

Upvotes: 1

sergio
sergio

Reputation: 69027

It seems you are not linking the ncurses library/usr/lib/libncurses.dylib into your program...

It is not clear how you are trying to compile the program (makefile, command line, Xcode), so I cannot advise further, but it should be readily done...

In Xcode:

  1. In the project navigator, select your project
  2. Select your target
  3. Select the 'Build Phases' tab
  4. Open 'Link Binaries With Libraries' expander
  5. Click the '+' button
  6. Select your framework (in your case look for libncurses under your SDK)
  7. (optional) Drag and drop the added framework to the 'Frameworks' group

Note: OSX supports unicode very well, however many open-source ./configure scripts choose settings that prevent ncurses from displaying unicode characters.

Upvotes: 5

Related Questions