【问题标题】:Undefined reference to stdscr [duplicate]对 stdscr 的未定义引用 [重复]
【发布时间】:2022-01-16 09:08:26
【问题描述】:

我想在最新版本的 ubuntu 中编译一个 C 代码。当我这样做时,我收到以下错误:
gcc <fileName>.c

/usr/bin/ld: /tmp/ccY8CJ10.o: in function `main':
sudoku.c:(.text+0xb8): undefined reference to `stdscr'
/usr/bin/ld: sudoku.c:(.text+0xc0): undefined reference to `wgetch'
collect2: error: ld returned 1 exit status

你知道是什么原因造成的吗?
我知道问题是代码中的&lt;curses.h&gt; 标头,但我不知道如何解决。

【问题讨论】:

  • 你必须链接curses库:gcc fileName.c -lcurses
  • 谢谢,它成功了。我曾经在文件名之前放置标志
  • 很好,不客气

标签: c linux gcc g++ undefined-reference


【解决方案1】:

您可以使用-lcurses。例如:gcc main.c -o demo -lcurses

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-03-21
    • 1970-01-01
    • 2011-07-27
    • 2013-06-20
    • 2012-02-05
    • 2014-12-27
    • 2012-11-15
    • 2017-01-26
    相关资源
    最近更新 更多