Thread: Compile Error

  1. #1
    Registered User
    Join Date
    Sep 2007
    Posts
    30

    Compile Error

    Does anyone know what this might be caused by?

    Undefined first referenced
    symbol in file
    main /usr/local/lib/gcc/sparc-sun-solaris2.9/3.4.2/crt1.o
    ld: fatal: Symbol referencing errors. No output written to a.out
    collect2: ld returned 1 exit status

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Usually crt1 is part of the runtime library to start the application, so it will call main from there. If you are trying to compile something that doesn't contain a "main", then this would be the likely outcome. There are two possible scenarios:
    1. You are compiling a file that is a part of a larger application, and you should be compiling it with "-c" to say "don't try to link this to form an application just yet". Eventually you would combine the object files (a.o, b.o, etc) into a complete application.
    2. You have a single file applicaiton, but for some reason, it doesn't have a main in it.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Sep 2007
    Posts
    30
    Brilliant! Thanks!

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    So just out of curiosity, which of the two alternatives applied in this case?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Beginner Needs help in Dev-C++
    By Korrupt Lawz in forum C++ Programming
    Replies: 20
    Last Post: 09-28-2010, 01:17 AM
  2. An error is driving me nuts!
    By ulillillia in forum C Programming
    Replies: 5
    Last Post: 04-04-2009, 09:15 PM
  3. DX - CreateDevice - D3DERR_INVALIDCALL
    By Tonto in forum Game Programming
    Replies: 3
    Last Post: 12-01-2006, 07:17 PM
  4. error: template with C linkage
    By michaels-r in forum C++ Programming
    Replies: 3
    Last Post: 05-17-2006, 08:11 AM
  5. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-29-2005, 11:21 PM