-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi Anthony,
the your binary does not use the library. Here is why:
g++ -shared -fPIC -o libpro.so 2D_CBS_Solver.cpp
creates the library with the contents of 2D_CBS_Solver.cpp.
But when you link your executable with
${CLINKER} -o pro pro.o 2D_CBS_Solver.o ${PETSC_LIB}
in your makefile you link 2D_CBS_Solver again. Therefore its contents
is linked statically to your executable "pro" and the library is not
needed to resolve any symbols. Hence the linker places no reference in
"pro".
Best
Klaus
Am 21.10.2013 22:33, schrieb Anthony Vergottis:
> When running ./pro the program works as expected, but when the .so
> file is recompiled ./pro does not show any change. Change occurs
> only when the makefile is rerun. When moving ${LIBS} before
> ${PETSC_LIB} there is no change as well.
>
>
> On 21 October 2013 21:19, Barry Smith <[email protected]
> <mailto:[email protected]>> wrote:
>
>
> Please always make sure to include the mailing list in your list of
> emails. Otherwise it just goes to me, and I don't know what I am
> talking about.
>
>
> Barry
>
> On Oct 21, 2013, at 3:18 PM, Barry Smith <[email protected]
> <mailto:[email protected]>> wrote:
>
>>
>> What happens when you run
>>
>> ./pro
>>
>> ?
>>
>> Try putting ${LIBS} before the ${PETSC_LIB} in the makefile
>>
>> Barry
>>
>>
>> On Oct 21, 2013, at 3:10 PM, Anthony Vergottis
> <[email protected] <mailto:[email protected]>> wrote:
>>
>>> OK this is the makefile,
>>>
>>> include ${PETSC_DIR}/conf/variables include
>>> ${PETSC_DIR}/conf/rules
>>> LIBS=-L/home/adonis/Dropbox/ParallelSolver
> -Wl,-rpath,/home/adonis/Dropbox/ParallelSolver -lpro
>>>
>>>
>>> pro: pro.o 2D_CBS_Solver.o ${CLINKER} -o pro pro.o
>>> 2D_CBS_Solver.o ${PETSC_LIB}
> ${LIBS}
>>> ${RM} pro.o 2D_CBS_Solver.o
>>>
>>>
>>> The terminal output (in bold are my commands),
>>>
>>> adonis@LinuxBox:~/Dropbox/ParallelSolver$ g++ -shared -fPIC -o
> libpro.so 2D_CBS_Solver.cpp
>>> adonis@LinuxBox:~/Dropbox/ParallelSolver$ ls -l total 84
>>> -rw-rw-r-- 1 adonis adonis 144 Oct 21 20:56
>>> 2D_CBS_Solver.cpp -rw-rw-r-- 1 adonis adonis 144 Oct 21 20:50
>>> 2D_CBS_Solver.cpp~ -rw-rw-r-- 1 adonis adonis 429 Oct 21
>>> 19:13 2D_CBS_Solver.h drwxrwxr-x 2 adonis adonis 4096 Oct 18
>>> 14:31 include -rwxrwxr-x 1 adonis adonis 7968 Oct 21 21:02
>>> libpro.so -rw------- 1 adonis adonis 291 Oct 21 21:01
>>> Makefile -rw------- 1 adonis adonis 291 Oct 21 21:01
>>> Makefile~ -rwxrwxr-x 1 adonis adonis 42896 Oct 21 21:02 pro
>>> -rw-rw-r-- 1 adonis adonis 940 Oct 21 20:42 pro.cpp
>>> drwxrwxr-x 2 adonis adonis 4096 Oct 21 20:54 Solvers
>>> adonis@LinuxBox:~/Dropbox/ParallelSolver$ file libpro.so
>>> libpro.so: ELF 64-bit LSB shared object, x86-64, version 1
> (SYSV), dynamically linked,
> BuildID[sha1]=0x928d227f5816b3de3329f4364a688b6146df8c60, not
> stripped
>>> adonis@LinuxBox:~/Dropbox/ParallelSolver$ make pro
>>> /home/adonis/Documents/petsc-3.4.2/linux-gnu-c-debug/bin/mpicxx
>
>>>
- -o pro.o -c -Wall -Wwrite-strings -Wno-strict-aliasing
> -Wno-unknown-pragmas -g -fPIC
> -I/home/adonis/Documents/petsc-3.4.2/include
> -I/home/adonis/Documents/petsc-3.4.2/linux-gnu-c-debug/include
> -D__INSDIR__= pro.cpp
>>> /home/adonis/Documents/petsc-3.4.2/linux-gnu-c-debug/bin/mpicxx
>
>>>
- -o 2D_CBS_Solver.o -c -Wall -Wwrite-strings -Wno-strict-aliasing
> -Wno-unknown-pragmas -g -fPIC
> -I/home/adonis/Documents/petsc-3.4.2/include
> -I/home/adonis/Documents/petsc-3.4.2/linux-gnu-c-debug/include
> -D__INSDIR__= 2D_CBS_Solver.cpp
>>> /home/adonis/Documents/petsc-3.4.2/linux-gnu-c-debug/bin/mpicxx
>
>>>
- -Wall -Wwrite-strings -Wno-strict-aliasing -Wno-unknown-pragmas -g
> -o pro pro.o 2D_CBS_Solver.o
> -Wl,-rpath,/home/adonis/Documents/petsc-3.4.2/linux-gnu-c-debug/lib
>
>
- -L/home/adonis/Documents/petsc-3.4.2/linux-gnu-c-debug/lib -lpetsc
> -Wl,-rpath,/home/adonis/Documents/petsc-3.4.2/linux-gnu-c-debug/lib
>
>
- -lflapack -lfblas -lX11 -lpthread -lparmetis -lmetis -lm
> -Wl,-rpath,/usr/lib/gcc/x86_64-linux-gnu/4.6
> -L/usr/lib/gcc/x86_64-linux-gnu/4.6
> -Wl,-rpath,/usr/lib/x86_64-linux-gnu -L/usr/lib/x86_64-linux-gnu
> -Wl,-rpath,/lib/x86_64-linux-gnu -L/lib/x86_64-linux-gnu
> -lmpichf90 -lgfortran -lm -lgfortran -lm -lquadmath -lm -lmpichcxx
> -lstdc++ -ldl -lmpich -lopa -lmpl -lrt -lpthread -lgcc_s -ldl
> -L/home/adonis/Dropbox/ParallelSolver
> -Wl,-rpath,/home/adonis/Dropbox/ParallelSolver -lpro
>>> /bin/rm -f pro.o 2D_CBS_Solver.o
>>> adonis@LinuxBox:~/Dropbox/ParallelSolver$ ldd pro
>>> linux-vdso.so.1 => (0x00007fff1dffe000) libpetsc.so =>
> /home/adonis/Documents/petsc-3.4.2/linux-gnu-c-debug/lib/libpetsc.so
>
>
(0x00007f24f4da6000)
>>> libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0
> (0x00007f24f4b88000)
>>> libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6
> (0x00007f24f4888000)
>>> libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1
> (0x00007f24f4672000)
>>> libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6
>>> (0x00007f24f42b2000) libX11.so.6 =>
>>> /usr/lib/x86_64-linux-gnu/libX11.so.6
> (0x00007f24f3f7d000)
>>> libparmetis.so =>
> /home/adonis/Documents/petsc-3.4.2/linux-gnu-c-debug/lib/libparmetis.so
>
>
(0x00007f24f3d2f000)
>>> libgfortran.so.3 => /usr/lib/x86_64-linux-gnu/libgfortran.so.3
> (0x00007f24f3a17000)
>>> libmpich.so.10 =>
> /home/adonis/Documents/petsc-3.4.2/linux-gnu-c-debug/lib/libmpich.so.10
>
>
(0x00007f24f364b000)
>>> libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2
> (0x00007f24f3447000)
>>> libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6
>>> (0x00007f24f314a000) /lib64/ld-linux-x86-64.so.2
>>> (0x00007f24f6176000) libxcb.so.1 =>
>>> /usr/lib/x86_64-linux-gnu/libxcb.so.1
> (0x00007f24f2f2c000)
>>> libmetis.so =>
> /home/adonis/Documents/petsc-3.4.2/linux-gnu-c-debug/lib/libmetis.so
>
>
(0x00007f24f2cb0000)
>>> libquadmath.so.0 => /usr/lib/x86_64-linux-gnu/libquadmath.so.0
> (0x00007f24f2a7a000)
>>> libmpl.so.1 =>
> /home/adonis/Documents/petsc-3.4.2/linux-gnu-c-debug/lib/libmpl.so.1
>
>
(0x00007f24f2875000)
>>> librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1
> (0x00007f24f266c000)
>>> libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6
> (0x00007f24f2469000)
>>> libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6
> (0x00007f24f2263000)
>>>
>>>
>>> I hope this helps and is more clear. The libpro.so object for
> some reason is not being linked.
>>>
>>> Thanks
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> On 21 October 2013 20:56, Barry Smith <[email protected]
> <mailto:[email protected]>> wrote:
>>>
>>> Please cut and paste everything you've done in this process,
>>> the
> make, the running of ldd etc
>>>
>>> Barry
>>>
>>> On Oct 21, 2013, at 2:53 PM, Anthony Vergottis
> <[email protected] <mailto:[email protected]>> wrote:
>>>
>>>> Thanks for the replies. Unfortunatly this has still not
>>>> worked.
> When using the ldd command the shared library libpro.so is not
> listed there. Any other ideas why this may be not linking?
>>>>
>>>> Thanks again.
>>>>
>>>>
>>>> On 21 October 2013 20:35, Satish Balay <[email protected]
> <mailto:[email protected]>> wrote:
>>>> On Mon, 21 Oct 2013, Anthony Vergottis wrote:
>>>>
>>>>> Dear All,
>>>>>
>>>>> I was wondering how does one include a .so object when
> compiling with a
>>>>> PETSc makefile? I have made various .so object for many
> projects and they
>>>>> work properly by specifying the -L location and the
>>>>> -lLibrary
> name. But
>>>>> when I try to link the .so object via a PETSc make file
>>>>> (after
> compilation
>>>>> with no errors) the ldd command does not show the library
>>>>> as
> being linked.
>>>>>
>>>>> Is there any internal behaviour of PETSc I should be aware
>>>>> of?
> Have tried
>>>>> everything possible.
>>>>>
>>>>> I have configure PETSc with the following flags (if this
>>>>> helps).
>>>>>
>>>>> --download-mpich --with-clanguage=c++
>>>>> --download-f-blas-lapack --download-metis
>>>>> --download-parmetis --with-shared-libraries=1
>>>>> --with-dynamic-loading=1
>>>>>
>>>>> This is the sample makefile:
>>>>>
>>>>> include ${PETSC_DIR}/conf/variables include
>>>>> ${PETSC_DIR}/conf/rules
>>>>> LIBS=-L/home/adonis/Dropbox/ParallelSolver -lpro
>>>>
>>>> you need:
>>>>
>>>> LIBS=-L/home/adonis/Dropbox/ParallelSolver
> -Wl,-rpath,/home/adonis/Dropbox/ParallelSolver -lpro
>>>>
>>>> Satish
>>>>
>>>>>
>>>>> pro: pro.o 2D_CBS_Solver.o ${CLINKER} -o pro pro.o
>>>>> 2D_CBS_Solver.o ${PETSC_LIB}
> ${LIBS}
>>>>> ${RM} pro.o 2D_CBS_Solver.o
>>>>>
>>>>> After this makefile is run still ldd does not show
>>>>> linkage.
>>>>>
>>>>> Any help would be appreciated. Thanks in advance.
>>>>>
>>>>> Best regards, Anthony
>>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> -- Anthony Vergottis
>>>>
>>>> PhD Student Department of Mechanical Engineering University
>>>> College London Gower Street London WC1E 6BT
>>>>
>>>> E-mail: [email protected] <mailto:[email protected]>
>>>> Tel (UK Mobile): (+44) 079 1263 0064
> <tel:%28%2B44%29%20079%201263%200064>
>>>
>>>
>>>
>>>
>>>
>>>
>>> -- Anthony Vergottis
>>>
>>> PhD Student Department of Mechanical Engineering University
>>> College London Gower Street London WC1E 6BT
>>>
>>> E-mail: [email protected] <mailto:[email protected]>
>>> Tel (UK Mobile): (+44) 079 1263 0064
> <tel:%28%2B44%29%20079%201263%200064>
>>
>
>
>
>
>
>
> -- Anthony Vergottis
>
> PhD Student Department of Mechanical Engineering University College
> London Gower Street London WC1E 6BT
>
> E-mail: [email protected] <mailto:[email protected]> Tel
> (UK Mobile): (+44) 079 1263 0064
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iQEcBAEBAgAGBQJSZZFuAAoJEHGtO1Agqpgxi3oIALN83i7x9GR94zMqt5V8oBwx
9IA3vG7lRRHcS2EQrPIjQOiG/hPM0tvRUf8ZAE/wZjzgBi97Zm6OL+US16qDK56k
J10C1pFQvisULaJ6cfJLrkq8BxR/p/rhzggKwpI8bRyxvKgUoClSKqbZK4p0DxNQ
orSN7+Dokv1W4DFhyOBYqeRL/nmeXm7hC4Y/MF1fS2PGMVOJkE3ZdRO/3IK7FGUt
3moal1SOpdt9EranV/am9xvb0AbQ2+LjHdiQtBUGZlQwKWYSOiz3wFFdwsLoh9AP
BUvMyTHQ66YpN84DLuwcInfoVAZEwI75ywT34FsRHXkQ3pcoo+uRZjjhA/914HA=
=kYAt
-----END PGP SIGNATURE-----