LINUX.ORG.RU

История изменений

Исправление kvpfs, (текущая версия) :

Не используй ldd, он сканит зависимости рекурсивно. Те флаги что я тебе сказал - делают ровно то, что просил:

cmake_minimum_required(VERSION 3.6)
project(example)

set(CMAKE_CXX_FLAGS "-Wl,--unresolved-symbols=ignore-all -rdynamic")

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

add_library(main SHARED main.cpp)
add_library(wrapper SHARED wrapper.cpp)

target_link_libraries(wrapper PRIVATE main)

add_executable(output output.cpp)
target_link_libraries(output PRIVATE wrapper)

Вот ссылки на либы, которые сохраняются в elf’ах, без всякого рекурсивного прохода (как это делает ldd):

$ readelf -d output 
Dynamic section at offset 0x2da8 contains 31 entries:
  Tag        Type                         Name/Value
 0x0000000000000001 (NEEDED)             Shared library: [libwrapper.so]
 0x0000000000000001 (NEEDED)             Shared library: [libstdc++.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libm.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libgcc_s.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]

$ readelf -d libwrapper.so 
Dynamic section at offset 0x2e00 contains 26 entries:
  Tag        Type                         Name/Value
 0x0000000000000001 (NEEDED)             Shared library: [libmain.so]
 0x0000000000000001 (NEEDED)             Shared library: [libstdc++.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libm.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libgcc_s.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]

Исходная версия kvpfs, :

Не используй ldd, он сканит зависимости рекурсивно. Те флаги что я тебе сказал - делают ровно то, что просил:

cmake_minimum_required(VERSION 3.6)
project(example)

set(CMAKE_CXX_FLAGS "-Wl,--unresolved-symbols=ignore-all -rdynamic")

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

add_library(main SHARED main.cpp)
add_library(wrapper SHARED wrapper.cpp)

target_link_libraries(wrapper PRIVATE main)

add_executable(output output.cpp)
target_link_libraries(output PRIVATE wrapper)

Вот ссылки на либы, которые сохраняются в elf’ах, без всякого рекурсивного прохода (как это делает ldd):

Dynamic section at offset 0x2da8 contains 31 entries:
  Tag        Type                         Name/Value
 0x0000000000000001 (NEEDED)             Shared library: [libwrapper.so]
 0x0000000000000001 (NEEDED)             Shared library: [libstdc++.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libm.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libgcc_s.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]

$ readelf -d libwrapper.so 
Dynamic section at offset 0x2e00 contains 26 entries:
  Tag        Type                         Name/Value
 0x0000000000000001 (NEEDED)             Shared library: [libmain.so]
 0x0000000000000001 (NEEDED)             Shared library: [libstdc++.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libm.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libgcc_s.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]