A demo to show how to build and run a Rust based program depending on a Rust library which needs a C shared library.
make oldadd
: this create a C shared library calledlibadd.so
in ./demomake build
: build the Rust project by adding linker arguments by-C
. Should create the executable successfully.make copy
: copy executable and library file intotest_dir
to create a test environmentmake dir_test
: run the program withLD_LIBRARY_PATH=./lib
. Should be successful. output:c_add_foo: 1
make newadd
: create a new shared library using newadd.cxxmake copy_new
: copy the library to the target positionmake dir_test
: output:c_add_foo: 2
. The program loads the correct shared library.