Solved

ncurses in netbeans with cygwin compiler

Posted on 2010-09-07
2
1,868 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

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

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

Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
Invest in your employees with these five simple steps to improve employee engagement and retention.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

705 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