I'm currently developing an application using C and Rust, where I don't have any problems when it's used in either of the following ways:
- C -> Rust -> C (swift)
- C -> Rust -> examples (console Rust)
but it's getting complicated when I want to access via wasm in Yew
- C -> Rust -> Yew/WASM (cargo web start)
The linker throws an error: "math.h" is missing
Wikipedia quotes: https://en.wikipedia.org/wiki/C_mathematical_functions
Under Linux and BSD, the mathematical functions (as declared in ) are bundled separately in the mathematical library libm. Therefore, if any of those functions are used, the linker must be given the directive -lm.
Although I've added the flag, it doesn't change anything...
Below I have included the build.rs
file from my library file binding 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")
}
Here is the error log of my compilation in yew (cargo 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...
What would you suggest ?
- Find a math.c/math.h file and include it in my library c -> rust
- Other suggestions ???
Edit:
I tried two ways which didn’t work:
- Add manually a math.h from /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/math.h on my mac
- Add .include("/usr/include") in build.rs of my library
The two ways compile my libswe-sys (0.1.5 and 0.1.6)
And this is the log of yew for wasm :
- with 0.1.5 (add manually 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
- 0.1.6 (add .include("/usr/include") in build.rs of my library
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
This is my yew setup (very small, it’s like a hello world project) :
Cargo.toml
[package]
name = "yewastrology"
version = "0.1.0"
authors = ["stephaneworkspace <[email protected]>"]
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>();
}
and data.json
{
"year": 1999,
"month": 12,
"day": 31,
"hourf64": 23.59,
"hour": 23,
"min": 59,
"sec": 0.0,
"lat": 46.0222,
"lng": 6.14569
}
For the 0.1.5 (add manually a math.h) the source is not compatible, have you one compatible ?
I just tried the first in my search on my mac book (7 in search result in different path)
Edit 2 :
I found this :
https://github.com/rust-lang/libc/issues/858
By definition, wasm32-unknown-unknown has no libc. If you want to use emscripten or wasi you can use wasm32-unknown-emscripten or wasm32-wasi, both of which are already supported in the libc crate.
I tried with emscripter (problem compile because a lib, ansi_term lib in my cargo is incomptible) and wasi the same problem as wasm32-unknown-unknown, problem with math.h