From 9ceaf1d6be6116fb916e60d593b2fffdfa4de66c Mon Sep 17 00:00:00 2001 From: MatthieuCoder Date: Tue, 3 Jan 2023 02:32:01 +0400 Subject: [PATCH] statically link liball.a --- exes/all/Cargo.toml | 2 +- exes/all/Makefile | 6 +++--- exes/all/build.rs | 1 - exes/all/main.go | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/exes/all/Cargo.toml b/exes/all/Cargo.toml index d6976ef..41396fc 100644 --- a/exes/all/Cargo.toml +++ b/exes/all/Cargo.toml @@ -25,7 +25,7 @@ config = "0.13.3" pretty_env_logger = "0.4.0" [lib] -crate-type = ["cdylib"] +crate-type = ["staticlib"] [build-dependencies] cbindgen = "0.24.3" \ No newline at end of file diff --git a/exes/all/Makefile b/exes/all/Makefile index 07c02d9..22a67e0 100644 --- a/exes/all/Makefile +++ b/exes/all/Makefile @@ -1,12 +1,12 @@ clean: - rm ./build/libhello.so + rm ./build/* library: cargo build --release build: library - cp ../../target/release/liball.so ./build - go build -ldflags="-r build" -o build/all + cp ../../target/release/liball.a ./build + go build -a -ldflags '-s' -o build/all all: library build diff --git a/exes/all/build.rs b/exes/all/build.rs index e779d53..c52ad11 100644 --- a/exes/all/build.rs +++ b/exes/all/build.rs @@ -15,7 +15,6 @@ fn main() { .to_string(); let config = Config { - namespace: Some(String::from("ffi")), language: Language::C, ..Default::default() }; diff --git a/exes/all/main.go b/exes/all/main.go index 0d15450..6e1f7c0 100644 --- a/exes/all/main.go +++ b/exes/all/main.go @@ -1,7 +1,7 @@ package main /* -#cgo LDFLAGS: -Lbuild -lall +#cgo LDFLAGS: -L./build -lall -lcrypto -lz -ldl -lssl -lm -static-libgcc #include "./build/all.h" */ import "C" -- 2.39.5