Hier ist mein Setup
Code: Select all
CmakeLists.txt
Code: Select all
set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so")
# Published to parent scope for install step.
set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} )
set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" )
set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" )
set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" )
list(APPEND FLUTTER_LIBRARY_HEADERS
"fl_basic_message_channel.h"
"fl_binary_codec.h"
"fl_binary_messenger.h"
"fl_dart_project.h"
"fl_engine.h"
"fl_json_message_codec.h"
"fl_json_method_codec.h"
"fl_message_codec.h"
"fl_method_call.h"
"fl_method_channel.h"
"fl_method_codec.h"
"fl_method_response.h"
"fl_plugin_registrar.h"
"fl_plugin_registry.h"
"fl_standard_message_codec.h"
"fl_standard_method_codec.h"
"fl_string_codec.h"
"fl_value.h"
"fl_view.h"
"flutter_linux.h"
)
list(PREPEND FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/")
add_library(flutter INTERFACE)
target_include_directories(flutter INTERFACE
"${EPHEMERAL_DIR}"
)
target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}")
target_link_libraries(flutter INTERFACE
PkgConfig::GTK
PkgConfig::GLIB
PkgConfig::GIO
)
Code: Select all
fn main() {
let cwd = std::env::current_dir().unwrap();
println!("CWD: {:?}", cwd.to_str());
println!("GIT_ROOT: {:?}", GIT_ROOT.to_str());
println!("EXAMPLE_DIR: {:?}", EXAMPLE_DIR.to_str());
assert!(EXAMPLE_DIR.exists());
run_cmd(
"flutter",
&["build", "linux", "--release"],
Some(&EXAMPLE_DIR),
);
let ephemeral_dir = EXAMPLE_DIR.join("linux").join("flutter").join("ephemeral");
assert!(ephemeral_dir.exists());
// now we can run cmake for the flutter_texture_linux
// e.g cmake -B ./build -G Ninja -DRustBuild=ON -DEPHEMERAL_DIR=/home/dev/Desktop/OS/flutter_gpu_texture_renderer/example/linux/flutter/ephemeral
let mut cmake_args = vec!["-B", "./build", "-G", "Ninja", "-DRustBuild=ON"];
let eph_arg = format!("-DEPHEMERAL_DIR={}", ephemeral_dir.to_str().unwrap());
cmake_args.push(eph_arg.as_str());
if cfg!(feature = "debug") {
cmake_args.push("-DCMAKE_BUILD_TYPE=Debug");
}
let root_linux_path = GIT_ROOT.join("linux");
run_cmd("cmake", &cmake_args, Some(&root_linux_path));
// find and link against the created C library
println!(
"cargo:rustc-link-search={}",
root_linux_path.join("build").to_str().unwrap()
);
println!("cargo:rustc-link-lib=flutter_gpu_texture_renderer_plugin");
let c_lib_api_header = root_linux_path.join("include/flutter_gpu_texture_renderer/api.h");
// now link against flutter and friends
println!("cargo:rustc-link-search={}", ephemeral_dir.to_str().unwrap());
// The bindgen::Builder is the main entry point
// to bindgen, and lets you build up options for
// the resulting bindings.
let bindings = bindgen::Builder::default()
// The input header we would like to generate
// bindings for.
.header(c_lib_api_header.to_str().unwrap())
// Tell cargo to invalidate the built crate whenever any of the
// included header files changed.
.parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
// Finish the builder and generate the bindings.
.generate()
// Unwrap the Result and panic on failure.
.expect("Unable to generate bindings");
// Write the bindings to the $OUT_DIR/bindings.rs file.
let out_path = bindings
.write_to_file(cwd.join("src/bindings.rs"))
.expect("Couldn't write bindings!");
}
Code: Select all
int take_five(){
return 5;
}
Code: Select all
mod bindings;
fn add_five(x: i32) -> i32 {
unsafe { x + bindings::take_five() }
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
let res = add_five(5);
assert_eq!(res, 10);
}
}
Code: Select all
error: linking with `cc` failed: exit status: 1
|
= note: LC_ALL="C" PATH="/home/dev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/home/dev/Documents/flutter_linux_3.24.0-stable/flutter/bin/:/home/dev/.cargo/bin:/home/dev/.rye/shims:/home/dev/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/home/dev/Documents/flutter_linux_3.24.0-stable/flutter/bin:/home/dev/.local/bin:/home/dev/.cargo/bin:/home/dev/.cargo/bin:/home/dev/.rye/shims:/home/dev/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/home/dev/.config/Code/User/globalStorage/github.copilot-chat/debugCommand" VSLANG="1033" "cc" "-m64" "/tmp/rustcEzoe1m/symbols.o" "/home/dev/Desktop/OS/flutter_gpu_texture_renderer/rust/target/debug/deps/flutter_texture_linux-78bf17888eae6794.02pc41qgbisrj64i8enoohv9y.rcgu.o" "/home/dev/Desktop/OS/flutter_gpu_texture_renderer/rust/target/debug/deps/flutter_texture_linux-78bf17888eae6794.1jfw3lwodakn32imyxdjdiyl2.rcgu.o" "/home/dev/Desktop/OS/flutter_gpu_texture_renderer/rust/target/debug/deps/flutter_texture_linux-78bf17888eae6794.1m6fuhpndkxqc8jv7s4g79m4t.rcgu.o" "/home/dev/Desktop/OS/flutter_gpu_texture_renderer/rust/target/debug/deps/flutter_texture_linux-78bf17888eae6794.1y6rv95aozj7g638h6szgz4eg.rcgu.o" "/home/dev/Desktop/OS/flutter_gpu_texture_renderer/rust/target/debug/deps/flutter_texture_linux-78bf17888eae6794.22v022552ka2aanjgbhmrloiv.rcgu.o" "/home/dev/Desktop/OS/flutter_gpu_texture_renderer/rust/target/debug/deps/flutter_texture_linux-78bf17888eae6794.3h1w4k19g72rcss6sw7un2jpg.rcgu.o" "/home/dev/Desktop/OS/flutter_gpu_texture_renderer/rust/target/debug/deps/flutter_texture_linux-78bf17888eae6794.3h4skbse6sn3dvk1tpjr6y26o.rcgu.o" "/home/dev/Desktop/OS/flutter_gpu_texture_renderer/rust/target/debug/deps/flutter_texture_linux-78bf17888eae6794.6bkgbgyxe64mcgyaw45pi8iop.rcgu.o" "/home/dev/Desktop/OS/flutter_gpu_texture_renderer/rust/target/debug/deps/flutter_texture_linux-78bf17888eae6794.6exauzl85az8vzc9uj6cwvz3m.rcgu.o" "/home/dev/Desktop/OS/flutter_gpu_texture_renderer/rust/target/debug/deps/flutter_texture_linux-78bf17888eae6794.7cubmyu4ks46elq0huvmduv03.rcgu.o" "/home/dev/Desktop/OS/flutter_gpu_texture_renderer/rust/target/debug/deps/flutter_texture_linux-78bf17888eae6794.7kxertbayy9lmf8qw1wkutt2e.rcgu.o" "/home/dev/Desktop/OS/flutter_gpu_texture_renderer/rust/target/debug/deps/flutter_texture_linux-78bf17888eae6794.90wv4u9qx1dvv169mlibxn4g7.rcgu.o" "/home/dev/Desktop/OS/flutter_gpu_texture_renderer/rust/target/debug/deps/flutter_texture_linux-78bf17888eae6794.96sokhx38k5qttyfzmc78fwua.rcgu.o" "/home/dev/Desktop/OS/flutter_gpu_texture_renderer/rust/target/debug/deps/flutter_texture_linux-78bf17888eae6794.ak3nwa9hoflo68aveww1i2hbx.rcgu.o" "/home/dev/Desktop/OS/flutter_gpu_texture_renderer/rust/target/debug/deps/flutter_texture_linux-78bf17888eae6794.boxiwkitl56eb0c1cp60gkkvt.rcgu.o" "/home/dev/Desktop/OS/flutter_gpu_texture_renderer/rust/target/debug/deps/flutter_texture_linux-78bf17888eae6794.c1fyz7zfhnkwlembnzkfg92jr.rcgu.o" "/home/dev/Desktop/OS/flutter_gpu_texture_renderer/rust/target/debug/deps/flutter_texture_linux-78bf17888eae6794.c4hei7kh8z8syismvy2j384qm.rcgu.o" "/home/dev/Desktop/OS/flutter_gpu_texture_renderer/rust/target/debug/deps/flutter_texture_linux-78bf17888eae6794.ce6nnbqj516qmrcs4y860y2vp.rcgu.o" "/home/dev/Desktop/OS/flutter_gpu_texture_renderer/rust/target/debug/deps/flutter_texture_linux-78bf17888eae6794.ewg37huuhjkueszxfspjeagly.rcgu.o" "/home/dev/Desktop/OS/flutter_gpu_texture_renderer/rust/target/debug/deps/flutter_texture_linux-78bf17888eae6794.covkn07bj4wrcrf8goa80z0oi.rcgu.o" "-Wl,--as-needed" "-Wl,-Bdynamic" "-lflutter_gpu_texture_renderer_plugin" "-Wl,-Bstatic" "/home/dev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libtest-aa035fdca64e6492.rlib" "/home/dev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgetopts-094c0ce9f8c98ed9.rlib" "/home/dev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunicode_width-aa0663517f777947.rlib" "/home/dev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_std-e1cd6e17fe237c71.rlib" "/home/dev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-ca74a2d9c5166d9f.rlib" "/home/dev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-e31ab23316ed5080.rlib" "/home/dev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-27dc4aa955912662.rlib" "/home/dev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libmemchr-bd0d6cccce077b99.rlib" "/home/dev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-8d001680935b5e3c.rlib" "/home/dev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-ba8ce71964f984f4.rlib" "/home/dev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-99a73526abcec14b.rlib" "/home/dev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_detect-63ac0d22cff92579.rlib" "/home/dev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-9057355c92c922d5.rlib" "/home/dev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-358be9bc1f6bab04.rlib" "/home/dev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-aca15549d5bff974.rlib" "/home/dev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-8251d2cef7072448.rlib" "/home/dev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-7d50b86011c66411.rlib" "/home/dev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-51ea098fce5006bf.rlib" "/home/dev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-5a14e0d0b712e731.rlib" "/home/dev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-8b83dbf3a7b8f999.rlib" "/home/dev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-c6fd227bdc7b39ff.rlib" "/home/dev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-959d3389fa3da8a5.rlib" "/home/dev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-abe05db089cc2c62.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/home/dev/Desktop/OS/flutter_gpu_texture_renderer/linux/build" "-L" "/home/dev/Desktop/OS/flutter_gpu_texture_renderer/example/linux/flutter/ephemeral" "-L" "/home/dev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/home/dev/Desktop/OS/flutter_gpu_texture_renderer/rust/target/debug/deps/flutter_texture_linux-78bf17888eae6794" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs"
= note: /usr/bin/ld: /home/dev/Desktop/OS/flutter_gpu_texture_renderer/rust/target/debug/deps/flutter_texture_linux-78bf17888eae6794.1y6rv95aozj7g638h6szgz4eg.rcgu.o: in function `flutter_texture_linux::add_five':
/home/dev/Desktop/OS/flutter_gpu_texture_renderer/rust/flutter_texture_linux/src/lib.rs:5:(.text._ZN21flutter_texture_linux8add_five17h271e60bd1d51d604E+0xe): undefined reference to `take_five'
collect2: error: ld returned 1 exit status