[Numpy-discussion] C Extensions, CTypes and "external code & libraries"

Jon Wright wright@esrf...
Tue Feb 12 10:20:22 CST 2008


Lou Pecora wrote:
 >...  This appears to be the way
> static and shared libraries work, especially on Mac OS
> X, maybe elsewhere.

Have you tried linking against a GSL static library? I don't have a mac, 
but most linkers only pull in the routines you need. For example, using 
windows and mingw:

#include <stdio.h>
#include <gsl/gsl_sf_bessel.h>
int main (void)
{  double x = 5.0;
    double y = gsl_sf_bessel_J0 (x);
    printf ("J0(%g) = %.18e\n", x, y);
    return 0; }

...compiles to a.exe which outputs:

J0(5) = -1.775967713143382900e-001

The stripped executable is about 92 kB in comparison to the 2 mega byte 
libgsl.a. Unstripped there are about 150 symbols containing gsl, 
compared to 5351 symbols in the library libgsl.a. I just needed to put 
"-lgsl" on the command line and rename "$LIB/libgsl.dll.def" to 
something else so the shared version wasn't found.

In this case the linker has not pulled in all of the library. Presumably 
just the parts it needed, including various things like error reporting, 
sin, cos, exp etc. Older platforms, including vax and various unix'es 
also seemed to behave in the same way in the past.

Are you saying the mac is somehow different? Perhaps they're trying to 
hold people to "open source ransom", where they have to give away to 
source so it can be recompiled when the next OSX escapes ;-)

Cheers,

Jon








More information about the Numpy-discussion mailing list