[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Also from Algorithm genius

On  0, DSC Siltec <dscpubl@siltec.lt> wrote:
> Okay...  I'm not a genius, but this is going to be 
> a no-brainer for some of you, I can't figure it out.
> I have a simple program that uses log. 
> I have "include <math.h>" in my program.
> When I compile on gcc, I get "unknown identifier: log."
> gcc mylogprog.c -o mylogprog.exe
> I'm guessing that I need to specify libraries, but I don't 
> know what libraries to specify, and I don't know how to find
> out such things, or how to specify them.  

Correct.  You should not get 'unknown identifier: log', though, you
should get 'undefined reference to 'log''.  This works for me:

--- begin thing.c ---
#include <math.h>
int main( int argc, char** argv )
	int x = log( 2 );
--- end thing.c ---

gcc thing.c -o thing -lm

Tom Cook
Information Technology Services, The University of Adelaide

"That you're not paranoid does not mean they're not out to get you."
	- Robert Waldner

Get my GPG public key: https://pinky.its.adelaide.edu.au/~tkcook/tom.cook-at-adelaide.edu.au

Attachment: pgpLpvxCj0yfn.pgp
Description: PGP signature

Reply to: