[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: exclusive static or shared
From: |
Ralf Wildenhues |
Subject: |
Re: exclusive static or shared |
Date: |
Fri, 17 Feb 2006 20:28:28 +0100 |
User-agent: |
Mutt/1.5.9i |
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
- exclusive static or shared, Christopher Hulbert, 2006/02/14
- Re: exclusive static or shared, Ralf Wildenhues, 2006/02/15
- Re: exclusive static or shared, Christopher Hulbert, 2006/02/15
- Re: exclusive static or shared, Ralf Wildenhues, 2006/02/15
- Re: exclusive static or shared, Christopher Hulbert, 2006/02/15
- Message not available
- Re: exclusive static or shared, Christopher Hulbert, 2006/02/15
- Re: exclusive static or shared, Ralf Wildenhues, 2006/02/17
- Re: exclusive static or shared, Christopher Hulbert, 2006/02/17
- Re: exclusive static or shared,
Ralf Wildenhues <=
- Re: exclusive static or shared, Ralf Wildenhues, 2006/02/15