Skip to content

Commit 8fdd1f9

Browse files
Shared Object File Sample
1 parent b12e43f commit 8fdd1f9

File tree

9 files changed

+144
-0
lines changed

9 files changed

+144
-0
lines changed

Application_Requirements.txt

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
Hardware :-
2+
3+
Processor - Intel(R) Core(TM) i5-3320M CPU @ 2.60GHz, 2601 Mhz, 2 Core(s), 4 Logical Processor(s)
4+
Installed RAM - 16.0 GB (15.7 GB usable)
5+
System type - 64-bit operating system, x64-based processor
6+
Pen and touch - No pen or touch input is available for this display
7+
-------------------------------
8+
Operating System :-
9+
10+
Edition : Windows 10 Pro
11+
Version : 22H2
12+
Installed on ‎: 29-‎08-‎2022
13+
OS build : 19045.2846
14+
Experience : Windows Feature Experience Pack 120.2212.4190.0
15+
----------------------------
16+
Ubuntu 20.04.5 LTS with WSL2 is required.
17+
18+
WSL2 version information
19+
20+
Command :- wsl -l -v
21+
22+
Output :-
23+
NAME STATE VERSION
24+
* Ubuntu Stopped 2
25+
docker-desktop-data Stopped 2
26+
docker-desktop Stopped 2
27+
28+
Ubuntu version information
29+
Executed following command on ubuntu terminal
30+
31+
Command :- lsb_release -a
32+
33+
Output :-
34+
35+
No LSB modules are available.
36+
Distributor ID: Ubuntu
37+
Description: Ubuntu 20.04.5 LTS
38+
Release: 20.04
39+
Codename: focal
40+
41+
------------------------------------
42+
43+
----------------------------
44+
Rust Compiler Version :-
45+
46+
Command :- rustc --version
47+
48+
Output :- rustc 1.69.0 (84c898d65 2023-04-16)
49+
-----------------------
50+
Rust toolchain :-
51+
52+
Command :- rustup toolchain list
53+
54+
Output :-
55+
stable-x86_64-pc-windows-msvc (default)
56+
nightly-2023-01-05-x86_64-pc-windows-msvc
57+
nightly-x86_64-pc-windows-msvc
58+
1.50.0-x86_64-pc-windows-msvc
59+
--------------------
60+
61+
IDE Used :-
62+
63+
Visual Studio Code
64+
65+
Version: 1.77.3 (user setup)
66+
Commit: 704ed70d4fd1c6bd6342c436f1ede30d1cff4710
67+
Date: 2023-04-12T09:16:02.548Z
68+
Electron: 19.1.11
69+
Chromium: 102.0.5005.196
70+
Node.js: 16.14.2
71+
V8: 10.2.154.26-electron.0
72+
OS: Windows_NT x64 10.0.19045
73+
Sandboxed: Yes
74+
------
75+

Output.png

19 KB
Loading
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/target

SharedObjectFile/addition_client/Cargo.lock

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[package]
2+
name = "addition_client"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7+
8+
[dependencies]
9+
addition_library = { version = "0.1.0", path = "../addition_library" }
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
extern crate addition_library;
2+
use addition_library::add;
3+
4+
fn main() {
5+
println!("");
6+
println!("--------------------------------------------------");
7+
println!(" .so file , The DLL of LINUX.");
8+
println!("");
9+
println!(" Calling Function from Shared Object (.so) file.");
10+
println!("");
11+
let result = add(2,2);
12+
println!(" Addition is : {}", result);
13+
println!("--------------------------------------------------");
14+
15+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/target
2+
/Cargo.lock
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[package]
2+
name = "addition_library"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7+
8+
[lib]
9+
crate-type = ["dylib"]
10+
11+
[dependencies]
12+
13+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#![crate_type="dylib"]
2+
pub extern fn add(left: usize, right: usize) -> usize {
3+
left + right
4+
}
5+
6+
#[cfg(test)]
7+
mod tests {
8+
use super::*;
9+
10+
#[test]
11+
fn it_works() {
12+
let result = add(2, 2);
13+
assert_eq!(result, 4);
14+
}
15+
}

0 commit comments

Comments
 (0)