LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-02-2007, 03:43 AM   #1
abhishekfishy
LQ Newbie
 
Registered: Aug 2007
Posts: 4

Rep: Reputation: 0
Question ../../ncurses/base/lib_getch.c: No such file or directory.


Hi

Below gives me a seg fault

#include <curses.h>
#include <stdio.h>

int main()
{
char c;
while(1)
{
c = (char)getch( );
printf("you entered %c \n",c);
}
}

[abmisra1@AbhishekM isra1 sampleC]$ gdb terminal.o core
GNU gdb Red Hat Linux (6.3.0.0-1.132. EL4rh)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-redhat- linux-gnu" ...(no debugging symbols found)
Using host libthread_db library "/lib/tls/libthread _db.so.1" .

Core was generated by `./terminal. o'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /usr/lib/libncurses .so.5...done.
Loaded symbols for /usr/lib/libncurses .so.5
Reading symbols from /lib/tls/libc. so.6...done.
Loaded symbols for /lib/tls/libc. so.6
Reading symbols from /lib/ld-linux. so.2...done.
Loaded symbols for /lib/ld-linux. so.2
#0 0x03f66557 in wgetch (win=0x0) at ../../ncurses/ base/lib_ getch.c:467
467 ../../ncurses/ base/lib_ getch.c: No such file or directory.
in ../../ncurses/ base/lib_ getch.c
(gdb) run
Starting program: /home/abmisra1/ sampleC/terminal .o

Program received signal SIGSEGV, Segmentation fault.
0x03f66557 in wgetch (win=0x0) at ../../ncurses/ base/lib_ getch.c:467
467 ../../ncurses/ base/lib_ getch.c: No such file or directory.
in ../../ncurses/ base/lib_ getch.c
(gdb) quit
The program is running. Exit anyway? (y or n) y
[abmisra1@AbhishekM isra1 sampleC]$


I'm using a custom built rhel 4 derived distro

Seems something wrong with my curses library

there is no ncurses/base/ lib_getch. c on my system, I do not think that in any case should a c file be required if we have executables and libraries in place.

Could some one through some light.
 
Old 08-02-2007, 02:38 PM   #2
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
That message probably comes from the library containing ncurses being build with gdb symbols and getting debugged on a different machine. In other words, it was build by your distro maintainer, but the source file doesn't reside in the same place on your machine (if at all.) I'm pretty sure that message has little to do with the actual error, other than that the backtrace leads through the getch call. My guess is you need to check for an error state before using that function to make sure the input source is open and is capable of providing data.
ta0kira
 
Old 08-08-2007, 03:40 AM   #3
abhishekfishy
LQ Newbie
 
Registered: Aug 2007
Posts: 4

Original Poster
Rep: Reputation: 0
ok i found the problem ncurses needs to be initialized

#include <ncurses.h>
#include <stdio.h>

int main()
{
char c;
initscr();
cbreak();
keypad(stdscr, TRUE);
noecho();

//nodelay(stdscr, TRUE); if no onput is wating then value of ERR is returned

//while(1)
{
c = getch();
printw("you entered %c \n",c);
}
getch();
endwin();
return 0;
}
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Sendmail M4 configuration base directory? Polaris2203 Slackware 9 02-09-2014 10:25 PM
Mysql directory base brazilian_user Debian 5 05-22-2007 08:24 AM
how to print text in color by ncurses without opening a ncurses window Greatrebel Programming 0 12-20-2006 09:15 AM
Gnome-pilot Base Directory Invalid Error (Ubuntu) tanstaafl4y Linux - Software 1 11-22-2006 04:02 AM
ncurses-5.2-28 conflicts with file from package ncurses-5.2-12 tubby Linux - Software 4 06-16-2002 12:00 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:13 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration