<conio.h> No such file or directory?

Member
Posts: 21
Joined: 2009.05
Post: #16
Hey guys,
Okay, I've changed around the -lcurses to -lncurses, with no change. Sad I also removed the library, added the linker tag and tried it, still no change. Just to make sure I am editing the correct areas, I took a few screen shots:

[Image: otf.gif]
This shows where I am entering the -lcurses (I tried -lncurses here too ). Also, if you right click a file, such as main.c, you can open the inspector window and add -|curses to the build text box. Though when I do this, nothing changes, same error.

I get to the above by opening the inspector on the main project name ( the blue A icon next to the name: files ). To show this, here's a screeny:

[Image: screeny2.gif]
I can't find anywhere else where I can add this setting. I've also read through several help files on adding linker flags, that is how I found out how to add them per file basis.

My last concern relates to the example source code I downloaded. I did a search for curses.h examples using google and just snipped someone's short code to see if it worked / play with the settings (it's how I learn...). So, here is the code I am using:

Code:
#include <time.h>
#include <curses.h>

int current_getch;
int doloop = 1;
static WINDOW *mainwnd;
static WINDOW *screen;
WINDOW *my_win;

int now_sec, now_min, now_hour, now_day, now_wday, now_month, now_year;
time_t now;
struct tm *now_tm;
    
void screen_init(void) {
   mainwnd = initscr();
   noecho();
   cbreak();
   nodelay(mainwnd, TRUE);
   refresh(); // 1)
   wrefresh(mainwnd);
   screen = newwin(13, 27, 1, 1);
   box(screen, ACS_VLINE, ACS_HLINE);
}

static void update_display(void) {
   curs_set(0);
   mvwprintw(screen,1,1,"-------- HEADER --------");
   mvwprintw(screen,3,6,"TIME: %d:%d:%d", now_hour, now_min, now_sec);
   mvwprintw(screen,5,6,"DATE: %d-%d-%d", now_day, now_month, now_year);
   mvwprintw(screen,7,6,"PRESS q TO END");
   mvwprintw(screen,10,1,"-------- FOOTER --------");
   wrefresh(screen);
   refresh();
}

void screen_end(void) {
   endwin();
}

void maketime(void) {
    // Get the current date/time
    now = time (NULL);
    now_tm = localtime (&now);
   now_sec = now_tm->tm_sec;
    now_min = now_tm->tm_min;
    now_hour = now_tm->tm_hour;
    now_day = now_tm->tm_mday;
    now_wday = now_tm->tm_wday;
    now_month = now_tm->tm_mon + 1;
    now_year = now_tm->tm_year + 1900;
}

int main(void) {
   screen_init();
   while (doloop) {
      current_getch = getch();
      if (current_getch == 113) {
         doloop = 0;
      }
      maketime();
      update_display();
      sleep(1);
   }
   screen_end();
   printf("TEST ENDS\n");
   return 0;
}
Sorry for always bugging you. >< I just really want to figure out why I can't get this to work. It's my current brick wall... nothing I throw at the darn thing seems to make a difference. Anyone have a cannon?

Thanks for your help. Smile

~Achi
Quote this message in a reply
Member
Posts: 21
Joined: 2009.05
Post: #17
Hey guys,
I just wanted to add on to what I am doing to try to resolve my continuous problems... >< First, for curses, I thought that perhaps the code I was using was causing the problem. Thus, I went out and found a really good tutorial on how to start using ncurses.h. I followed the tutorial to the letter though to no avail, I still receive the same error as mentioned above. This is the new source code I am using:
Code:
//**********************************
// Includes
//**********************************
    #include <ncurses.h>

int main( void )
{    
    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've read that sometimes Xcode has problems with curses and people have recommended building from the terminal. Thus, I tried to use SCons (I believe this was a recommendation from OSC from my Tic Tac Toe topic), anyway, after hours of attempting to install SCons (I didn't have access to my System folder and found out I had to us 'sudo' to install scons: sudo python setup.py install) I got it installed, though it didn't work. <-- That seems to be the story of my life right now. I'm following every tutorial to the letter and nothing is working... that has to be one of my most frustrating things in life, it has been a major turn off... though I am still trying. Rasp

Right now, the tutorial simply states to create a file: SConstruct and include within it: Program('main.c'). When I type in: scons (per the tutorials instruction) I get an error back: -bash: scons: command not found. I then thought I had to write out the path to the installed command, and tried this: (I know there is a better way to write this, though I am very new to unix commands)

../../../../../System/Library/Frameworks/Python.framework/Versions/2.3/bin/scons

This worked, to the point that it ran the command. However, I get this message back:

Code:
scons: Reading SConscript files ...
  File "SConstruct", line 1

    {\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410

                                                      ^

SyntaxError: invalid token
So, I'm still completely lost here. >< I've learned a lot, though even so, I have not been able to figure out what I am doing wrong. Any advice would be much appreciated. Thanks!

~Achi

EDIT:
Here's the scons tutorial I am following: :: Link :: and the curses tutorial I am following: :: Link ::.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #18
If your path starts with a /, it's absolute. So, /System/Library/.............

For easier access, you can either make an alias for it, add the directory containing it to your path, or put a symlink to it in a directory that's already in your path. The latter is probably easiest:

sudo ln -s /System/Library/Frameworks/Python.framework/Versions/2.3/bin/scons /usr/bin/scons

Note that this modifies a system directory! Be careful!

Your SConstruct is an RTF file, by the looks. Try making it plain text Wink
Quote this message in a reply
Member
Posts: 21
Joined: 2009.05
Post: #19
Thanks OSC. Smile
I did as you said and finally got my SConstruct to work. When 'scons' ran, it could not build my executable because all the functions were undefined (it did not have access to the curses library). This morning, after reading through the scons tutorial, I found out how to include the curses library:
Code:
Program('main.c', LIBS = 'ncurses', LIBPATH = '/System/Library/Frameworks/Python.framework/Versions/2.3/bin' )
From that point forward, everything worked just fine. Smile

Now, I just need to find out why Xcode is not compiling correctly. I just don't know where I need to inform xcode that I am using curses. Blah. >< If you have any insight on that, that would be great. Smile

BTW, I just ordered a Unix book for Mac OS X. I should get it in about a week. I figure that it would be good to know a bit about the command line. I look forward to it. Grin

Well, thanks again for your help. I'm just about out of the woods. Grin

~Achi
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #20
you shouldn't need that LIBPATH entry.

To make Xcode link libncurses.dylib, drag it from /usr/lib into your project, or use the "Add Files" thing to add it. Xcode will handle the rest for you. Either that, or add "-lncurses" to your "other linker flags". They should be exactly equivalent.
Quote this message in a reply
Member
Posts: 21
Joined: 2009.05
Post: #21
I'll edit out the LIBPATH and see if it works. I just used one of the tutorial examples. Thanks for letting me know. Smile

As for adding libncurses.dylib or/and "-lncurses" I have done that in many different ways. If you see above, my post with the screen shots, you will see more specifically what I have tried. Every attempt just simply doesn't work. I have read everywhere... just drag and drop the lib and it works... use -lncurses and it works; it's not working. I believe I am doing everything right, and based off of what you stated just above, it should be right. I wonder if this could be an xcode bug... though I highly doubt it.

Well, for the time being, I may have to just compile using SCons until I figure out what's going on with xcode. If you have any further advice, that's great. Smile Sorry for being such a bother... this is just a rather frustrating problem that I can't seem to work out for the life of me.

Take care and thanks for your help and time as always. Smile

~Achi
Quote this message in a reply
Post Reply