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

Jed Brown jedbrown at mcs.anl.gov
Sat Mar 10 12:59:29 CST 2012


On Sat, Mar 10, 2012 at 11:49, 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"
>

And are you intending to build a 64-bit native binary? If so, you should be
sure to compile everything with the appropriate compiler flags (-m64 or
-march=native, for example).

If you want a shared PETSc library, be sure to configure
--with-shared-libraries


>
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20120310/73732655/attachment.htm>


More information about the petsc-users mailing list