[Numpy-discussion] building numpy with atlas on ubuntu edgy

David Cournapeau david at ar.media.kyoto-u.ac.jp
Wed Apr 18 23:12:24 EDT 2007


Robert Kern wrote:
> Charles R Harris wrote:
>> I'm wondering if the static libraries could simply be compiled with the
>> -fPIC flag and linked with the program to produce the dynamic library.
>> The static libraries are just collections of *.o files, so I don't see
>> why that shouldn't work.
>
> I don't think there is a reason why it *wouldn't* work; it's just that one needs
> to do "gcc -shared" to make a .so and that flag also tells the linker to choose
> .so's over .a's for the libraries that get linked into the target .so.
>
Ok, I found it much faster than I expected: you should use the option 
-Bdynamic of the *linker*, that is, for example:

gcc -shared -o c_gaussd.mexglx c_gaussd.o mex_alloc.o 
-L/usr/local/matlab/bin/glnx86  -L/usr/media/boulot/local/lib 
-L/usr/lib/atlas -Wl,-Bstatic,-lem_full -llapack_atlas -latlas 
-Wl,-Bdynamic,-lmx -lmex

will build a shared "library" c_gaussd.mexglx from c_gaussd.o and 
mex_alloc.o, statically link libem_full, lapack_atlas and atlas, and 
dynamically everything else. This was working, as otherwise, matlab 
would have picked up atlas symbols from its existing, already linked own 
atlas, and not from the atlas installed on my system (which was crashing 
matlab and was the reason why I went through this pain in the first place).

cheers,

David



   




More information about the NumPy-Discussion mailing list