[petsc-users] Creating a dll on 64-bit environment
Satish Balay
balay at mcs.anl.gov
Sat Mar 10 12:57:09 CST 2012
Everything that goes into .so file should be built with -fPIC.
So you have to make sure MPI/PETSc are built with -fPIC flag. One way
to do this is to build woth PETSc and MPI as shared libraries.
Not sure what MPI you are using - but wrt PETSc - use the configure
option --with-shared-libraries=1
Satish
On Sat, 10 Mar 2012, Markus Iivonen 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"
>
> 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
More information about the petsc-users
mailing list