我试图在Ubuntu14.04上编译以下代码,但是收到了一个错误。谁能给我指明正确的方向?我试过没有效果的-lpthread。
编译:
gcc main.c -o terminal-app -lcdk -lpthreadmain.c (为更正从这里粘贴的副本)
#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发布于 2014-10-14 06:38:58
显然,cdk要求在命令行中直接提供ncurse。在我的机器上你的测试通过了:
gcc test.c -lcdk -lncurses发布于 2015-02-28 18:07:50
我使用makefile来编译Linux中的CDK (Debian稳定的)
我需要两个零件:
:= -Wall -g -I /usr/include/cdk
LDLIBS := -lcdk
https://stackoverflow.com/questions/26348743
复制相似问题