<div class="gmail_quote">On Sat, Mar 10, 2012 at 11:49, Markus Iivonen <span dir="ltr">&lt;<a href="mailto:Markus.Iivonen@metropolia.fi">Markus.Iivonen@metropolia.fi</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello,<br>
<br>
I&#39;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.<br>
At first I got an error:<br>
<br>
&quot;/usr/bin/ld: MyClass.o: relocation R_X86_64_32S against `.rodata&#39; can not be used when making a shared object; recompile with -fPIC<br>
MyClass.o: could not read symbols: Bad value&quot;<br></blockquote><div><br></div><div>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).</div>
<div><br></div><div>If you want a shared PETSc library, be sure to configure --with-shared-libraries</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
what was new for me because I haven&#39;t worked on 64bit environment before. Anyway at first I just tried to modify &quot;-${CLINKER} -shared -Wl,-soname,${SONAME} -o ${VERS}   *.o  ${PETSC_MAT_LIB}&quot; as &quot;-${CLINKER} -shared -fPIC -Wl,-soname,${SONAME} -o ${VERS}   *.o  ${PETSC_MAT_LIB}&quot;<br>

<br>
even after that I got the same error, after that I added -fPIC to CFLAGS and the error changed:<br>
<br>
&quot;../petsc/petsc-3.2-p6/arch-linux2-cxx-debug/lib/libpetsc.a(err.o): relocation R_X86_64_32 against `ompi_mpi_comm_self&#39; can not be used when making a shared object; recompile with -fPIC&quot;<br>
<br>
So here is my current makefile<br>
<br>
<br>
CFLAGS          = - fPIC<br>
CCPPFLAGS       =<br>
LOCDIR          = /home/user/petsc/project/<br>
EXAMPLESC       = x1.cpp x2.cpp x3.cpp<br>
PETSC_DIR       = /home/user/petsc/petsc-3.2-p6/<br>
<br>
MYLIB           = -L/home/user/petsc/project/opt/lib/ -libmyclass<br>
LIBADD          = /.../user/petsc/project/opt/lib/<br>
<br>
VERS            = libmyclass.so.1.0<br>
SONAME          = libmyclass.so.1<br>
SOWOV           = libmyclass.so<br>
<br>
include ${PETSC_DIR}/conf/variables<br>
include ${PETSC_DIR}/conf/rules<br>
<br>
<br>
<br>
<br>
MyProgram: main.o chkopts<br>
    -${CLINKER} -o $@ $&lt; ${MYLIB} ${PETSC_MAT_LIB}<br>
    ${RM} main.o<br>
<br>
    export LD_LIBRARY_PATH=${LIBADD}:$LD_LIBRARY_PATH<br>
<br>
LibMyProgram.so: MyClass.o  chkopts<br>
    -${CLINKER}  -shared -Wl,-soname,${SONAME} -o ${VERS}   *.o  ${PETSC_MAT_LIB}<br>
<br>
    mv ${VERS} ${LIBADD}<br>
    ln -sf ${LIBADD}${VERS} ${LIBADD}${SOWOV}<br>
    ln -sf ${LIBADD}${VERS} ${LIBADD}${SONAME}<br>
<br>
So would there be any kind of solution to this problem ?<br>
<br>
Thank You.<br>
<br>
Sincerely Markus Iivonen</blockquote></div><br>