大家好 小菜我最近写了个c代码 但是链接不上去阿 不知道什么原因 代码和错误贴上 望那位大哥指点
#include<stdio.h> //basic i/o
#include<curses.h> //shell window control
#include<sys/time.h>
#include<stdlib.h>
#include<signal.h> //signal();
#define COLS 30
#define message "hello"
#define blank " "
int row;
int col;
int dir;
int main()
{
int delay; //delay time
int ndelay; //new delay time
int c; //user input
void move_msg(int); //handler for timer
initscr();
crmode();
noecho();
clear();
row=10; //set initialize row value
col=0; //set initialize column value
dir=1; //set initialize direction
delay=200; //ms
mov(row,col); //move cursor to the specified location
addstr(message);//draw message in the specified location
signal(SIGALRM,move_msg);
//specified move_msg to process the SIGALRM message
set_ticker(delay); //set new delay time to control speed in there
while(1)
{
ndelay=0; //set new delay=0 when start
c=getch(); //get a char from input
if(c=='Q') break;
if(c==' ') dir = -dir;
if((c=='f')&&(delay>2))
ndelay=delay/2;
// increase the speed by slow down the interval time
if(c=='s') ndelay=delay*2; // slow down
if(ndelay>0)
set_ticker(delay=ndelay); // reset delay&&timer
}
endwin();
return 0; //procedure terminated
}
void move_msg(int signum) //process the message from timer
{
signal(SIGALRM,move_msg); //not necccessary
move(row,col); //set blank
addstr(blank);
col+-dir; //set new column
move(row,col);
addstr(message); //set message
refresh();
if(dir==-1&&col<=0) //when move to start
dir = 1;
else if((dir == 1) && (col + 7>=COLS))
dir=-1;
}
int set_ticker(int n_msecs)
{
struct itimerval new_timeset;
long n_sec,n_usecs;
n_sec=n_msecs/1000;
n_usecs=(n_msecs%1000)*1000L;
new_timeset.it_interval.tv_sec=n_sec;
new_timeset.it_interval.tv_usec=n_usecs;
new_timeset.it_value.tv_sec=n_sec;
new_timeset.it_value.tv_usec=n_usecs;
return setitimer(ITIMER_REAL,&new_timeset,NULL);
}
编译命令和提示的错误信息是
administrator@ubuntu:~$ cc bounceld1.c -l curses -o bounceld
/tmp/ccASgicj.o: In function `main':
bounceld1.c.text+0x5e): undefined reference to `mov'
collect2: ld returned 1 exit status
谢谢
链接不过阿 求助!
-
- 帖子: 3
- 注册时间: 2009-12-06 20:27
- wzssyqa
- 帖子: 4010
- 注册时间: 2008-04-07 17:36
- 来自: 泰安人在阜新
Re: 链接不过阿 求助!
选项中加上 -lcurses
宇宙=数学 *物理 sssssssss Ubuntu 桌面培训 sssssssss 问打包的问题之前先看
和我一样的新手请看,我看过了,腰不酸了,腿不疼了,上楼也有劲了
想去IRC的点这里——一个比QQ群好N多的东西
和我一样的新手请看,我看过了,腰不酸了,腿不疼了,上楼也有劲了
想去IRC的点这里——一个比QQ群好N多的东西
-
- 帖子: 6548
- 注册时间: 2008-10-31 22:12
- 系统: 践兔
- 联系: