Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to compile Bouncing Ball example #26

Open
jamaas opened this issue Feb 6, 2024 · 6 comments
Open

Unable to compile Bouncing Ball example #26

jamaas opened this issue Feb 6, 2024 · 6 comments

Comments

@jamaas
Copy link

jamaas commented Feb 6, 2024

Relative noob to Rust here, but lots of experience with other languages. My goal is to build a simple generic two-pool compartmental model using Rust and ode's. I found your ode models and they look perfect except there is something wrong with my Rust setup. When I attempt to compile the bouncing ball example I get these errors. Any/all suggestions most welcome, genuine thanks for your patience.

:jambounc $ cargo build
Compiling jambounc v0.1.0 (/home/jamaas/research/rust/renevey/ode-solvers-main/jambounc)
error[E0405]: cannot find trait Systemo in crate ode_solvers
--> jambounc/src/main.rs:72:19
|
72 | impl ode_solvers::Systemo<Time, State> for BouncingBall {
| ^^^^^^^ help: a trait with a similar name exists: System
|
::: /home/jamaas/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ode_solvers-0.4.0/src/dop_shared.rs:25:1
|
25 | pub trait System<T, V>
| ---------------------- similarly named trait System defined here

@tomtuamnuq
Copy link

Hi @jamaas. The name of the trait in the ode-solvers crate is System. This trait gets exported in the library file lib.rs so that you can use it with ode_solvers::System. The compiler messages look like there is an additional letter o in the use Systemo. Can you check that? If it is not the source of the error maybe you can provide the full code of your main.rs file.

@jamaas
Copy link
Author

jamaas commented Feb 6, 2024

Thanks @tomtuamnuq. I thought the same but this is an exact copy of example code from Github. I'll do some digging and see what I find, and report back.

@jamaas
Copy link
Author

jamaas commented Feb 6, 2024

Thanks again @tomtuamnuq. That was indeed the problem and must have been done by me because original code does not have it. Ooops. Now I am getting this out of scope error .... Suggestions on how to fix this?

-- mode: compilation; default-directory: "~/research/rust/renevey/ode-solvers-main/" --
Compilation started at Tue Feb 6 15:03:24

cargo build
Compiling ode_solvers v0.4.0 (/home/jamaas/research/rust/renevey/ode-solvers-main)
error[E0412]: cannot find type Vector3 in this scope
--> src/dop_shared.rs:23:14
|
23 | type State = Vector3;
| ^^^^^^^ not found in this scope
|
help: consider importing one of these items
|
3 + use crate::Vector3;
|
3 + use nalgebra::Vector3;
|

error[E0782]: trait objects must include the dyn keyword
--> src/dop_shared.rs:24:17
|
24 | type MySystem = System<Precision, State>;
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
help: add dyn keyword before this trait
|
24 | type MySystem = dyn System<Precision, State>;
| +++

Some errors have detailed explanations: E0412, E0782.
For more information about an error, try rustc --explain E0412.
error: could not compile ode_solvers (lib) due to 2 previous errors

Compilation exited abnormally with code 101 at Tue Feb 6 15:03:25

@srenevey
Copy link
Owner

srenevey commented Feb 7, 2024

Hi @jamaas,

For the first error, as suggested by the compiler, you need to bring Vector3 in scope. You can do that by importing it with use crate::Vector3; which is a type alias for nalgebra's Vector3 or directly from nalgebra with use nalgebra::Vector3;.

For the second error, System is a trait. You need to define a structure for your system and then implement this trait. For instance (have a look here for an example):

struct MySystem {};
impl ode_solvers::System<f64, State> for MySystem {
...
}

Lastly, your logs suggest that you are editing dop_shared.rs. I don't know what you are trying to achieve but you might be better off trying to modify one of the examples.

I hope that helps.

@jamaas
Copy link
Author

jamaas commented Feb 7, 2024

Hi @srenevey et. al, sincerely appreciate your help and particularly your time.

I downloaded a fresh un-hacked copy and then attempted to use Cargo, from within Emacs, on Linux to build and then test the boucing_ball.rs file. I'll attach the output I got from both the build and test operations. It appears to compile but does not appear to produce an executable file that I can then run. In my ignorance, am I doing something wrong? Should it not produce a standalone executable file? Do I need to change or adjust my base Rust compiler setup? Why do I get so many errors when running a test? Thanks a bunch. J
cargo_test_output.txt
first_build_output.txt

@jamaas
Copy link
Author

jamaas commented Feb 7, 2024

I did some more reading and learned more about Cargo. As usual was making the initial attempt much more complicated than was necessary! I cloned a new version and followed the Cargo book instructions and it all works fine .... with one tiny exception. When you created the directory/file structure for the project you did not include a ./outputs directory, so the examples have nowhere to put results and throw an error. Might you want to include an empty directory? Would anyone like to help me, or know anyone who would like to help me, build the attached model in Rust?
Thanks a bunch, J.
Two Pool Model

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants