[petsc-users] Creating a dll on 64-bit environment

Markus Iivonen Markus.Iivonen at metropolia.fi
Sat Mar 10 11:49:33 CST 2012


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