How can i successfully run example code from github?

Hi all,
I am in search of a simple gui library(For Windows only). I found a lot in github. But i can't test the example code. What i am doing is just download the library and navigate to the example code directory and run the file with rustc command. But it can't find the extern crates, Do i need to use cargo ? If so how ? Because, i only know to create a new project with cargo. I dont know how to create a project with existing rust sample code.

Generally if there’s an examples directory you can run:

cargo run --example examplename

Where examplename is the name of the directory or file for that specific example. Make sure not to include the ‘rs’ file extension.

1 Like

Thanks for the quick reply. Let me try. :slight_smile:

It started downloading nearly 50+ files and the started compiling. This is horrible than i thought. The compilation is still under progress after 10 minutes. OMG ! And ended up in an error after 12 minutes.

It depends on the library I guess.

Maybe you could say which one and what errors you’ve seen. Or perhaps others on the forum have some alternative recommendations.

A lot of rust libraries depend on other libraries. Dependency hell is avoided in terms of versions clashing (cargo is actually pretty clever about this!), but the number of dependencies is still typically high.

Familiar stuff if you've worked with js and npm before. Only because rust is compiled all those dependencies can become slow quite quickly. Some rust developers deliberately try to reduce the number of creates they depend on because of this.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.