[petsc-users] Including user made shared library in makefile.
Barry Smith
bsmith at mcs.anl.gov
Mon Oct 21 15:19:48 CDT 2013
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 <bsmith at mcs.anl.gov> 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 <a.vergottis at ucl.ac.uk> 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 at LinuxBox:~/Dropbox/ParallelSolver$ g++ -shared -fPIC -o libpro.so 2D_CBS_Solver.cpp
>> adonis at 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 at 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 at 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 at 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 <bsmith at mcs.anl.gov> 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 <a.vergottis at ucl.ac.uk> 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 <balay at mcs.anl.gov> 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: a.vergottis at ucl.ac.uk
>>> Tel (UK Mobile): (+44) 079 1263 0064
>>
>>
>>
>>
>>
>>
>> --
>> Anthony Vergottis
>>
>> PhD Student
>> Department of Mechanical Engineering
>> University College London
>> Gower Street
>> London
>> WC1E 6BT
>>
>> E-mail: a.vergottis at ucl.ac.uk
>> Tel (UK Mobile): (+44) 079 1263 0064
>
More information about the petsc-users
mailing list