static linking on Ubuntu

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

static linking on Ubuntu

hemant

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


--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: static linking on Ubuntu

Bo Zhou
Hi,

You can archive what youwant from the find_library() with NAMES parameter, for example, find_library(THELIB NAMES libthelib.a thelib-static thelib), it would try to pick the static library firstly.

Boost. You have to set Boost_USE_STATIC_LIBS before find_package(Boost), so the CMake would try to pick up the static libraries, of course, you should already own the static libraries.

Thank you very much and good luck.



On Thu, Jun 7, 2018 at 8:07 AM, <[hidden email]> wrote:

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


--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake



--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake