A sample project which creates a shared object (.so) library on linux using Rust programming language and calls it's function from another rust program.
Shared Object (.so) File:-
In simple words, a '.so' file on Linux is similar to a 'dll' on Windows.
It is a shared library that is dynamically linked to the executable/binary, meaning it's not embedded inside the executable/binary like a static library (.a). Instead, the executable/binary contains references to the .so file, which is loaded into memory when the executable/binary is run and the library's functionality is referenced. This dynamic linking allows multiple executables/binaries to share the same library in memory, promoting efficient use of system resources.
For System Requirements please refer 'Application_Requirements.txt'
How to run the project.
-
Clone the repository.
-
Navigate inside project folder 'addition_library' from terminal.
-
Build this Library project using following command -
cargo build -
Navigate inside project folder 'addition_client' from terminal.
-
Build and run this binary project using following commands -
cargo build
cargo run
Application is tested on Ubuntu 20.04.5 LTS with WSL2 on Windows 10, working well.
Tested on Ubuntu 22.04.2 LTS using github actions, working well.
Output :-
- Build Library project :
- Build and Run Binary project :
addition_library project dependency tree
addition_library v0.1.0 () -
addition_client project dependency tree
addition_client v0.1.0 () -
`-- addition_library feature "default"
`-- addition_library v0.1.0 () -
Repository Tree Structure
├── .github
└── workflows
│ └── rust.yml
├── Application_Requirements.txt
├── LICENSE
├── Output1.png
├── Output2.png
├── README.md
└── SharedObjectFile
├── addition_client
├── .gitignore
├── Cargo.lock
├── Cargo.toml
└── src
│ └── main.rs
└── addition_library
├── .gitignore
├── Cargo.toml
└── src
└── lib.rs

