[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]
GCC Compiler problem
Hi Vipin,
1. rpm -V: ignore the issues in localtime, it has changed since
installation since your localtime is not pointing to Asia/Calcutta (I
hope :)
2. undefined reference to log: append -lm to the compiler command
line:
gcc -o p p.c -lm
3. ld: I normally wouldn't use ld directly to link a program, I'd use
gcc. IAC your command has a typo (p/usr/lib/libc.a).
Regards,
-- Raju
>>>>> "Vipin" == <" <pandeyvip@xxxxxxxxxxxxxx>> writes:
Vipin> Hi folks I have a problem with the gcc compiler which is
Vipin> not linking programs that use the functions in <math.h>
Vipin> standard header. I have tried to Verify the glibc and
Vipin> glibc-devel packages on my system. glibc-devel is Ok but
Vipin> on verifying glibc package gives the following output
Vipin> rpm -V glibc S.5....T c /etc/localtime Which stands for
Vipin> (Error in S = File size, 5 means MD5 Sum, T means Mtime) I
Vipin> have reinstalled the package glibc but still rpm -V glibc
Vipin> gives the same error. As we can see this is a linking
Vipin> error, probably math.h is not present in C library
Vipin> properly. I do not know if this is a bug. Users with RH
Vipin> 6.2 installed from June2K of PCQ please try to run C code
Vipin> requiring any function from <math.h> and let me know if it
Vipin> works or gives error as in my case.
Vipin> Problem: --------------Start-------------------- gcc -o p
Vipin> p.c /tmp/ccOk5I48.o: In function `main':
Vipin> /tmp/ccOk5I48.o(.text 0x1e): undefined reference to `log'
Vipin> collect2: ld returned 1 exit status [vipin@vipin] ~$ vi p.c
Vipin> [vipin@vipin] ~$ cat p.c #include<stdio.h> #include<math.h>
Vipin> main() { double a, b; a=101; b = log(a); return 0;
Vipin> }
Vipin> OUTPUT 2
Vipin> ------------------------------------------------------------------
Vipin> gcc -c p.c -o p.o [vipin@vipin] ~$ ld -o p/usr/lib/libc.a
Vipin> p.o -lc ld: cannot open output file p/usr/lib/libc.a: No
Vipin> such file or directory [vipin@vipin] ~$ ld -o p
Vipin> /usr/lib/libc.a p.o -lc ld: warning: cannot find entry
Vipin> symbol _start; defaulting to 08048100 p.o: In function
Vipin> `main': p.o(.text 0x1e): undefined reference to `log'
Vipin> Problem ------------End--------------------------
Vipin> Please help me solve the problem.
--
Raju Mathur raju@xxxxxxxxxxxxx http://kandalaya.org/