LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-05-2007, 11:00 AM   #1
ilnli
Member
 
Registered: Jul 2004
Location: Pakistan
Distribution: Slackware 10.0, SUSE 9.1, RH 7, 7.3, 8, 9, FC2
Posts: 413

Rep: Reputation: 32
compilation error


when I try to compile the following code with command

Code:
#include "cdk/cdk.h"

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

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

   /* Set the labels up.                */
   mesg[0] = "<R></B/1>This line should have a yellow foreground and a blue background.<!1>";
   mesg[1] = "</U/2>This line should have a white  foreground and a blue background.<!2>";
   mesg[2] = "<B=+>This is a bullet.";
   mesg[3] = "<I=10>This is indented 10 characters.";
   mesg[4] = "<C>This line should be set to whatever the screen default is.";

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

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

   /* Clean up                  */
   destroyCDKLabel (demo);
   destroyCDKScreen (cdkscreen);
   endCDK();
   exit (0);
}
Code:
debian:~/Desktop/cdk-5.0-20060507# gcc    -c test.c -o test.o
test.c: In function ‘main’:
test.c:4: warning: return type of ‘main’ is not ‘int’

but when I try to make the executable it gives me the following error
Code:
debian:~/Desktop/cdk-5.0-20060507# gcc  test.c
test.c: In function ‘main’:
test.c:4: warning: return type of ‘main’ is not ‘int’
/tmp/cc2H5gFa.o: In function `main':
test.c:(.text+0x12): undefined reference to `initscr'
test.c:(.text+0x20): undefined reference to `initCDKScreen'
test.c:(.text+0x80): undefined reference to `newCDKLabel'
test.c:(.text+0xaf): undefined reference to `waitCDKLabel'
test.c:(.text+0xba): undefined reference to `_destroyCDKObject'
test.c:(.text+0xc5): undefined reference to `destroyCDKScreen'
test.c:(.text+0xca): undefined reference to `endCDK'
collect2: ld returned 1 exit status
can anyone please tell what can be the problem?

regards,
Imran
 
Old 08-05-2007, 12:40 PM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

1. To get rid of this warning, you should:
Quote:
warning: return type of ‘main’ is not ‘int’
Code:
int
main (int argc, char *argv[])
"int main" isn't absolutely necessary (it's just a warning) ... but I would argue it's very good practice. Honest!

2. Fixing this will cause a second warning. You should also change "exit (0)" to:
Code:
  return 0;
Again, it isn't necessary ... but "return 0;" from function "main ()" is simply better form than calling "exit ()".

3. Finally, your program uses CDE ... so you need to include the CDK library when you link your program. For example:
Quote:
gcc -g test.c -o test -lcdk -lncurses
In the above example, "-lcdk" specifies your CDK library. CDK, in turn, will probably need "-lncurses". You don't need "-c" (this example compiles and links in one step), you don't need "-o test.o" ("test.o" is the default object name; re-specifying it is just redundant). The "-g" allows you to run your program in a debugger - always a Good Idea.

'Hope that helps .. PSM

Last edited by paulsm4; 08-05-2007 at 11:59 PM.
 
Old 08-05-2007, 07:07 PM   #3
ilnli
Member
 
Registered: Jul 2004
Location: Pakistan
Distribution: Slackware 10.0, SUSE 9.1, RH 7, 7.3, 8, 9, FC2
Posts: 413

Original Poster
Rep: Reputation: 32
thanks alot it worked
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Kernel compilation error: Error 15: File not found Niceman2005 Linux - General 9 10-04-2007 03:45 AM
compilation error deepshikha Linux - Server 2 06-08-2007 01:51 AM
Compilation Error abdullahgee Programming 9 05-21-2004 12:29 AM
Error during Compilation vipinsharma Programming 0 05-20-2004 10:40 AM
Sqwebmail compilation error ... [maildirsearchC.o] Error 1 boogie_maan Linux - Software 0 10-26-2002 07:21 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:32 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration