Libraries to link under Linux's gcc compiler 
Author Message
 Libraries to link under Linux's gcc compiler

NOTE: This message has been posted to the comp.lang.c moderated and
comp.lang.c newsgroups under the same title.

Greetings,

While compiling a simple program
------------------------
#include <stdio.h>
#include <math.h>

int main()
{
    printf("The square root of 81 is %f", sqrt(81.0));

    return (0);

Quote:
}

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

using gcc 2.8.1 under SuSE Linux 6.1, I kept getting error messages
stating the sqrt was an unknown function. After I learned that I needed
to link in the math library, the problem resolved.

There was nothing in any documentation that I could find that said to
link in the math library. My concern is about the other things out there
that needed libraries to be linked in and will bite me as this one did
today.... <g>.

Where can I find which functions needed to have what libraries linked
when linking programs under gcc? Is there a master list that says if you
use, for example sqrt, you need to link in the math library?

Thanx.

B. O'Fallon
"The only dumb question is the one that isn't asked"
--



Tue, 12 Feb 2002 03:00:00 GMT  
 Libraries to link under Linux's gcc compiler


Quote:
>Where can I find which functions needed to have what libraries linked
>when linking programs under gcc? Is there a master list that says if you
>use, for example sqrt, you need to link in the math library?
>From your implementation documentation.  #include <math.h> etc. tells

the compiler the necessary declarations so that it can create the basic
code.  However you will also need to tell the linker where it is to look
for unresolved externals.  IOWs when the linker has done its best at
resolving function calls from the compiled TUs that you have provided,
where should it look for other ones.  Only the documentation of your
linker can tell you this.  

Francis Glassborow      Journal Editor, Association of C & C++ Users
64 Southfield Rd
Oxford OX4 1PA          +44(0)1865 246490
All opinions are mine and do not represent those of any organisation
--



Wed, 13 Feb 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Libraries to link under Linux's gcc compiler

2. Need text window library for Linux GCC

3. shared libraries with gcc under Linux

4. asm with GCC compiler in Linux

5. problems withs using gcc compiler on Linux and Win2000

6. what's the difference between cc on hp-ux 11.0 and gcc on linux

7. Linux/gcc/Intel Inline Maths and php's round

8. Padding option in 'gcc' compiler

9. Standard Library of gcc compiler?

10. Q: Linking gcc object files w/ Borland library

11. shared libraries with gcc/SparcWorks compiler

12. I don't know the command of c compiler on the linux corel

 

 
Powered by phpBB® Forum Software