Solved

ncurses in netbeans with cygwin compiler

Posted on 2010-09-07
2
1,846 Views
Last Modified: 2013-11-15
I'm trying to run this C code in netbeans 6.8. I have installed cygwin gcc compiler. At compilation I get these error messages:

/usr/bin/make -f nbproject/Makefile-Debug.mk SUBPROJECTS= .build-conf
make[1]: Entering directory `/cygdrive/c/Documents and Settings/stefano federici/Documenti/NetBeansProjects/cursestest'
/usr/bin/make  -f nbproject/Makefile-Debug.mk dist/Debug/Cygwin-Windows/cursestest.exe
make[2]: Entering directory `/cygdrive/c/Documents and Settings/stefano federici/Documenti/NetBeansProjects/cursestest'
mkdir -p build/Debug/Cygwin-Windows
rm -f build/Debug/Cygwin-Windows/main.o.d
gcc    -c -g -MMD -MP -MF build/Debug/Cygwin-Windows/main.o.d -o build/Debug/Cygwin-Windows/main.o main.c
main.c:47:2: warning: no newline at end of file
mkdir -p dist/Debug/Cygwin-Windows
gcc     -o dist/Debug/Cygwin-Windows/cursestest build/Debug/Cygwin-Windows/main.o  
build/Debug/Cygwin-Windows/main.o: In function `draw':
/cygdrive/c/Documents and Settings/stefano federici/Documenti/NetBeansProjects/cursestest/main.c:13: undefined reference to `_stdscr'
/cygdrive/c/Documents and Settings/stefano federici/Documenti/NetBeansProjects/cursestest/main.c:13: undefined reference to `_wmove'
/cygdrive/c/Documents and Settings/stefano federici/Documenti/NetBeansProjects/cursestest/main.c:14: undefined reference to `_stdscr'
/cygdrive/c/Documents and Settings/stefano federici/Documenti/NetBeansProjects/cursestest/main.c:14: undefined reference to `_wdelch'
/cygdrive/c/Documents and Settings/stefano federici/Documenti/NetBeansProjects/cursestest/main.c:14: undefined reference to `_stdscr'
/cygdrive/c/Documents and Settings/stefano federici/Documenti/NetBeansProjects/cursestest/main.c:14: undefined reference to `_winsch'
/cygdrive/c/Documents and Settings/stefano federici/Documenti/NetBeansProjects/cursestest/main.c:15: undefined reference to `_stdscr'
/cygdrive/c/Documents and Settings/stefano federici/Documenti/NetBeansProjects/cursestest/main.c:15: undefined reference to `_wrefresh'
build/Debug/Cygwin-Windows/main.o: In function `main':
/cygdrive/c/Documents and Settings/stefano federici/Documenti/NetBeansProjects/cursestest/main.c:30: undefined reference to `_initscr'
/cygdrive/c/Documents and Settings/stefano federici/Documenti/NetBeansProjects/cursestest/main.c:31: undefined reference to `_cbreak'
/cygdrive/c/Documents and Settings/stefano federici/Documenti/NetBeansProjects/cursestest/main.c:32: undefined reference to `_noecho'
/cygdrive/c/Documents and Settings/stefano federici/Documenti/NetBeansProjects/cursestest/main.c:34: undefined reference to `_stdscr'
/cygdrive/c/Documents and Settings/stefano federici/Documenti/NetBeansProjects/cursestest/main.c:34: undefined reference to `_wclear'
/cygdrive/c/Documents and Settings/stefano federici/Documenti/NetBeansProjects/cursestest/main.c:35: undefined reference to `_stdscr'
/cygdrive/c/Documents and Settings/stefano federici/Documenti/NetBeansProjects/cursestest/main.c:35: undefined reference to `_wrefresh'
/cygdrive/c/Documents and Settings/stefano federici/Documenti/NetBeansProjects/cursestest/main.c:39: undefined reference to `_stdscr'
/cygdrive/c/Documents and Settings/stefano federici/Documenti/NetBeansProjects/cursestest/main.c:39: undefined reference to `_wgetch'
/cygdrive/c/Documents and Settings/stefano federici/Documenti/NetBeansProjects/cursestest/main.c:44: undefined reference to `_endwin'
collect2: ld returned 1 exit status
make[2]: *** [dist/Debug/Cygwin-Windows/cursestest.exe] Error 1
make[2]: Leaving directory `/cygdrive/c/Documents and Settings/stefano federici/Documenti/NetBeansProjects/cursestest'
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory `/cygdrive/c/Documents and Settings/stefano federici/Documenti/NetBeansProjects/cursestest'
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 8s)
// simple curses example; keeps drawing the inputted characters, in columns
 // downward, shifting rightward when the last row is reached, and
 // wrapping around when the rightmost column is reached

 #include "ncurses\curses.h" // required

 int r,c, // current row and column (upper-left is (0,0))
 nrows, // number of rows in window
 ncols; // number of columns in window

 void draw(char dc)

 { move(r,c); // curses call to move cursor to row r, column c
 delch(); insch(dc); // curses calls to replace character under cursor by dc
 refresh(); // curses call to update screen
 r++; // go to next row
 // check for need to shift right or wrap around
 if (r == nrows) {
 r = 0;
 c++;
 if (c == ncols) c = 0;
 }
 }

 main()

 { int i; char d;
 WINDOW *wnd;

 wnd = initscr(); // curses call to initialize window
 cbreak(); // curses call to set no waiting for Enter key
 noecho(); // curses call to set no echoing
 getmaxyx(wnd,nrows,ncols); // curses call to find size of window
 clear(); // curses call to clear screen, send cursor to position (0,0)
 refresh(); // curses call to implement all changes since last refresh

 r = 0; c = 0;
 while (1) {
 d = getch(); // curses call to input from keyboard
 if (d == 'q') break; // quit?
 draw(d); // draw the character
 }

 endwin(); // curses call to restore the original window and leave

 }

Open in new window

0
Comment
Question by:Esanteva
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 13

Accepted Solution

by:
Superdave earned 500 total points
ID: 33621960
Judging by this line of output:

gcc     -o dist/Debug/Cygwin-Windows/cursestest build/Debug/Cygwin-Windows/main.o  

you don't have any libraries specified in the makefile.  You'll need to add at least -lncurses to that command.
0
 

Author Closing Comment

by:Esanteva
ID: 33622179
I don't know what happened: following direction I found on the web I had added the -lncurses option for libraries. But then, you are perfectly right, now it was missing. So... Thanks.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I use more than 1 computer in my office for various reasons. Multiple keyboards and mice take up more than just extra space, they make working a little more complicated. Using one mouse and keyboard for all of my computers makes life easier. This co…
Skype is a P2P (Peer to Peer) instant messaging and VOIP (Voice over IP) service – as well as a whole lot more.
Using Adobe Premiere Pro, the viewer will learn how to set up a sequence with proper settings, importing pictures, rendering, and exporting the finished product.
Viewers will learn how to use the Hootsuite Dashboard.

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question