I am trying to create a rust workspace, having multiple binaries to build from same project
Actually I prepared structure as follow
Where external Cargo.tml contains only
[workspace]
members = ["itris-console", "autolearn" ]
And itris-console/Cargo.toml contains
[package]
name = "itris"
version = "0.1.0"
edition = "2021"
[dependencies]
rand = "0.8.5"
arr_macro = "0.1.3"
[[bin]]
name = "itris"
path = "src/main.rs"
test = false
bench = false
And autolearn/Cargo.toml is
[package]
name = "autolearn"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
I am trying to build it all from project root (the itris2 directory)
I got this problem
cargo build
error: failed to load manifest for workspace member `C:\Progetti\rust\itris2\itris-console`
Caused by:
failed to read `C:\Progetti\rust\itris2\itris-console\Cargo.toml`
Caused by:
Impossibile trovare il percorso specificato. (os error 3)
I consulted what follows but I cannot make it works
https://doc.rust-lang.org/cargo/reference/cargo-targets.html#binaries
https://stackoverflow.com/a/57630418/1055279
The itris-console and autolearn directories should not be in a src directory.
Currently path to your itris-console directory is C:\Progetti\rust\itris2\src\itris-console while it should be C:\Progetti\rust\itris2\itris-console. Remove the unnecessary src directory from the path and you are almost good to go.
Since you are on windows you also need to use escaped forward-slashes while defining the path to the bin in itris-console\Cargo.toml ("src/main.rs" -> "src\\main.rs").
Related
In Rust, I created one package and now I want to change only output app name without changing package name.
Below is the content of Cargo.toml file:
[package]
authors = ["Rust exam"]
edition = "2021"
name = "rust-exam"
description = "Rebuilt for Scale"
version = "1.10.0"
license = "Apache-2.0"
[dependencies]
base64 = "0.12.3"
clap = "2.33.1"
serde = "1.0.132"
serde_json = "1.0.73"
serde_yaml = "0.8.23"
tempfile = "3.2.0"
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
When I input cargo build, it makes rust-exam and librust-exam.
I want to only change rust-exam, not change package name. How can I do that?
You can configure the app name like so:
[[bin]]
name = "rust-output"
path = "src/main.rs"
I am new to RUST, and I am trying to use this concrete library: https://github.com/zama-ai/concrete/tree/master/concrete. I am trying to create a simple "Hello World" in RUST to see if concrete imports correctly. I followed the instructions in the aforementioned link.
Specifically, I:
Cloned the GitHub repo.
Cd into concrete folder (/concrete/concrete)
ran "cargo new play_with_fhe"
Updated the "Cargo.toml" file with the new member "play_with_me"
[workspace]
members = [
"concrete",
"concrete-npe",
"concrete-core",
"concrete-csprng",
"concrete-commons",
"concrete-tasks",
"concrete-boolean",
"play_with_fhe",
]
[profile.bench]
opt-level = 3
debug = true
lto="fat"
[patch.crates-io]
concrete = {path="concrete"}
concrete-npe = {path="concrete-npe"}
concrete-core = {path="concrete-core"}
concrete-csprng = {path="concrete-csprng"}
concrete-commons = {path="concrete-commons"}
concrete-boolean = {path= "concrete-boolean"}
play_with_fhe = {path= "play_with_fhe"}
Cd into "/concrete/concrete/play_with_fhe" and updated the "Cargo.toml" file with
[package]
name = "play_with_fhe"
version = "0.1.11"
authors = ["FHE Curious"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
concrete = "^0.1.11"
Cd into /concrete/concrete/play_with_fhe_/src and created a main.rs file running a simple code:
use concrete::*;
fn main() {
println!("Hello, world!");
}
When I try compiling it with rustc main.rs, I get told that:
error[E0432]: unresolved import `concrete`
--> main.rs:2:5
|
2 | use concrete::*;
| ^^^^^^^^ maybe a missing crate `concrete`?
error: aborting due to previous error
For more information about this error, try `rustc --explain E0432`.
How can I address this issue? Any advice would be appreciated.
Since you're trying to create your own hello world project, you don't need to clone the repository. You just need to create a project, include concrete as a dependency, and then import it. Those instructions are on the concrete page (as Stargateur notes):
% cargo new play_with_fhe
% cd play_with_fhe
Add concrete to your dependencies in Cargo.toml:
[package]
name = "play_with_fhe"
version = "0.1.0"
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
concrete = "^0.1" # <--- This is the only change you make. The rest is template.
Then add use cargo::* to the top of your main.rs, and build it:
% cargo build
This will install everything. For more on Cargo, see Dependencies in Rust By Example.
Note that this package likely won't build correctly unless you're on an x86 architecture. For example, it won't run on an Apple M1 without Rosetta2.
I am trying to include a second toml file from Cargo.toml file.
I don't known how to do that and i don't known do this is possible.
I am trying this:
Cargo.toml:
[package]
name = "toml"
authors = "TANDEX"
version = "0.0.0"
include = ["libs.toml"]
libs.toml:
[dependencies]
termion = "0.9.8"
and this:
Cargo.toml:
include = ["libs.toml"]
[package]
name = "toml"
authors = ["TANDEX"]
version = "0.0.0"
libs.toml:
[dependencies]
termion = "0.9.8"
Both of them don't works.
For information I want to automatically generate one file by script and the `Cargo.toml` leave normal.
I'm building an app with rust. Using --cargo run --release successfully compiles the app and runs it, bringing up the GUI window for the app. However, when I manually open target/release/MyApp.exe, nothing happens. Checked when myapp.exe was last modifies shows that running --cargo run --release is updating the app.
I'm on windows 10 so I added "x86_64-pc-windows-msvc" as the build target.
[package]
name = "MuTexAlpha"
version = "0.1.0"
authors = ["Webb Hinton <wyhinton189#gmail.com>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
fltk = "0.15.1"
serde = "1.0.118"
texture-synthesis = "0.8.0"
rand = "0.7.3"
num_cpus = "1.13.0"
uuid = { version = "0.8", features = ["serde", "v4"] }
image = "0.23.12"
glob = "0.3.0"
dyn-clone = "1.0.4"
colored = "2.0.0"
arboard = "1.1.0"
id_tree = "1.7.0"
id_tree_layout = "2.0.1"
typetag = "0.1"
serde_json = "1.0.61"
snafu = "0.6.10"
palette = "0.5.0"
indicatif = "0.14.0"
[build]
target = "x86_64-pc-windows-msvc"
Isn't the .exe in release the same program being executed with --cargo run --release?
I have some file dependencies in my app, might this be the cause of the issue? (compiling the app gives no errors, however)
Could this be something specifically related to windows?
Might just be a shot in the dark, but are you opening the exe using Windows Explorer?
Open up a cmd.exe window and try running it from there.
[package]
name = "my package"
version = "0.1.0"
authors = ["me"]
edition = "2018"
[dependencies]
nalgebra = "0.18.1"
I tried to compile rust with above Cargo.toml but it gave me following error:
error: expected item, found `[`
--> Cargo.toml:1:1
|
1 | [package]
| ^ expected item
error: aborting due to previous error
I can fix this if I remove nalgebra = "0.18.1", but I can't use nalgebra package so it doesn't help me.
I think there are multiple issues with your Cargo.toml
This is not allowed:
name = "my package"
Suggestion:
name = "my-package"
There is also missing parts:
error during execution of `cargo metadata`: error: failed to parse manifest at `test/Cargo.toml`
Caused by:
no targets specified in the manifest
either src/lib.rs, src/main.rs, a [lib] section, or [[bin]] section must be present
Could you post the entire file here?
A minimum viable setup:
[package]
name = "my-package"
version = "0.1.0"
authors = ["me"]
edition = "2018"
[[bin]]
name = "radkilla"
path = "src/main.rs"
doc = false
[dependencies]
nalgebra = "0.18.1"
src/main.rs
fn main() {}
Running fmt and build:
➜ test cargo fmt ; cargo build
Finished dev [unoptimized + debuginfo] target(s) in 0.11s
The error disappeared after closing the cargo.toml file which was opened on the visual studio.