← Back to team overview

dolfin team mailing list archive

Re: Loading shared libraries

 

On Thu, Feb 09, 2006 at 02:47:24PM +0100, Garth N. Wells wrote:
> On Thu, 2006-02-09 at 14:34 +0100, Johan Jansson wrote:
> > 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.
> > 
> Nor did I until this morning. I found it on the libtool web page
> http://www.gnu.org/software/libtool/manual.html#Linking-executables
> 
> > 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>.
> > 
> 
> I didn't want to do this as I always have several versions of DOLFIN -
> at least one stable version with running models, and at least one
> development version. 
> 
> > 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.
> > 
> 
> OK, sounds good.
> 
> Garth

This seems like a good idea. Since we are always building the demos
against an installed version of DOLFIN, we know the location of the
shared library at compile-time, so we might as well include the
location in the executable. The problem would be if we were to
distribute precompiled executables separate from the library. Then we
would need to rely on finding the libraries somewhere in
LD_LIBRARY_PATH. But we don't so this should be ok.

So it would work to just modify dolfin-config?

/Anders



Follow ups

References