This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Documentation comments...


gcc-bugs,

I have a comment on the GNU documentation.  This may be the wrong venue but if you would forward it to the correct party I would appreciate it. 

I've been working on compiling a program on our Sun that was working and then we added a call to sqrt and broke the link.  From there I've searched the on-line documentation for information about sqrt.  To say it was sparse would be an understatement.  Finally after a bit of searching I sent an email (below) which was answered in about 5 minutes with the obvious fix of:  link with -lm.  Duh.  Once I knew what I was looking for I was able to find a reference:

From the introduction of a libc.a reference, "Note that many of the functions in `libm.a' (the math library) are defined in `math.h' but are not present in libc.a."  You must link with -lm to link in the math library.  The URL for this reference is http://www.delorie.com/djgpp/doc/libc-2.02/.

My comment overall is that I shouldn't have had to dig through so much documentation without finding what appears now to be an obvious point.  I can find very explicit information on peep-hole optimization and other items.  But the mundane information is harder to come by.  Next update to the documentation you might want to consider the addition of some type of primer/library refernence/etc.  Something that helps new users gain traction more quickly than now.  My 2 cents.

-----------------------------------------------------------------------------------------------------------

gcc help,

Obviously I am new to the GNU gcc compiler.

I've been trying compile a program on our SUN with gcc (sparc-sun-solaris2.7/2.95.1) and it contains some intrinsic functions. When I get to the point of linking it doesn't recognize the functions, eg: sqrt. Below is a test program. What is missing that I am not finding the built-in functions to link with? Thanks for any help.

file:marc.c:
#include <stdio.h>
#include <math.h>
main()
{
double x = 2;
printf("sqrt of %e is %e\n",x,sqrt(x));
}
gcc -c marc.c
gcc -o marc.out marc.o
Undefined first referenced
symbol in file
sqrt marc.o
ld: fatal: Symbol referencing errors. No output written to marc.out
collect2: ld returned 1 exit status

- bjd
____________________________
Brian J. Dent
CompuDent
v (831) 649-0948 f (707) 222-1209
http://www.redshift.com/~briandent/
Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]