如何在 Ubuntu 16.04 的 Codeblocks 13.12 中包含或 link ncurses/curses 库?

How to include or link ncurses/ curses library in Codeblocks 13.12 in Ubuntu 16.04?

希望你一切顺利!

我在基于 ubuntu 16.04 的基础 OS (Loki) 中使用代码块 13.12。最近,我尝试在我的 C 语言编码中使用 getch()、getche() 函数,为此我在我的系统中安装了 ncurses 库。当我尝试构建代码时,我收到两条错误消息 -

  1. 对 'stdscr'
  2. 的未定义引用
  3. 对 'wgetch'
  4. 的未定义引用

这是我的示例代码:

#include'stdio.h'
#include'ncurses.h'
int main(){
    char ch;
    printf("Enter a character: ");
    ch=getch();
    printf("\nIts ASCII is : %d .",ch);
    return 0;
}        

解决方法是什么? 我知道我必须 link 在命令行中将库添加到我的源代码文件中。

这是我的命令行执行:
gcc -o example_3_1_1test1 example_3_1_1.c -lncurses

符合无误

Enter a character: 
Its ASCII is : -1

这是错误的。因为我的程序不接受键盘输入并自动 returns -1。

我想 build/complile 自动从代码块中提取我的代码。那么,我如何 link codeblocks 13.12 中的 ncurses 库?

提前致谢。

纳兹穆尔

设置 > 编译器 > 搜索目录

只需点击添加

我链接了 boost


把你的 -lncurses 放在这里,就像我放 -pthreadstd=c11