[petsc-users] Creating a dll on 64-bit environment
Matthew Knepley
knepley at gmail.com
Sat Mar 10 12:56:16 CST 2012
On Sat, Mar 10, 2012 at 11:49 AM, Markus Iivonen <
Markus.Iivonen at metropolia.fi> wrote:
> Hello,
>
> I've written a program on 32-bit environment and I want to use a dll.
> Everything worked fine until I uploaded the code on the other machine which
> run 64-bit os.
> At first I got an error:
>
> "/usr/bin/ld: MyClass.o: relocation R_X86_64_32S against `.rodata' can not
> be used when making a shared object; recompile with -fPIC
> MyClass.o: could not read symbols: Bad value"
>
> what was new for me because I haven't worked on 64bit environment before.
> Anyway at first I just tried to modify "-${CLINKER} -shared
> -Wl,-soname,${SONAME} -o ${VERS} *.o ${PETSC_MAT_LIB}" as "-${CLINKER}
> -shared -fPIC -Wl,-soname,${SONAME} -o ${VERS} *.o ${PETSC_MAT_LIB}"
>
> even after that I got the same error, after that I added -fPIC to CFLAGS
> and the error changed:
>
> "../petsc/petsc-3.2-p6/arch-linux2-cxx-debug/lib/libpetsc.a(err.o):
> relocation R_X86_64_32 against `ompi_mpi_comm_self' can not be used when
> making a shared object; recompile with -fPIC"
>
This is a known problem with OpenMPI. There response was "cry me a river".
Switch to MPICH and make sure
you configure with --with-shared-libraries.
Matt
> So here is my current makefile
>
>
> CFLAGS = - fPIC
> CCPPFLAGS =
> LOCDIR = /home/user/petsc/project/
> EXAMPLESC = x1.cpp x2.cpp x3.cpp
> PETSC_DIR = /home/user/petsc/petsc-3.2-p6/
>
> MYLIB = -L/home/user/petsc/project/opt/lib/ -libmyclass
> LIBADD = /.../user/petsc/project/opt/lib/
>
> VERS = libmyclass.so.1.0
> SONAME = libmyclass.so.1
> SOWOV = libmyclass.so
>
> include ${PETSC_DIR}/conf/variables
> include ${PETSC_DIR}/conf/rules
>
>
>
>
> MyProgram: main.o chkopts
> -${CLINKER} -o $@ $< ${MYLIB} ${PETSC_MAT_LIB}
> ${RM} main.o
>
> export LD_LIBRARY_PATH=${LIBADD}:$LD_LIBRARY_PATH
>
> LibMyProgram.so: MyClass.o chkopts
> -${CLINKER} -shared -Wl,-soname,${SONAME} -o ${VERS} *.o
> ${PETSC_MAT_LIB}
>
> mv ${VERS} ${LIBADD}
> ln -sf ${LIBADD}${VERS} ${LIBADD}${SOWOV}
> ln -sf ${LIBADD}${VERS} ${LIBADD}${SONAME}
>
> So would there be any kind of solution to this problem ?
>
> Thank You.
>
> Sincerely Markus Iivonen
--
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20120310/95f15921/attachment.htm>
More information about the petsc-users
mailing list