LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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 01-17-2005, 03:39 PM   #1
sjp
LQ Newbie
 
Registered: Jan 2005
Location: Germany
Distribution: suse at present
Posts: 2

Rep: Reputation: 0
ncurses problem


something is going wrong somewehere! I am a beginner in programming.
I tried using ncurses. Compiled using -lncurses. All the usages concerning
ncurses caused errors:

#include<curses.h> is present in the file

e.g. undefined reference to 'initscr'

what is wrong where?:
Take for example the simplest one
==================================================
#include <ncurses.h>

int main()
{
initscr();
printw("Hello World");
refresh();
getch();
endwin();

return 0;
}

======================================================
here are the errors:

/tmp/ccCReeBn.o: In function `main':
/tmp/ccCReeBn.o(.text+0x11): undefined reference to `initscr'
/tmp/ccCReeBn.o(.text+0x1e): undefined reference to `printw'
/tmp/ccCReeBn.o(.text+0x2a): undefined reference to `stdscr'
/tmp/ccCReeBn.o(.text+0x2f): undefined reference to `wrefresh'
/tmp/ccCReeBn.o(.text+0x3b): undefined reference to `stdscr'
/tmp/ccCReeBn.o(.text+0x40): undefined reference to `wgetch'
/tmp/ccCReeBn.o(.text+0x48): undefined reference to `endwin'
collect2: ld returned 1 exit status
 
Old 01-17-2005, 04:44 PM   #2
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 110Reputation: 110
The linker clearly link with the ncurses library
If you are sure you linked with -lncurses, then... is ncurses actually installed?
You could also try to link with -lcurses (removed the 'n'), though don't really think that's the problem.
 
Old 01-18-2005, 04:14 PM   #3
sjp
LQ Newbie
 
Registered: Jan 2005
Location: Germany
Distribution: suse at present
Posts: 2

Original Poster
Rep: Reputation: 0
Thank you for the reply.
The command issued was:
gcc -lncurses -o hello hello.c

I did try
gcc -lcurses -o hello hello.c

The result was no better.

ncurses is installed. I even checked it.
 
Old 01-18-2005, 07:12 PM   #4
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 110Reputation: 110
Strange.
The only other thing can think of is:
  • Find out in which directory the file "libncurses.so" and/or "libncurses.so.5" is (probably /lib and/or /usr/lib).
  • Make sure that this directory is listed in /etc/ld.so.conf (add it if necessary (as root)).
  • Run ldconfig (as root)
  • Try compiling again.
 
Old 01-18-2005, 07:14 PM   #5
Hosiah
Member
 
Registered: Sep 2004
Location: Des Moines, Iowa
Distribution: Slackware, Mandriva, Debian derivatives, +BSD/ Solaris/ Minix/ plan9/ GNU/HURD...
Posts: 185

Rep: Reputation: 30
Pardon me for the stupid suggestion, but is your version of ncurses (a) up to date, and (b) in the correct place? (i.e. the include folder your linker normally looks?

Also:
What confused me about curses is, in my file I have to #include <ncurses.h> /* WITH 'n'! */ but on the command line my library option is: '-lcurses' with NO 'n'. At least, it works that way, but I just checked it again, (now that I've installed an up-to-date version) and the system can now respond to a call to either header file, and either link option. It didn't do that with the old library, I had to download and install 5.3 from RPMfind.net . Somewhere, I bet one header file calls the other, or gcc recognizes either.
 
Old 01-26-2005, 06:27 AM   #6
krsnachaitanya
LQ Newbie
 
Registered: Jan 2005
Posts: 16

Rep: Reputation: 0
Hi,

I applied a patch and when I tried using make menuconfig, it was exiting after saying "unable to find the ncurses libraries.

The command that I executed and the sample output that I got was as follows:


[root@localhost linux]# make menuconfig
rm -f include/asm
( cd include ; ln -sf asm-i386 asm)
make -C scripts/lxdialog all
make[1]: Entering directory `/usr/src/krishna/linux/scripts/lxdialog'
/usr/bin/ld: crt1.o: No such file: No such file or directory
collect2: ld returned 1 exit status

>> Unable to find the Ncurses libraries.
>>
>> You must have Ncurses installed in order
>> to use 'make menuconfig'

make[1]: *** [ncurses] Error 1
make[1]: Leaving directory `/usr/src/krishna/linux/scripts/lxdialog'
make: *** [menuconfig] Error 2


Please help me. What was wrong with the Ncurses. What modifications should I make? Thanx in advance.

King Krsna
 
Old 01-26-2005, 06:43 AM   #7
krsnachaitanya
LQ Newbie
 
Registered: Jan 2005
Posts: 16

Rep: Reputation: 0
just now I tried installing ncurses once again,
The command that I executed and the output that I got was:

[root@localhost ncurses-5.4]# ./configure --prefix=/usr --libdir=/lib\
> --with-shared --disable-termcap
Configuring NCURSES 5.4 ABI 5 (Wed Jan 26 17:23:08 IST 2005)
checking build system type... i686-pc-linux-gnulibc1
checking host system type... i686-pc-linux-gnulibc1
checking target system type... i686-pc-linux-gnulibc1
Configuring for linux-gnulibc1
checking for prefix... /usr
checking for gcc... gcc
checking for C compiler default output... configure: error: C compiler cannot create executables

What should I do to install ncurses?
Please help me out....
Thanx in advance
 
Old 01-26-2005, 07:15 AM   #8
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 110Reputation: 110
Quote:
checking for C compiler default output... configure: error: C compiler cannot create executables
You probably don't have the header files for libc installed. Try installing a package named "libc6-dev" if you use debian) or something like "libc6-devel" or "glibc-devel" on fedora/suse,...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Ncurses problem Sushy Slackware 4 10-20-2005 01:09 PM
Problem with ncurses ina Programming 0 11-29-2002 09:29 AM
ncurses problem ina Linux - Software 2 09-30-2002 12:26 PM
Problem ncurses ina Linux - General 0 09-19-2002 02:50 AM
ncurses-5.2-28 conflicts with file from package ncurses-5.2-12 tubby Linux - Software 4 06-16-2002 01:00 AM

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

All times are GMT -5. The time now is 01:19 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration