Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 04-18-2013, 03:24 AM   #1
LQ Newbie
Registered: Nov 2012
Posts: 7

Rep: Reputation: Disabled
How to overcome the following error?

I got the following code,
    int main (int argc,char *argv[])
      struct sha512_ctx ctx;
      char sum[64];
      int result = 0;
      int cnt;
      for (cnt = 0; cnt < (int) ntests; ++cnt)
          sha512_init_ctx (&ctx);
          sha512_process_bytes (tests[cnt].input, strlen (tests[cnt].input), &ctx);
          sha512_finish_ctx (&ctx, sum);
          if (memcmp (tests[cnt].result, sum, 64) != 0)
    	  printf ("test %d run %d failed\n", cnt, 1);
    	  result = 1;
          sha512_init_ctx (&ctx);
          for (int i = 0; tests[cnt].input[i] != '\0'; ++i)
    	sha512_process_bytes (&tests[cnt].input[i], 1, &ctx);
          sha512_finish_ctx (&ctx, sum);
          if (memcmp (tests[cnt].result, sum, 64) != 0)
    	  printf ("test %d run %d failed\n", cnt, 2);
    	  result = 1;
      char buf[1000];
      memset (buf, 'a', sizeof (buf));
      sha512_init_ctx (&ctx);
      for (int i = 0; i < 1000; ++i)
        sha512_process_bytes (buf, sizeof (buf), &ctx);
      sha512_finish_ctx (&ctx, sum);
      static const char expected[64] =
      if (memcmp (expected, sum, 64) != 0)
          printf ("test %d failed\n", cnt);
          result = 1;
      for (cnt = 0; cnt < ntests2; ++cnt)
          char *cp = sha512_crypt (tests2[cnt].input, tests2[cnt].salt);
          if (strcmp (cp, tests2[cnt].expected) != 0)
    	  printf ("test %d: expected \"%s\", got \"%s\"\n",
    	   	  cnt, tests2[cnt].expected, cp);
    	  result = 1;
      if (result == 0)
        puts ("all tests OK");
      return result;
While executing the above code, I got the following error,

/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crt1.o: In
function `_start': (.text+0x20): undefined reference to `main'
collect2: ld returned 1 exit status
Can anyone help us to overcome this run-time error?
Old 04-18-2013, 03:54 AM   #2
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 982
Blog Entries: 2

Rep: Reputation: 244Reputation: 244Reputation: 244
Why is this in newbie and not programming?
Old 04-18-2013, 04:10 AM   #3
LQ Veteran
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390
Next time use the report button to ask a moderator to move the thread to another location, don't create a second thread (cross-posting is frowned upon).

Newly created duplicate thread can be found here:
Old 04-19-2013, 03:22 PM   #4
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,632

Rep: Reputation: 208Reputation: 208Reputation: 208
I'm closing this one, please post all responses to the one in Programming.


compilation, cprogramming, encryption

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
LXer: Android's last obstacle overcome LXer Syndicated Linux News 0 09-19-2011 01:20 AM
how to overcome grub problems in RHEL4 ranjithkumar721 Linux - Hardware 1 04-05-2008 03:06 AM
How to overcome symbol lookup error? unclesam Linux - Newbie 2 02-10-2006 02:50 AM
overcome chmod ohovus Linux - Security 4 11-29-2005 12:41 PM
imp...!grub error 23 how to overcome farhan Linux - General 0 03-11-2003 04:30 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:56 PM.

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