How can I programatically determine where my C++ runtime libraries are?

前端 未结 2 1396
[愿得一人]
[愿得一人] 2021-01-06 19:17

I\'m building C++11 with GCC 4.8 on CentOS 6 using \"hax\", then deploying on arbitrary CentOS 6 targets (on which anything C++-related out of the box will have been built a

相关标签:
2条回答
  • 2021-01-06 19:59

    In my Makefile:

    GCC_INSTALL_DIR := $(shell $(CXX) -print-search-dirs | grep install | cut -d' ' -f2)
    

    …then my main build target will perform:

    ln -sf $(GCC_INSTALL_DIR)/libstdc++.so $(BIN_DIR)/deps/
    

    …and I can dump everything in $(BIN_DIR)/deps into the right place on install.

    I think.

    0 讨论(0)
  • 2021-01-06 20:03

    If I understand correctly, you have already built your binaries and just want to get a list of runtime libraries to package them along with binaries? You can try using ldd for this, like:

    > ldd /usr/bin/ls
        linux-vdso.so.1 (0x00007ffe76dd2000)
        libselinux.so.1 => /lib64/libselinux.so.1 (0x00007fc97131f000)
        libcap.so.2 => /lib64/libcap.so.2 (0x00007fc97111a000)
        libacl.so.1 => /lib64/libacl.so.1 (0x00007fc970f10000)
        libc.so.6 => /lib64/libc.so.6 (0x00007fc970b68000)
        libpcre.so.1 => /usr/lib64/libpcre.so.1 (0x00007fc970902000)
        libdl.so.2 => /lib64/libdl.so.2 (0x00007fc9706fd000)
        /lib64/ld-linux-x86-64.so.2 (0x000055c4ba4ed000)
        libattr.so.1 => /lib64/libattr.so.1 (0x00007fc9704f8000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fc9702db000)
    

    This way you will see all libraries needed except, of course, the ones that are used via dlopen().

    0 讨论(0)
提交回复
热议问题