← Back to team overview

dolfin team mailing list archive

Re: Loading shared libraries

 

On Thu, Feb 09, 2006 at 11:57:36AM +0100, Garth N. Wells wrote:
> If I add "libtool --mode=link" by hand in the Makefile where executables
> are made,
> 
> $(DEST): $(OBJECTS)
>          libtool --mode=link $(CXX) -o $@ $(OBJECTS) $(CFLAGS) $(LIBS)
> 
> it works. Is there a simpler way? Should the script dolfin-config
> --compiler by able to return 
> 
> libtool --mode=link g++ ?
> 
> Garth
> 

Ok, I didn't know you could do this.

What you usually need to do with shared libraries is to specify for
the dynamic loader where to look for shared libraries. On Linux you
can do this by adding paths to /etc/ld.so.conf or by setting the
environment variable LD_LIBRARY_PATH. You can check which libraries
are used (or missing) by an executable by: ldd <executable>.

It seems it's also possible to add a path directly in the executable,
as you have shown above (an -rpath flag is given to the linker).

I don't see any real disadvantages of doing this, so I think we should
adopt this. It would also eliminate the hassle of setting the library
path yourself.

By using libtool in dolfin-config we should also be able to create
shared libraries in a platform-independent way, which is needed for
the dolfin-swig tool anyway (for generating Python modules from
forms).

  Johan



Follow ups

References