2

I am trying to compile the following on Ubuntu 14.04 but am receiving an error. Can anyone point me in the right direction? I have tried -lpthread which has no effect.

Compile:

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

main.c (copy pasted from here save for the <cdk/cdk.h> correction)

#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);
}

Error:

/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
Community
  • 1
  • 1
Steven Leimberg
  • 785
  • 1
  • 4
  • 18

2 Answers2

4

Obviously, cdk requires ncurses to be directly supplied in command line. On my machine your test passes with:

gcc test.c -lcdk -lncurses
Konstantin Vladimirov
  • 6,791
  • 1
  • 27
  • 36
  • Thank you! Palmface... The man pages say -lcdk includes the curses libraries (among others), but it does not include ncurses (wtf..?). Thanks for your help. – Steven Leimberg Oct 14 '14 at 13:35
0

I use a makefile for compiling CDK in Linux (Debian Stable)

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

The parts I needed were two:

  1. where to find the header files

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

  1. to link the CDK library

LDLIBS := -lcdk

mrflash818
  • 930
  • 13
  • 24