gpt4 book ai didi

c - 对 ncurses 库中函数的 undefined reference

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:48:06 25 4
gpt4 key购买 nike

<分区>

我正在尝试使用 ncurses 库 v 5.9 编译以下代码。在 Debian 上喘息。但是我得到了对库函数的 undefined reference 。我从源代码安装了库。

#include <curses.h>
#include <menu.h>
#include<stdlib.h>

#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
#define CTRLD 4

char *choices[] = {
"Choice 1",
"Choice 2",
"Choice 3",
"Choice 4",
"Exit",
};

int main()
{ ITEM **my_items;
int c;
MENU *my_menu;
int n_choices, i;
ITEM *cur_item;


initscr();
cbreak();
noecho();
keypad(stdscr, TRUE);

n_choices = ARRAY_SIZE(choices);
my_items = (ITEM **)calloc(n_choices + 1, sizeof(ITEM *));

for(i = 0; i < n_choices; ++i)
my_items[i] = new_item(choices[i], choices[i]);
my_items[n_choices] = (ITEM *)NULL;

my_menu = new_menu((ITEM **)my_items);
mvprintw(LINES - 2, 0, "F1 to Exit");
post_menu(my_menu);
refresh();

while((c = getch()) != KEY_F(1))
{ switch(c)
{ case KEY_DOWN:
menu_driver(my_menu, REQ_DOWN_ITEM);
break;
case KEY_UP:
menu_driver(my_menu, REQ_UP_ITEM);
break;
}
}

free_item(my_items[0]);
free_item(my_items[1]);
free_menu(my_menu);
endwin();
}

这里是错误

root@sss:/home/sss/Desktop# gcc -Wall -o mn mn.c -lncurses -lmenu
mn.c: In function ‘main’:
mn.c:21:8: warning: unused variable ‘cur_item’ [-Wunused-variable]
mn.c:58:1: warning: control reaches end of non-void function [-Wreturn-type]
/usr/lib/gcc/i486-linux-gnu/4.7/../../../../lib/libmenu.a(m_driver.o): In function `menu_driver':
m_driver.c:(.text+0x33b): undefined reference to `getmouse'
m_driver.c:(.text+0x36c): undefined reference to `wenclose'
m_driver.c:(.text+0x3b0): undefined reference to `wmouse_trafo'
m_driver.c:(.text+0x7b9): undefined reference to `wenclose'
m_driver.c:(.text+0x7f2): undefined reference to `wmouse_trafo'
/usr/lib/gcc/i486-linux-gnu/4.7/../../../../lib/libmenu.a(m_global.o): In function `_nc_Show_Menu':
m_global.c:(.text+0x78b): undefined reference to `copywin'
/usr/lib/gcc/i486-linux-gnu/4.7/../../../../lib/libmenu.a(m_post.o): In function `_nc_Post_Item':
m_post.c:(.text+0x3c): undefined reference to `wattr_on'
m_post.c:(.text+0x8e): undefined reference to `wattr_off'
m_post.c:(.text+0xce): undefined reference to `wattr_on'
m_post.c:(.text+0x276): undefined reference to `wattr_on'
m_post.c:(.text+0x3a3): undefined reference to `wattr_off'
m_post.c:(.text+0x3db): undefined reference to `wattr_off'
m_post.c:(.text+0x424): undefined reference to `wattr_on'
m_post.c:(.text+0x458): undefined reference to `wattr_on'
m_post.c:(.text+0x47e): undefined reference to `wattr_on'
m_post.c:(.text+0x4ce): undefined reference to `wattr_on'
m_post.c:(.text+0x4fe): undefined reference to `wattr_off'
m_post.c:(.text+0x51e): undefined reference to `wattr_off'
m_post.c:(.text+0x53a): undefined reference to `wattr_off'
m_post.c:(.text+0x5b6): undefined reference to `wattr_off'
/usr/lib/gcc/i486-linux-gnu/4.7/../../../../lib/libmenu.a(m_post.o): In function `_nc_Draw_Menu':
m_post.c:(.text+0x605): undefined reference to `wbkgdset'
m_post.c:(.text+0x61f): undefined reference to `wbkgdset'
m_post.c:(.text+0x69e): undefined reference to `wattr_on'
m_post.c:(.text+0x774): undefined reference to `wattr_off'
/usr/lib/gcc/i486-linux-gnu/4.7/../../../../lib/libmenu.a(m_post.o): In function `unpost_menu':
m_post.c:(.text+0xa41): undefined reference to `delwin'
m_post.c:(.text+0xa53): undefined reference to `delwin'
collect2: error: ld returned 1 exit status

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com