Hi Christopher, * Christopher Hulbert wrote on Fri, Feb 17, 2006 at 08:21:07PM CET: > I normally do not create shared libraries. The ONE place I do though > is with Matlab MEX functions which are nothing more than a shared > library with the mexFunction as an exported function. I link my > Matlab code against static libraries that contain my real functions > (The matlab interface serves exactly that an interface from matlab to > my C/fortran backend).
So do you compile your static library code with -fPIC? Because if not, then.. > Although it's not advised it works on 3 main > platforms that we use matlab on x86,x86_64,and win32. .. it will fail on x86_64 (for nontrivial code): echo 'int x = 0; int a() { return x; }' > a.c gcc -c a.c ar cru liba.a a.o echo 'extern int a(); int b() { return a(); }' > b.c gcc -fPIC -c b.c gcc -shared -o libb.so b.o -L. -la | /usr/bin/ld: ./liba.a(a.o): relocation R_X86_64_PC32 against `x' can not be used when making a shared object; recompile with -fPIC | /usr/bin/ld: final link failed: Bad value If you _do_ build the static library with -fPIC: just consider using a libtool convenience archive instead of a library. See the docs for the differences. Cheers, Ralf _______________________________________________ http://lists.gnu.org/mailman/listinfo/libtool