gcc -lm and libm.a for Mac OS X

Andrew Pinski pinskia@physics.uc.edu
Tue Nov 11 16:41:00 GMT 2003


On Nov 11, 2003, at 8:31 AM, Vincent Lemaitre wrote:

> Hi,
>
> When running the following command:
> gcc -lm test_isnan.cc
>
> I got the following error message:
>
> ld: Undefined symbols:
> ___gxx_personality_v0

This symbol is needed for exception handling in c++, either compile 
with g++ or use -fno-exceptions or use higher optimizations.


>
> The libm.a is missing in /usr/lib. And I suspect this is (part of) the 
> reason of the reason for the error.

libm.a does not exists because it is part of the libSystem.dyld and 
Apple does not provide static libraries.


>
> Could somebody explain me where and how to get libm.a under Mac OSX? 
> Or is there another way to link the math library?


You do not have to explicitly link with the math library on Mac OS X 
(aka Darwin) to use it, it is already included in libSystem.

>
> The gcc man page on Apple web site takes it for granted that libm.a 
> should be in /usr/local, but it is not. The only library that could be 
> a math library is libm.dylib@...
> (I have installed the Apple's Developper's Tools and all the C 
> libraries I could find with fink, without success).
>
> Thank you in advance,
>
> Vincent
>
> test_isnan.cc:
>
> #include <stdio.h>
> #include <math.h>
>
> int main()
> {
>
>   printf("Hello it's test program for isnan()\n");
>
>   printf(" \"3000\" is a NUMBER?\t: %d\n",isnan(3000.0));
>
>   return 1;
> }
>
>
>



More information about the Gcc-bugs mailing list