这是我的源程序
#include <stdio.h>
#include <curses.h>
int main(void){
initscr();
clear();
move(10,20);
addstr("hello , world");
move(LINES-1,0);
refresh();
getch();
endwin();
}
/tmp/cc6IgGrX.o:在函数‘main’中:
hello1.c:(.text+0xa):对‘initscr’未定义的引用
hello1.c:(.text+0xf):对‘stdscr’未定义的引用
hello1.c:(.text+0x17):对‘wclear’未定义的引用
hello1.c:(.text+0x1c):对‘stdscr’未定义的引用
hello1.c:(.text+0x34):对‘wmove’未定义的引用
hello1.c:(.text+0x39):对‘stdscr’未定义的引用
hello1.c:(.text+0x51):对‘waddnstr’未定义的引用
hello1.c:(.text+0x56):对‘LINES’未定义的引用
hello1.c:(.text+0x5e):对‘stdscr’未定义的引用
hello1.c:(.text+0x72):对‘wmove’未定义的引用
hello1.c:(.text+0x77):对‘stdscr’未定义的引用
hello1.c:(.text+0x7f):对‘wrefresh’未定义的引用
hello1.c:(.text+0x84):对‘stdscr’未定义的引用
hello1.c:(.text+0x8c):对‘wgetch’未定义的引用
hello1.c:(.text+0x91):对‘endwin’未定义的引用
collect2: 错误: ld 返回 1
怎麼办
那命令是什麼,该怎麼写
追答关注gcc工具的几个选项:
-I (大写 爱 字母)指定头文件目录
-lxxx (小写 诶藕 字母)指定链接名叫 libXXX.so 或者 libXXX.a 的库
-L (大写 诶藕 字母)指定库所在目录。
gcc 为必通的东西,更多问题可 参与巨立安技术的邮件列表或者qq群
root@lwm-IdeaPad-Z565:~# gcc -lcurses -o hello1.c
/usr/lib/gcc/i686-linux-gnu/4.7/../../../i386-linux-gnu/crt1.o:在函数‘_start’中:
(.text+0x18):对‘main’未定义的引用
collect2: 错误: ld 返回 1
那这是什麼意思
不是gcc -lcurses -o hello1.c, 在-o后面再加上一个生成文件的名称,如hello
--> gcc -lcurses -o hello hello1.c
root@lwm-IdeaPad-Z565:/lwm# gcc -lcurses -o hello hello1.c
还是说那些函数是为定义的引用
-lcurses是说链接curses库,-o指生成的二进制文件