https://github.com/libraries/rust_extern
https://github.com/libraries/rust_extern
Last synced: 10 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/libraries/rust_extern
- Owner: libraries
- Created: 2019-11-06T10:57:26.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-11-14T06:23:39.000Z (about 6 years ago)
- Last Synced: 2025-01-22T00:38:26.353Z (12 months ago)
- Language: LLVM
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Rust 使用 C 函数/结构体
```
$ cd src
$ clang draw.c -c -o libdraw.so
$ clang main.c libdraw.so -o main
$ ./main
```
```
$ cd ..
$ cargo clean
$ RUSTFLAGS="-L /src/rust_extern/src" cargo run
# rustc main.rs -L . -o main
```
# Rust 使用 minits 函数/结构体
```
$ cd /src/minits
$ ts-node src/index.ts build /src/rust_extern/src/draw.ts -o /src/rust_extern/src/draw.ll
$ cd /src/rust_extern/src
$ clang -c -shared -undefined dynamic_lookup draw.ll -o libdraw.so
$ cd ..
$ cargo clean
$ RUSTFLAGS="-L /src/rust_extern/src" cargo run
```