c - 如何在 Ubuntu 16.04 的 Codeblocks 13.12 中包含或链接 ncurses/curses 库?

标签 c linux ubuntu codeblocks

希望你做得很好!

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

  1. 对“stdscr”的 undefined reference
  2. 对“wgetch”的 undefined reference

这是我的示例代码:

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

解决方案是什么? 我知道我必须在命令行中将库链接到我的源代码文件。

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

符合没有错误

Enter a character: 
Its ASCII is : -1

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

我想自动从代码块构建/编译我的代码。那么,如何在 codeblocks 13.12 中链接 ncurses 库?

提前致谢。

纳兹穆尔

最佳答案

设置> 编译器> 搜索目录

点击添加

enter image description here

我链接了boost

enter image description here

enter image description here


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

enter image description here

关于c - 如何在 Ubuntu 16.04 的 Codeblocks 13.12 中包含或链接 ncurses/curses 库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42189167/

相关文章:

c - 为什么 sem_open 在没有共享内存的情况下与 fork() 一起工作?

c - 如何用C语言从整数数组中读取2位?

linux - 本地缓存的dns无法通过缓存刷新linux解除缓存

java - 手动安装时无法在 ubuntu 14.04 中设置 JAVA_HOME 变量

c - 操作系统内存管理,段错误?

c++ - sigsegv 发生在 posix_memalign 在某些设备和 AIX 中的编译选项后立即释放时

php - PDF 缩略图 shell 命令问题 - PHP

android - 在构建 cordova 项目时出现 ANDROID_HOME PATH 错误

Linux 不会晚于预定时间执行预定作业

c++ - 终端不显示程序的警告...如何在终端中查看它们?