I intend to use Rust's FFI to call functions from a 3rd party C library. This C library's source and corresponding build artefacts have the following modular hierarchy:
top
└── intermediate
└── base
Each library is to be compiled independently and linked up manually to obtain the corresponding hierarchy.
top.so
└── intermediate.so
└── base.so
]There are cmake
and make
files distributed for each package, and I am able to manually compile and link the C libraries together as above.
Now, I wish to make use of the functionality of top.so
through Rust's FFI within Native Rust code. To this end, I have created three corresponding -sys
packages, and used the package.links
manifest in their Cargo.toml files, and passed the linker flags through the DEP_LIB_PROPERTY
where property
is an arbitrary key I have chosen (after reading the build script documentation).
Now, the problem is that I am able to compile the cargo workspace successfully, but the resulting libraries are broken. To explain, when compiled through Cargo, inspecting with ldd
on intermedite.so
confirms that it is correctly linked up to base.so
.
However, ldd
on top.so
reveals that, whilst it is correctly linked up to intermediate.so
, rest of the linkage dependency is broken, i.e. intermediate.so
does not get linked to base.so
resulting in a broken path.
top.so
└── intermediate.so
x
x
└── base.so
How can I architect/confgure to achieve the desired effect of obtaining a properly linked transitive dependency tree?