[Trilinos-Users] Building with -fPIC flag
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.
On Sat, Jul 30, 2011 at 10:39 AM, Bill Spotz <wfspotz at sandia.gov> wrote:
> 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.
> 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
> > 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
> > -fPIC to the compile flags worked. Why your aztecoo libraries didn't
> > with it I couldn't say without more information. If you you really want
> > stay with static libraries I would suggest you run "make clean" in your
> > build dir, delete your CMakeCache.txt file and CMakeFiles directory and
> > 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
> >> 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
> >>> need the libraries to be 'position independent' or compiled with the
> >>> flag.
> >>> I tried rebuilding trilinos (via ccmake, make, make install) with -fPIC
> >>> 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
> >>> 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
> >>> 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
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Trilinos-Users