LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 661|回复: 4

Help: installed ncurses-5.4 , but compiled a test program error

[复制链接]
发表于 2004-2-26 00:56:45 | 显示全部楼层 |阅读模式
installed ncurses-5.4 just a moment ago, the ncurses file's path is :
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
/usr/local/include;
/usr/local/lib ;
/usr/local/man.....
...........

the test program source code  like this:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#include <iostream>
#include <cstdio>
#include <cstdlib>

#include <curses.h>
#include <unistd.h>

using namespace std;

int main()
{
  printf("%c[%d;%dH",27,10,10);
  cout << "where am i" << endl;

  if (initscr()==NULL){
     cerr << "initscr" << endl;
      return -1;
  }
   printw("this is a test program, bye bye");
   refresh();
   endwin();
   
   return 0;
}

compiled error information is :
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
dow2004$  g++ cursor_test.cpp -o cursor_test
/tmp/cczbeiZE.o: In fuction 'main':
/tmp/cczbeiZE.o(.text+0x42): undefined reference to 'initscr'
/tmp/cczbeiZE.o(.text+0x89): undefined reference to 'printw'
/tmp/cczbeiZE.o(.text+0x91): undefined reference to 'refresh'
/tmp/cczbeiZE.o(.text+0x96): undefined reference to 'endwin'
collect2: ld returned 1 exit status

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

what wrong ? someone expert , could you tell me ?
please help me

addition : i have found these function (initscr(), printw(), refresh() , endwin() ) in the file-- /usr/local/include/curses.h

:help
 楼主| 发表于 2004-2-26 01:03:48 | 显示全部楼层
addition : i have found these function (initscr(), printw(), refresh() , endwin() ) in the file-- /usr/local/include/curses.h

in the file /usr/local/include/curses.h i have found the function initscr() (and others)
why the compiler tell me undefined reference 'initscr' (and others)?
发表于 2004-2-26 06:23:39 | 显示全部楼层
编译的时候加上 -lcurses
 楼主| 发表于 2004-2-26 12:12:50 | 显示全部楼层
still error
compile information is :
g++ cursor_test.cpp -o cursor_test -lcurses
/usr/bin/ld cannot find -lcurses
collect2: ld returned 1 exit status
 楼主| 发表于 2004-2-26 13:46:38 | 显示全部楼层
the problem has been solved .:p
add the option -lncurses (attention is "-lncurses", not -lcurses) when compile.
wanting to get more information you may read the manual of ncurses:
---> command is : man ncurses.

:thank
thank you
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表