[rust-dev] Cargo multiple targets

Isak Andersson contact at bitpuffin.com
Wed Jul 2 03:49:12 PDT 2014


Hello Rust folks!

I am using Cargo and I am trying to specify mulitple targets in my
Cargo.toml file.
First of all is this even possible?

The way I have set things up is that I have src/hmwhoami.rs which builds to
a binary,
and uses src/proof.rs and that builds totally fine.

My Cargo file looks like this:
[package]

name = "hmproof"
version = "0.1.0"
authors = [ "isak at houstonmedia.se" ]

[[bin]]

name = "hmwhoami"

[dependencies.rust-http]

git = "https://github.com/chris-morgan/rust-http.git"


Now what I also want to do is to build src/proof.rs as a library (that is
linkable with C programs
so they can call the extern fn's). My initial approach was this:

[package]

name = "hmproof"
version = "0.1.0"
authors = [ "isak at houstonmedia.se" ]

[[bin]]

name = "hmwhoami"

[[lib]]

name = "proof"
(I also tried adding a path)
path = "src/proof.rs"

[dependencies.rust-http]

git = "https://github.com/chris-morgan/rust-http.git"

I also tried putting the [[lib]] part after the dependencies part. The
error I get is this:
error: couldn't read src/bin/hmwhoami.rs: couldn't open file (no such file
or directory (No such file or directory); path=src/bin/hmwhoami.rs;
mode=open; access=read)

Whiich doesn't make any sense at all to me. Why does it suddenly start
looking in src/bin?
Do I have to put my bin code in src/bin and my lib code in src lib or what?
That would probably break the hmwhoami executable because I'd have to make
the proof library an extern crate, at least I think I would have to do that.

Thanks!
Isak Andersson
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20140702/0b12ba21/attachment.html>


More information about the Rust-dev mailing list