[Trilinos-Users] Building with -fPIC flag

Christopher Parmer christopher.parmer at gmail.com
Sat Jul 30 13:53:05 MDT 2011


Thanks Bill and Brent,

I cleaned everything and recompiled with -fPIC with no luck. I've since
recompiled with shared libraries turned ON and I had a successful compile.
Thanks again!

Chris

On Sat, Jul 30, 2011 at 10:39 AM, Bill Spotz <wfspotz at sandia.gov> wrote:

> Chris,
>
> My suspicion here is that matlap, a dynamic tool, expects dynamic (shared)
> libraries.  When you tried to load a static library, the lack of position
> independent code was the symptom, not the underlying problem.  Given your
> Epetra/AztecOO behavior, my guess is that Epetra worked because Epetra does
> not depend on any other packages.  However, AztecOO depends on Epetra, so
> when you tried to load AztecOO into matlab, it loaded Epetra a second time
> (which is how static libraries behave in a dynamic setting).  At this point,
> matlab had two copies of Epetra, meaning duplication of symbols, and matlab
> (or the compiler that compiled it) got confused.
>
> By compiling as shared, AztecOO will "share" the existing Epetra library,
> which is what you want.
>
> -Bill
>
> On Jul 29, 2011, at 12:46 PM, Perschbacher, Brent M wrote:
>
> > Hello Chris,
> >  What Bill said is true, turning on shared libraries will force the
> > libraries to be built with position independent code. I have a feeling
> that
> > this is more along the lines of what matlab is expecting too, ie using
> > dlopen to load the correct libraries.
> >
> > However, what you did should work too, at least for building static libs
> > with position independent code. I just did a test on my machine and
> adding
> > -fPIC to the compile flags worked. Why your aztecoo libraries didn't
> built
> > with it I couldn't say without more information. If you you really want
> to
> > stay with static libraries I would suggest you run "make clean" in your
> > build dir, delete your CMakeCache.txt file and CMakeFiles directory and
> then
> > try configuring and building again. If you don't require static libraries
> > then enabling shared libraries is the easiest way to go.
> >
> > Brent
> >
> >
> > On 7/29/11 12:27 PM, "Bill Spotz" <wfspotz at sandia.gov> wrote:
> >
> >> Chris,
> >>
> >> Position independent code is associate with shared libraries.  I believe
> that
> >> if you configure with
> >>
> >>    -D BUILD_SHARED_LIBS:BOOL=ON
> >>
> >> then all of the libraries should be compiled properly for you.
> >>
> >> -Bill
> >>
> >> On Jul 29, 2011, at 11:14 AM, Christopher Parmer wrote:
> >>
> >>> Hi All,
> >>>
> >>> I'm linking my trilinos project with matlab and so I (er.. matlab mex
> files)
> >>> need the libraries to be 'position independent' or compiled with the
> -fPIC
> >>> flag.
> >>>
> >>> I tried rebuilding trilinos (via ccmake, make, make install) with -fPIC
> in
> >>> CMAKE_CXX_FLAGS, (and later I added it to CMAKE_C_FLAGS,
> >>> CMAKE_EXE_LINKER_FLAGS), but I get the same error with respect to the
> >>> libaztecoo and a few other packages. However, my simple examples with
> Epetra
> >>> CrsMatrices now work.
> >>>
> >>> Am I missing a flag somewhere? Or are some libraries not written to be
> >>> 'position independent'?
> >>>
> >>> Sorry if this is a simple question - I'm very new to linking and
> building
> >>> large packages.
> >>>
> >>> Thanks,
> >>>
> >>> Chris
> >>>
> >>> --
> >>> (802) 343-5897
> >>> _______________________________________________
> >>> Trilinos-Users mailing list
> >>> Trilinos-Users at software.sandia.gov
> >>> http://software.sandia.gov/mailman/listinfo/trilinos-users
> >>
> >> ** Bill Spotz                                              **
> >> ** Sandia National Laboratories  Voice: (505)845-0170      **
> >> ** P.O. Box 5800                 Fax:   (505)284-0154      **
> >> ** Albuquerque, NM 87185-0370    Email: wfspotz at sandia.gov **
> >>
> >> _______________________________________________
> >> Trilinos-Users mailing list
> >> Trilinos-Users at software.sandia.gov
> >> http://software.sandia.gov/mailman/listinfo/trilinos-users
>
>
>


-- 
(802) 343-5897
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://software.sandia.gov/pipermail/trilinos-users/attachments/20110730/654fb5cf/attachment.html 


More information about the Trilinos-Users mailing list