Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Need help regarding ld: fatal error

Posted on 2002-03-18
1
Medium Priority
?
275 Views
Last Modified: 2010-04-15
Here is my test program:

#include <stdio.h>
#include <math.h>

main () {
  double result;
  double x=2.718;

  result=log(x);
  printf("Log of %g is %.2g\n", x, result);
  return(0);
}

when I compile the program as follows:
cc test.c

I get the following error:

Undefined                       first referenced
 symbol                             in file
log                                 test.o
ld: fatal: Symbol referencing errors. No output written to a.out

The math.h file is in /usr/include. I tried compiling with -L /usr/include but it didn't work.


Thanks.
Theta.

0
Comment
Question by:theta
1 Comment
 
LVL 85

Accepted Solution

by:
ozo earned 200 total points
ID: 6877360
cc test.c -lm
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question