Solved

Need help regarding ld: fatal error

Posted on 2002-03-18
1
257 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 84

Accepted Solution

by:
ozo earned 50 total points
Comment Utility
cc test.c -lm
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now