Я в настоящее время разрабатываю приложение, используя C и Rust, где у меня нет проблем, когда оно используется любым из следующих способов:
- C -> Rust -> C (swift)
- C -> Rust -> examples (console Rust)
, но становится сложнее, когда я хочу получить доступ через wasm в Yew
- C -> Rust -> Yew / WASM (автомобиль go веб-запуск)
Компоновщик выдает ошибку: отсутствует "math.h"
Цитаты из Википедии: https://en.wikipedia.org/wiki/C_mathematical_functions
В Linux и BSD математические функции (как заявлено в) объединяются в математической библиотеке libm отдельно. Поэтому, если какая-либо из этих функций используется, компоновщик должен получить директиву -lm.
Хотя я добавил флаг, он ничего не меняет ...
Ниже я включил файл build.rs
из библиотеки моей привязки файла C -> Rust:
use std::env;
use std::path::Path;
fn main() {
let dir = env::var("CARGO_MANIFEST_DIR").unwrap();
cc::Build::new()
.flag("-g")
// .flag("-09")
.flag("-lm") // math.h for wasm (dosen't work or without)
.flag("-Wall")
.file(Path::new(&dir).join("src/swisseph/2.08/src/swecl.c"))
.file(Path::new(&dir).join("src/swisseph/2.08/src/swedate.c"))
.file(Path::new(&dir).join("src/swisseph/2.08/src/swehel.c"))
.file(Path::new(&dir).join("src/swisseph/2.08/src/swehouse.c"))
.file(Path::new(&dir).join("src/swisseph/2.08/src/swejpl.c"))
.file(Path::new(&dir).join("src/swisseph/2.08/src/swemmoon.c"))
.file(Path::new(&dir).join("src/swisseph/2.08/src/swemplan.c"))
.file(Path::new(&dir).join("src/swisseph/2.08/src/swepcalc.c"))
.file(Path::new(&dir).join("src/swisseph/2.08/src/sweph.c"))
.file(Path::new(&dir).join("src/swisseph/2.08/src/swephlib.c"))
.compile("swe")
}
Вот журнал ошибок моей компиляции в тисе (car go web start)
Compiling libswe-sys v0.1.4
Compiling stdweb v0.4.20
error: failed to run custom build command for libswe-sys v0.1.4
--- stdout
TARGET = Some("wasm32-unknown-unknown")
OPT_LEVEL = Some("0")
HOST = Some("x86_64-apple-darwin")
CC_wasm32-unknown-unknown = None
CC_wasm32_unknown_unknown = None
TARGET_CC = None
CC = None
CFLAGS_wasm32-unknown-unknown = None
CFLAGS_wasm32_unknown_unknown = None
TARGET_CFLAGS = None
CFLAGS = None
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("true")
running: "clang" "clang" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-Wall" "-Wextra" "-g" "-lm" "-Wall" "-o" "/Users/stephanebressani/Code/Rust/yewastrology/target/wasm32-unknown-unknown/debug/build/libswe-sys-2679bddccf8cd805/out/swedate.o" "-c" "/Users/stephanebressani/.cargo/registry/src/github.com-1ecc6299db9ec823/libswe-sys-0.1.4/src/swisseph/2.08/src/swedate.c"
running: "clang" "clang" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-Wall" "-Wextra" "-g" "-lm" "-Wall" "-o" "/Users/stephanebressani/Code/Rust/yewastrology/target/wasm32-unknown-unknown/debug/build/libswe-sys-2679bddccf8cd805/out/swecl.o" "-c" "/Users/stephanebressani/.cargo/registry/src/github.com-1ecc6299db9ec823/libswe-sys-0.1.4/src/swisseph/2.08/src/swecl.c"
running: "clang" "clang" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-Wall" "-Wextra" "-g" "-lm" "-Wall" "-o" "/Users/stephanebressani/Code/Rust/yewastrology/target/wasm32-unknown-unknown/debug/build/libswe-sys-2679bddccf8cd805/out/swehel.o" "-c" "/Users/stephanebressani/.cargo/registry/src/github.com-1ecc6299db9ec823/libswe-sys-0.1.4/src/swisseph/2.08/src/swehel.c"
cargo:warning=clang: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
cargo:warning=clang: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
cargo:warning=clang: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
cargo:warning=In file included from /Users/stephanebressani/.cargo/registry/src/github.com-1ecc6299db9ec823/libswe-sys-0.1.4/src/swisseph/2.08/src/swedate.c:86:
cargo:warning=In file included from /Users/stephanebressani/.cargo/registry/src/github.com-1ecc6299db9ec823/libswe-sys-0.1.4/src/swisseph/2.08/src/swephexp.h:83:
cargo:warning=/Users/stephanebressani/.cargo/registry/src/github.com-1ecc6299db9ec823/libswe-sys-0.1.4/src/swisseph/2.08/src/sweodef.h:167:10: fatal error: 'math.h' file not found
cargo:warning=#include <math.h>
cargo:warning= ^~~~~~~~
cargo:warning=In file included from /Users/stephanebressani/.cargo/registry/src/github.com-1ecc6299db9ec823/libswe-sys-0.1.4/src/swisseph/2.08/src/swecl.c:62:
cargo:warning=In file included from /Users/stephanebressani/.cargo/registry/src/github.com-1ecc6299db9ec823/libswe-sys-0.1.4/src/swisseph/2.08/src/swejpl.h:67:
cargo:warning=/Users/stephanebressani/.cargo/registry/src/github.com-1ecc6299db9ec823/libswe-sys-0.1.4/src/swisseph/2.08/src/sweodef.h:167:10: fatal error: 'math.h' file not found
cargo:warning=#include <math.h>
cargo:warning= ^~~~~~~~
cargo:warning=In file included from /Users/stephanebressani/.cargo/registry/src/github.com-1ecc6299db9ec823/libswe-sys-0.1.4/src/swisseph/2.08/src/swehel.c:68:
cargo:warning=In file included from /Users/stephanebressani/.cargo/registry/src/github.com-1ecc6299db9ec823/libswe-sys-0.1.4/src/swisseph/2.08/src/swephexp.h:83:
cargo:warning=/Users/stephanebressani/.cargo/registry/src/github.com-1ecc6299db9ec823/libswe-sys-0.1.4/src/swisseph/2.08/src/sweodef.h:167:10: fatal error: 'math.h' file not found
cargo:warning=#include <math.h>
cargo:warning= ^~~~~~~~`
cargo:warning=1 error generated.
exit code: 1
running: "clang" "clang" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-Wall" "-Wextra" "-g" "-lm" "-Wall" "-o" "/Users/stephanebressani/Code/Rust/yewastrology/target/wasm32-unknown-unknown/debug/build/libswe-sys-2679bddccf8cd805/out/swehouse.o" "-c" "/Users/stephanebressani/.cargo/registry/src/github.com-1ecc6299db9ec823/libswe-sys-0.1.4/src/swisseph/2.08/src/swehouse.c"
cargo:warning=1 error generated.
exit code: 1
cargo:warning=clang: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
cargo:warning=1 error generated.
exit code: 1
cargo:warning=In file included from /Users/stephanebressani/.cargo/registry/src/github.com-1ecc6299db9ec823/libswe-sys-0.1.4/src/swisseph/2.08/src/swehouse.c:63:
cargo:warning=In file included from /Users/stephanebressani/.cargo/registry/src/github.com-1ecc6299db9ec823/libswe-sys-0.1.4/src/swisseph/2.08/src/swephexp.h:83:
cargo:warning=/Users/stephanebressani/.cargo/registry/src/github.com-1ecc6299db9ec823/libswe-sys-0.1.4/src/swisseph/2.08/src/sweodef.h:167:10: fatal error: 'math.h' file not found
cargo:warning=#include <math.h>
cargo:warning= ^~~~~~~~
cargo:warning=1 error generated.
exit code: 1
--- stderr
error occurred: Command "clang" "clang" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-Wall" "-Wextra" "-g" "-lm" "-Wall" "-o" "/Users/stephanebressani/Code/Rust/yewastrology/target/wasm32-unknown-unknown/debug/build/libswe-sys-2679bddccf8cd805/out/swecl.o" "-c" "/Users/stephanebressani/.cargo/registry/src/github.com-1ecc6299db9ec823/libswe-sys-0.1.4/src/swisseph/2.08/src/swecl.c" with args "clang" did not execute successfully (status code exit code: 1).
warning: build failed, waiting for other jobs to finish...
Что бы вы предложили?
- Найдите файл math.c / math.h и включите его в мою библиотеку c -> rust
- Другие предложения ???
Редактировать:
Я пробовал два способа, которые не работали:
- Добавить вручную math.h из / Библиотека / Разработчик / CommandLineTools / SDKs / MacOSX10.15.sdk / usr / include / math.h на моей ма c
- Добавьте .include ("/ usr / include") в build.rs моей библиотека
Два способа компилирования моего libswe-sys (0.1.5 и 0.1.6)
И вот журнал тисовых сообщений для wasm:
- с 0.1.5 (добавьте вручную math.h)
error: failed to run custom build command for `libswe-sys v0.1.5`
--- stdout
TARGET = Some("wasm32-unknown-unknown")
OPT_LEVEL = Some("0")
HOST = Some("x86_64-apple-darwin")
CC_wasm32-unknown-unknown = None
CC_wasm32_unknown_unknown = None
TARGET_CC = None
CC = None
CFLAGS_wasm32-unknown-unknown = None
CFLAGS_wasm32_unknown_unknown = None
TARGET_CFLAGS = None
CFLAGS = None
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("true")
running: "clang" "clang" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-Wall" "-Wextra" "-g" "-Wall" "-o" "/Users/stephanebressani/Code/Rust/yewastrology/target/wasm32-unknown-unknown/debug/build/libswe-sys-b52a4354b3363d0b/out/swedate.o" "-c" "/Users/stephanebressani/.cargo/registry/src/github.com-1ecc6299db9ec823/libswe-sys-0.1.5/src/swisseph/2.08/src/swedate.c"
running: "clang" "clang" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-Wall" "-Wextra" "-g" "-Wall" "-o" "/Users/stephanebressani/Code/Rust/yewastrology/target/wasm32-unknown-unknown/debug/build/libswe-sys-b52a4354b3363d0b/out/swecl.o" "-c" "/Users/stephanebressani/.cargo/registry/src/github.com-1ecc6299db9ec823/libswe-sys-0.1.5/src/swisseph/2.08/src/swecl.c"
cargo:warning=In file included from /Users/stephanebressani/.cargo/registry/src/github.com-1ecc6299db9ec823/libswe-sys-0.1.5/src/swisseph/2.08/src/swedate.c:86:
cargo:warning=In file included from /Users/stephanebressani/.cargo/registry/src/github.com-1ecc6299db9ec823/libswe-sys-0.1.5/src/swisseph/2.08/src/swephexp.h:83:
cargo:warning=/Users/stephanebressani/.cargo/registry/src/github.com-1ecc6299db9ec823/libswe-sys-0.1.5/src/swisseph/2.08/src/sweodef.h:167:10: error: 'math.h' file not found with <angled> include; use "quotes" instead
cargo:warning=#include <math.h>
cargo:warning= ^~~~~~~~
cargo:warning= "math.h"
cargo:warning=In file included from /Users/stephanebressani/.cargo/registry/src/github.com-1ecc6299db9ec823/libswe-sys-0.1.5/src/swisseph/2.08/src/swecl.c:62:
cargo:warning=In file included from /Users/stephanebressani/.cargo/registry/src/github.com-1ecc6299db9ec823/libswe-sys-0.1.5/src/swisseph/2.08/src/swejpl.h:67:
cargo:warning=/Users/stephanebressani/.cargo/registry/src/github.com-1ecc6299db9ec823/libswe-sys-0.1.5/src/swisseph/2.08/src/sweodef.h:167:10: error: 'math.h' file not found with <angled> include; use "quotes" instead
cargo:warning=#include <math.h>
cargo:warning= ^~~~~~~~
cargo:warning= "math.h"
cargo:warning=In file included from /Users/stephanebressani/.cargo/registry/src/github.com-1ecc6299db9ec823/libswe-sys-0.1.5/src/swisseph/2.08/src/swedate.c:86:
cargo:warning=In file included from /Users/stephanebressani/.cargo/registry/src/github.com-1ecc6299db9ec823/libswe-sys-0.1.5/src/swisseph/2.08/src/swecl.c:62:
cargo:warning=In file included from /Users/stephanebressani/.cargo/registry/src/github.com-1ecc6299db9ec823/libswe-sys-0.1.5/src/swisseph/2.08/src/swejpl.h:67:
cargo:warning=In file included from /Users/stephanebressani/.cargo/registry/src/github.com-1ecc6299db9ec823/libswe-sys-0.1.5/src/swisseph/2.08/src/swephexp.h:83:
cargo:warning=In file included from /Users/stephanebressani/.cargo/registry/src/github.com-1ecc6299db9ec823/libswe-sys-0.1.5/src/swisseph/2.08/src/sweodef.h:167:
cargo:warning=In file included from /Users/stephanebressani/.cargo/registry/src/github.com-1ecc6299db9ec823/libswe-sys-0.1.5/src/swisseph/2.08/src/sweodef.h:167:
cargo:warning=/Users/stephanebressani/.cargo/registry/src/github.com-1ecc6299db9ec823/libswe-sys-0.1.5/src/swisseph/2.08/src/math.h:295:10: fatal error: '__config' file not found
cargo:warning=#include <__config>
cargo:warning= ^~~~~~~~~~
cargo:warning=/Users/stephanebressani/.cargo/registry/src/github.com-1ecc6299db9ec823/libswe-sys-0.1.5/src/swisseph/2.08/src/math.h:295:10: fatal error: '__config' file not found
cargo:warning=#include <__config>
cargo:warning= ^~~~~~~~~~
cargo:warning=2 errors generated.
exit code: 1
running: "clang" "clang" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-Wall" "-Wextra" "-g" "-Wall" "-o" "/Users/stephanebressani/Code/Rust/yewastrology/target/wasm32-unknown-unknown/debug/build/libswe-sys-b52a4354b3363d0b/out/swehel.o" "-c" "/Users/stephanebressani/.cargo/registry/src/github.com-1ecc6299db9ec823/libswe-sys-0.1.5/src/swisseph/2.08/src/swehel.c"
cargo:warning=2 errors generated.
exit code: 1
cargo:warning=In file included from /Users/stephanebressani/.cargo/registry/src/github.com-1ecc6299db9ec823/libswe-sys-0.1.5/src/swisseph/2.08/src/swehel.c:68:
cargo:warning=In file included from /Users/stephanebressani/.cargo/registry/src/github.com-1ecc6299db9ec823/libswe-sys-0.1.5/src/swisseph/2.08/src/swephexp.h:83:
cargo:warning=/Users/stephanebressani/.cargo/registry/src/github.com-1ecc6299db9ec823/libswe-sys-0.1.5/src/swisseph/2.08/src/sweodef.h:167:10: error: 'math.h' file not found with <angled> include; use "quotes" instead
cargo:warning=#include <math.h>
cargo:warning= ^~~~~~~~
cargo:warning= "math.h"
cargo:warning=In file included from /Users/stephanebressani/.cargo/registry/src/github.com-1ecc6299db9ec823/libswe-sys-0.1.5/src/swisseph/2.08/src/swehel.c:68:
cargo:warning=In file included from /Users/stephanebressani/.cargo/registry/src/github.com-1ecc6299db9ec823/libswe-sys-0.1.5/src/swisseph/2.08/src/swephexp.h:83:
cargo:warning=In file included from /Users/stephanebressani/.cargo/registry/src/github.com-1ecc6299db9ec823/libswe-sys-0.1.5/src/swisseph/2.08/src/sweodef.h:167:
cargo:warning=/Users/stephanebressani/.cargo/registry/src/github.com-1ecc6299db9ec823/libswe-sys-0.1.5/src/swisseph/2.08/src/math.h:295:10: fatal error: '__config' file not found
cargo:warning=#include <__config>
cargo:warning= ^~~~~~~~~~
cargo:warning=2 errors generated.
exit code: 1
--- stderr
error occurred: Command "clang" "clang" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-Wall" "-Wextra" "-g" "-Wall" "-o" "/Users/stephanebressani/Code/Rust/yewastrology/target/wasm32-unknown-unknown/debug/build/libswe-sys-b52a4354b3363d0b/out/swecl.o" "-c" "/Users/stephanebressani/.cargo/registry/src/github.com-1ecc6299db9ec823/libswe-sys-0.1.5/src/swisseph/2.08/src/swecl.c" with args "clang" did not execute successfully (status code exit code: 1).
warning: build failed, waiting for other jobs to finish...
error: build failed
error: build failed
error: failed to run custom build command for `libswe-sys v0.1.6`
--- stdout
TARGET = Some("wasm32-unknown-unknown")
OPT_LEVEL = Some("0")
HOST = Some("x86_64-apple-darwin")
CC_wasm32-unknown-unknown = None
CC_wasm32_unknown_unknown = None
TARGET_CC = None
CC = None
CFLAGS_wasm32-unknown-unknown = None
CFLAGS_wasm32_unknown_unknown = None
TARGET_CFLAGS = None
CFLAGS = None
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("true")
running: "clang" "clang" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-I" "/usr/include" "-Wall" "-Wextra" "-g" "-Wall" "-o" "/Users/stephanebressani/Code/Rust/yewastrology/target/wasm32-unknown-unknown/debug/build/libswe-sys-08f220b2455dd53e/out/swecl.o" "-c" "/Users/stephanebressani/.cargo/registry/src/github.com-1ecc6299db9ec823/libswe-sys-0.1.6/src/swisseph/2.08/src/swecl.c"
running: "clang" "clang" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-I" "/usr/include" "-Wall" "-Wextra" "-g" "-Wall" "-o" "/Users/stephanebressani/Code/Rust/yewastrology/target/wasm32-unknown-unknown/debug/build/libswe-sys-08f220b2455dd53e/out/swedate.o" "-c" "/Users/stephanebressani/.cargo/registry/src/github.com-1ecc6299db9ec823/libswe-sys-0.1.6/src/swisseph/2.08/src/swedate.c"
cargo:warning=In file included from /Users/stephanebressani/.cargo/registry/src/github.com-1ecc6299db9ec823/libswe-sys-0.1.6/src/swisseph/2.08/src/swedate.c:86:
cargo:warning=In file included from /Users/stephanebressani/.cargo/registry/src/github.com-1ecc6299db9ec823/libswe-sys-0.1.6/src/swisseph/2.08/src/swephexp.h:83:
cargo:warning=/Users/stephanebressani/.cargo/registry/src/github.com-1ecc6299db9ec823/libswe-sys-0.1.6/src/swisseph/2.08/src/sweodef.h:167:10: fatal error: 'math.h' file not found
cargo:warning=#include <math.h>
cargo:warning= ^~~~~~~~
cargo:warning=In file included from /Users/stephanebressani/.cargo/registry/src/github.com-1ecc6299db9ec823/libswe-sys-0.1.6/src/swisseph/2.08/src/swecl.c:62:
cargo:warning=In file included from /Users/stephanebressani/.cargo/registry/src/github.com-1ecc6299db9ec823/libswe-sys-0.1.6/src/swisseph/2.08/src/swejpl.h:67:
cargo:warning=/Users/stephanebressani/.cargo/registry/src/github.com-1ecc6299db9ec823/libswe-sys-0.1.6/src/swisseph/2.08/src/sweodef.h:167:10: fatal error: 'math.h' file not found
cargo:warning=#include <math.h>
cargo:warning= ^~~~~~~~
cargo:warning=1 error generated.
exit code: 1
running: "clang" "clang" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-I" "/usr/include" "-Wall" "-Wextra" "-g" "-Wall" "-o" "/Users/stephanebressani/Code/Rust/yewastrology/target/wasm32-unknown-unknown/debug/build/libswe-sys-08f220b2455dd53e/out/swehel.o" "-c" "/Users/stephanebressani/.cargo/registry/src/github.com-1ecc6299db9ec823/libswe-sys-0.1.6/src/swisseph/2.08/src/swehel.c"
cargo:warning=1 error generated.
cargo:warning=In file included from /Users/stephanebressani/.cargo/registry/src/github.com-1ecc6299db9ec823/libswe-sys-0.1.6/src/swisseph/2.08/src/swehel.c:68:
cargo:warning=In file included from /Users/stephanebressani/.cargo/registry/src/github.com-1ecc6299db9ec823/libswe-sys-0.1.6/src/swisseph/2.08/src/swephexp.h:83:
cargo:warning=/Users/stephanebressani/.cargo/registry/src/github.com-1ecc6299db9ec823/libswe-sys-0.1.6/src/swisseph/2.08/src/sweodef.h:167:10: fatal error: 'math.h' file not found
cargo:warning=#include <math.h>
cargo:warning= ^~~~~~~~
exit code: 1
cargo:warning=1 error generated.
exit code: 1
--- stderr
error occurred: Command "clang" "clang" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-I" "/usr/include" "-Wall" "-Wextra" "-g" "-Wall" "-o" "/Users/stephanebressani/Code/Rust/yewastrology/target/wasm32-unknown-unknown/debug/build/libswe-sys-08f220b2455dd53e/out/swecl.o" "-c" "/Users/stephanebressani/.cargo/registry/src/github.com-1ecc6299db9ec823/libswe-sys-0.1.6/src/swisseph/2.08/src/swecl.c" with args "clang" did not execute successfully (status code exit code: 1).
warning: build failed, waiting for other jobs to finish...
error: build failed
error: build failed
Это моя установка для тиса (очень маленькая, она как мир приветствия) проект):
Автомобиль go .томл
[package]
name = "yewastrology"
version = "0.1.0"
authors = ["stephaneworkspace <s.bressani@bluewin.ch>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
yew = "0.11.0"
astrology = "0.1.24"
src / main.rs
use astrology::{WorkingStorageYew, YewAction, YewAstro};
use yew::{
html, Callback, ClickEvent, Component, ComponentLink, Html, ShouldRender,
};
struct App {
clicked: bool,
onclick: Callback<ClickEvent>,
}
enum Msg {
Click,
}
impl Component for App {
type Message = Msg;
type Properties = ();
fn create(_: Self::Properties, link: ComponentLink<Self>) -> Self {
App {
clicked: false,
onclick: link.callback(|_| Msg::Click),
}
}
fn update(&mut self, msg: Self::Message) -> ShouldRender {
match msg {
Msg::Click => {
self.clicked = true;
true // Indicate that the Component should re-render
},
}
}
fn view(&self) -> Html {
let button_text: String = if self.clicked {
// Ephem file and better path todo later !
let ws = WorkingStorageYew::new(
"/Users/stephanebressani/Code/Rust/yewastrology/data.json",
"",
550,
);
let ok = ws.yew_draw_chart(YewAction::Chart);
let result = ok.0;
result
} else {
"Click me!".to_string()
};
if !self.clicked {
html! {
<button onclick=&self.onclick>{ button_text }</button>
}
} else {
html! {
<h1>{ button_text }</h1>
}
}
}
}
fn main() {
yew::start_app::<App>();
}
и данные. json
{
"year": 1999,
"month": 12,
"day": 31,
"hourf64": 23.59,
"hour": 23,
"min": 59,
"sec": 0.0,
"lat": 46.0222,
"lng": 6.14569
}
Для 0.1.5 (добавьте вручную math.h) источник не совместим, у вас есть совместимый?
Я только что попробовал первый в моем поиске на моей книге ma c (7 в результате поиска по другому пути)
Редактировать 2:
Я нашел это:
https://github.com/rust-lang/libc/issues/858
По определению, wasm32-unknown-unknown не имеет lib c. Если вы хотите использовать emscripten или wasi, вы можете использовать wasm32-unknown-emscripten или wasm32-wasi, оба из которых уже поддерживаются в ящике lib c.
Я пробовал с emscripter (проблема компилировать, потому что библиотека lib, ansi_term в моей машине go несовместима) и была той же проблемой, что и wasm32-unknown-unknown, проблема с math.h