Thread: Quick compiling error..

  1. #1
    Registered User
    Join Date
    Feb 2010
    Posts
    5

    Quick compiling error..

    I can't seem to find the solution to this error.

    I'm relatively new to C programming.


    Code:
    hw4.c:61:2: warning: no newline at end of file
    Undefined                       first referenced
     symbol                             in file
    pow                                 /var/tmp//ccN4AJpg.o
    ld: fatal: Symbol referencing errors. No output written to a.out
    collect2: ld returned 1 exit status
    any information is welcome. Thanks

  2. #2
    Registered User
    Join Date
    Feb 2010
    Posts
    57

    Re: Quick compiling error..

    If you compile simply it will this error for only math.h. Because sometimes it may not include in our program.

    So you need to use -lm option to include the math.h header file.

    cc -lm <programname>

    After compiling with this option If you execute that you won't get this error.

    This -l option used to search and link the library files
    Last edited by sganesh; 02-26-2010 at 11:49 PM. Reason: missing some suggestion

  3. #3
    Registered User
    Join Date
    Feb 2010
    Posts
    5
    Thanks. I really appreciate that. Worked great.

    Is there any background as to why that error occurs?

  4. #4
    Registered User
    Join Date
    Feb 2010
    Posts
    57

    Re: Quick compiling error..

    yeah. It may not search or link that math.h header file correctly in out program. For this problem only they have provided the -l option in cc compiler.

  5. #5
    Registered User
    Join Date
    Feb 2010
    Posts
    5
    Thanks for the help. I greatly appreciate it.

  6. #6
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    A better answer is that you are trying to call a function that does not reside within your executable, but another .dll file elsewhere. The compiler/linker doesn't know where this function lies, and must know this in order to compile your executable.
    So you must tell the linker where to look for this information, and this is what you do by specifying this command line option.

    The first warning is because you don't have a newline at the end of your file. This is required for some reason.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. what am I missing? (Program won't compile)
    By steals10304 in forum C Programming
    Replies: 3
    Last Post: 08-25-2009, 03:01 PM
  2. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  3. How to monitor process creation?
    By markiz in forum Windows Programming
    Replies: 31
    Last Post: 03-17-2008, 02:39 PM
  4. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  5. Using VC Toolkit 2003
    By Noobwaker in forum Windows Programming
    Replies: 8
    Last Post: 03-13-2006, 07:33 AM