[CMake] static linking on Ubuntu

hemant at mnkcg.com hemant at mnkcg.com
Wed Jun 6 19:07:58 EDT 2018


Hi folks,

 

The P4 programming language has a compiler called p4c with a variant in
p4c-xp.  This compiler executable is built on Ubuntu 16.04.   p4c-xp uses
cmake.  As one can see, there are several shared libs used by p4c-xp.  Each
shared lib may call other shared libs.  I could use some help with cmake.  I
have used some cmake help for creating a single static lib but the steps did
not help on Ubuntu.  Further, I would like cmake to automatically detect
other shared lib dependencies and build a statically linked executable.

 

$ ldd p4c-xp

     linux-vdso.so.1 =>  (0x00007ffd2cd06000)

     libboost_iostreams.so.1.58.0 =>
/usr/lib/x86_64-linux-gnu/libboost_iostreams.so.1.58.0 (0x00007f0efa732000)

     libgmp.so.10 => /usr/local/lib/libgmp.so.10 (0x00007f0efa4bb000)

     libgmpxx.so.4 => /usr/lib/x86_64-linux-gnu/libgmpxx.so.4
(0x00007f0efa2b5000)

     libgc.so.1 => /usr/local/lib/libgc.so.1 (0x00007f0efa048000)

     librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f0ef9e40000)

     libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6
(0x00007f0ef9abe000)

     libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f0ef97b5000)

     libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1
(0x00007f0ef959f000)

     libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f0ef91d5000)

     libbz2.so.1.0 => /lib/x86_64-linux-gnu/libbz2.so.1.0
(0x00007f0ef8fc5000)

     libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f0ef8dab000)

     libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0
(0x00007f0ef8b8e000)

     libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f0ef898a000)

     /lib64/ld-linux-x86-64.so.2 (0x00007f0efa94b000)

 

Regards,

 

Hemant

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20180606/5f75b02b/attachment.html>


More information about the CMake mailing list