Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/303.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
对ncurses库中函数的未定义引用_C_Linux_Gcc_Ncurses - Fatal编程技术网

对ncurses库中函数的未定义引用

对ncurses库中函数的未定义引用,c,linux,gcc,ncurses,C,Linux,Gcc,Ncurses,我试图使用ncurses库v5.9编译以下代码。关于Debian气喘。 但我得到了图书馆功能的未定义参考。 我从源代码安装了库 #include <curses.h> #include <menu.h> #include<stdlib.h> #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) #define CTRLD 4 char *choices[] = { "C

我试图使用ncurses库v5.9编译以下代码。关于Debian气喘。 但我得到了图书馆功能的未定义参考。
我从源代码安装了库

#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();   
}

直接引用自
人工菜单

在库列表中,libmenu.a应位于libncurses.a之前;也就是说,您想说
-lmenu-lncurses
,而不是反过来说(这通常会导致链接错误)


直接引用自
人工菜单

在库列表中,libmenu.a应位于libncurses.a之前;也就是说,您想说
-lmenu-lncurses
,而不是反过来说(这通常会导致链接错误)


即使将
stdlib
作为第一个
include
行,您也会得到这样的结果吗?实际上stdlib不是问题所在。我删除了它,但仍然收到相同的错误“我从源代码安装了库。”-为什么?我只使用curses.h执行了一个没有菜单.h标题的简单程序。成功了。没有错误。但是当我尝试使用菜单。h这个错误弹出这看起来不像C++,不是代码也不是错误消息。你得到这个甚至与<代码> STDLIB < /代码>,因为第一个<代码>包含< /代码>行吗?实际上,STDLIB不是问题。我删除了它,但仍然收到相同的错误“我从源代码安装了库。”-为什么?我只使用curses.h执行了一个没有菜单.h标题的简单程序。成功了。没有错误。但是当我尝试使用菜单。h这个错误突然出现了。这看起来不像C++,不是代码,也不是错误消息。谢谢人类。它工作了。谢谢。
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