【问题标题】:How do I avoid the stray error when compiling a c program with the library pdcurses?使用库 pdcurses 编译 c 程序时如何避免杂散错误?
【发布时间】:2022-08-17 00:47:33
【问题描述】:

当我意识到我需要 pdcurses 库时,我正在使用 Windows 上的代码块编写 c 程序,因此下载并构建了它,但是在将其导入代码块后,当我运行测试代码时,出现以下错误:

代码是:

#include <stdio.h>

#include <stdlib.h>

#include <pdcurses.a>

int main(){

    initsrc();

    printw(\"Hello world!\\n\");
    refresh();
    getch();

    endwin();
    return 0;
}

有人可以帮我解决这个问题吗?

    标签: c windows


    【解决方案1】:

    扩展名为“.a”的文件是一个库文件,它是二进制的。您没有使用#include 将其包含在您的代码中。

    您应该做的是#include 与此库关联的头文件,然后在项目配置中链接库文件。

    【讨论】:

      【解决方案2】:

      此代码经过测试可与 PDCurses 一起使用。请注意,您不需要其他 #include

      #include <curses.h>
      
      int main(void)
      {
          initscr();
          addstr("Hello World!\n");
          refresh();
          getch();
      
          endwin();
          return 0;
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2016-07-10
        • 2023-03-07
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-05-03
        相关资源
        最近更新 更多