Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

ncurses in netbeans with cygwin compiler

Posted on 2010-09-07
2
Medium Priority
?
1,909 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 2000 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

Curious about the latest ransomware attack? Check out our timeline of events surrounding the spread of this new virus along with tips on how to mitigate the damage.
Have you ever run into that annoying problem where the computer won't boot?  Wouldn't it be great if you had a tool that would make that disk boot again?  I have found one tool that works more often than not ...
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

618 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