【问题标题】:Curses Development Kit - DSO missing from command line诅咒开发工具包 - 命令行中缺少 DSO
【发布时间】:2014-10-13 20:56:15
【问题描述】:

我正在尝试在 Ubuntu 14.04 上编译以下内容,但收到错误消息。谁能指出我正确的方向?我试过-lpthread 没有效果。

编译:

gcc main.c -o terminal-app -lcdk -lpthread

ma​​in.c(从here 复制粘贴,以备 更正)

#include <cdk/cdk.h>

void main()
{
  CDKSCREEN   *cdkscreen;
  CDKLABEL    *demo;
  WINDOW      *screen;
  char        *mesg[4];

  /* Initialize the Cdk screen.   */
  screen = initscr();
  cdkscreen = initCDKScreen (screen);

  /* Start CDK Colors */
  initCDKColor();

  /* Set the labels up.      */
  mesg[0] = "</31>This line should have a yellow foreground and a cyan background.<!31>";
  mesg[1] = "</05>This line should have a white  foreground and a blue background.<!05>";
  mesg[2] = "</26>This line should have a yellow foreground and a red  background.<!26>";
  mesg[3] = "<C>This line should be set to whatever the screen default is.";

  /* Declare the labels.     */
  demo   = newCDKLabel (cdkscreen, CENTER, CENTER, mesg, 4, TRUE, TRUE);

  /* Draw the label          */
  drawCDKLabel (demo, TRUE);
  waitCDKLabel (demo, ' ');

  /* Clean up           */
  destroyCDKLabel (demo);
  destroyCDKScreen (cdkscreen);
  endCDK();
  exit (0);
}

错误:

/usr/bin/ld: /tmp/ccUtj1kg.o: undefined reference to symbol 'initscr'
//lib/x86_64-linux-gnu/libncurses.so.5: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

【问题讨论】:

    标签: gcc compiler-errors ncurses


    【解决方案1】:

    显然,cdk 需要在命令行中直接提供 ncurses。在我的机器上,您的测试通过:

    gcc test.c -lcdk -lncurses
    

    【讨论】:

    • 谢谢! Palmface ...手册页说-lcdk包括curses库(以及其他),但它不包括ncurses(wtf..?)。感谢您的帮助。
    【解决方案2】:

    我使用 makefile 在 Linux (Debian Stable) 中编译 CDK

    http://mrflash818.geophile.net/software/nc_834v5010generator/makefile

    我需要的部分是两个:

    1. 在哪里可以找到头文件

    CXXFLAGS := -Wall -g -I /usr/include/cdk

    1. 链接 CDK 库

    LDLIBS := -lcdk

    【讨论】:

      猜你喜欢
      • 2016-01-20
      • 2019-01-12
      • 2016-11-17
      • 2014-07-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-25
      • 2021-05-18
      相关资源
      最近更新 更多