如何在 Rust 中使用外部板条箱? [英] How do I use external crates in Rust?

查看:52
本文介绍了如何在 Rust 中使用外部板条箱?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 rust-http 库,并且我'想用它作为小项目的基础.

I'm trying to work with the rust-http library, and I'd like to use it as the basis for a small project.

我不知道如何使用我无法通过 rustpkg install 安装的东西.事实上,我今天发现 rustpkg 现在已被弃用.

I have no idea how to use something that I can't install via rustpkg install <remote_url>. In fact, I found out today that rustpkg is now deprecated.

如果我 git clone 库并运行适当的 make 命令来构建它,我如何在其他地方使用它?IE.我如何实际使用 extern crate http?

If I git clone the library and run the appropriate make commands to get it built, how do I use it elsewhere? I.e. how do I actually use extern crate http?

推荐答案

更新

对于现代 Rust,请参阅这个答案.

您需要将 -L 标志传递给 rustc 以将包含编译的 http 库的目录添加到搜索路径.像 rustc -L path-to-cloned-rust-http-repo/build your-source-file.rs 应该做的事情.

You need to pass the -L flag to rustc to add the directory which contains the compiled http library to the search path. Something like rustc -L path-to-cloned-rust-http-repo/build your-source-file.rs should do.

教程参考

这篇关于如何在 Rust 中使用外部板条箱?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆