当前位置: 首页 > 知识库问答 >
问题:

Rust Playground和local machine中reqwest示例的错误

滑乐逸
2023-03-14

我正在和reqwest图书馆乱搞,想用Rust Playground尝试一些例子。我从web上举了一个最简单的例子,但它不编译。

   Compiling playground v0.0.1 (/playground)
error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-Wl,--eh-frame-hdr" "-L" "/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/playground/target/debug/deps/playground-552f473283bcb85e.playground.1fpw7zol-cgu.0.rcgu.o" "-o" "/playground/target/debug/deps/playground-552f473283bcb85e" "/playground/target/debug/deps/playground-552f473283bcb85e.4jwju6fs7xga1d77.rcgu.o" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro" "-Wl,-znow" "-nodefaultlibs" "-L" "/playground/target/debug/deps" "-L" "/playground/target/debug/build/libsqlite3-sys-16200be2df74876c/out" "-L" "/playground/target/debug/build/ring-bb20fb99fa6aa7fb/out" "-L" "/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/playground/target/debug/deps/libfutures-e81e955c63e30b74.rlib" "/playground/target/debug/deps/libfutures_executor-cfdeba081d488308.rlib" "/playground/target/debug/deps/libreqwest-f9a05f7baf6db60c.rlib" "/playground/target/debug/deps/libcookie_store-140640047f1ead84.rlib" "/playground/target/debug/deps/libpublicsuffix-6ec6805d8d4576ca.rlib" "/playground/target/debug/deps/libregex-690a57b3d88f2f3e.rlib" "/playground/target/debug/deps/libthread_local-8d339f961a8cde82.rlib" "/playground/target/debug/deps/libregex_syntax-4b763771453cb6c9.rlib" "/playground/target/debug/deps/libaho_corasick-a90058961ca40ce7.rlib" "/playground/target/debug/deps/liberror_chain-bfc8e31e68aab259.rlib" "/playground/target/debug/deps/libbacktrace-1f6305b7986130af.rlib" "/playground/target/debug/deps/libobject-8fae803afce7a82f.rlib" "/playground/target/debug/deps/libaddr2line-4cb58e132c263024.rlib" "/playground/target/debug/deps/libobject-600bcc9a4024c890.rlib" "/playground/target/debug/deps/libflate2-7c0dda569caa75f2.rlib" "/playground/target/debug/deps/libminiz_oxide-06fcba964606bf52.rlib" "/playground/target/debug/deps/libadler-cf7f582a580fb2a1.rlib" "/playground/target/debug/deps/libcrc32fast-d8f8d6d441eb6dc8.rlib" "/playground/target/debug/deps/libwasmparser-18775bada4336335.rlib" "/playground/target/debug/deps/libgimli-e397da103aee7023.rlib" "/playground/target/debug/deps/libstable_deref_trait-33402efe82680c8b.rlib" "/playground/target/debug/deps/libfallible_iterator-2abec6be3aaf9504.rlib" "/playground/target/debug/deps/libcpp_demangle-af0e508f637e754e.rlib" "/playground/target/debug/deps/librustc_demangle-b0887c2590d815fd.rlib" "/playground/target/debug/deps/libcookie-212b7aa8adce5158.rlib" "/playground/target/debug/deps/libtime-fd9f56ac09845820.rlib" "/playground/target/debug/deps/libtime_macros-a8c33e90ea2139d7.rlib" "/playground/target/debug/deps/libstandback-f34bd7ec31cc9868.rlib" "/playground/target/debug/deps/libhyper_tls-9848d4b1ee8e7a27.rlib" "/playground/target/debug/deps/libipnet-8e33934d86be4d6e.rlib" "/playground/target/debug/deps/libtokio_native_tls-095fa4f445b9ada7.rlib" "/playground/target/debug/deps/libserde_urlencoded-c61505e8efe59184.rlib" "/playground/target/debug/deps/libencoding_rs-6db646af6aed58d2.rlib" "/playground/target/debug/deps/libserde_json-aaaea4d5f17e7bfd.rlib" "/playground/target/debug/deps/libryu-8177541eadb28761.rlib" "/playground/target/debug/deps/libbase64-263cbd5a5e64ab1a.rlib" "/playground/target/debug/deps/libmime_guess-eb8a1cb9893e4e18.rlib" "/playground/target/debug/deps/libunicase-b4234293fa194e2e.rlib" "/playground/target/debug/deps/libmime-f1104dec2de465c5.rlib" "/playground/target/debug/deps/libnative_tls-7028e32d0e94add2.rlib" "/playground/target/debug/deps/libopenssl_probe-7372e2218175cb8d.rlib" "/playground/target/debug/deps/libopenssl-84d1cdf5218f0b74.rlib" "/playground/target/debug/deps/libopenssl_sys-2038d81ad68cd2ed.rlib" "/playground/target/debug/deps/libforeign_types-37adb5bae539fda7.rlib" "/playground/target/debug/deps/libforeign_types_shared-22f2940fb592036b.rlib" "/playground/target/debug/deps/libbitflags-23cf02f711efe05e.rlib" "/playground/target/debug/deps/libhyper-430dd2c2e9afb7dd.rlib" "/playground/target/debug/deps/libwant-de668461c77b0f6d.rlib" "/playground/target/debug/deps/libtry_lock-30c95cee42568441.rlib" "/playground/target/debug/deps/libhttparse-ebba17a8d7f5b2dd.rlib" "/playground/target/debug/deps/libsocket2-abd46160d6c6c84a.rlib" "/playground/target/debug/deps/libh2-67e8c1f896ffcf25.rlib" "/playground/target/debug/deps/libtracing_futures-bfe252ef9bfa1357.rlib" "/playground/target/debug/deps/libindexmap-e59d655bbe32a039.rlib" "/playground/target/debug/deps/libhashbrown-89e2fd5a7081dfb3.rlib" "/playground/target/debug/deps/libahash-842a5b5404407a6a.rlib" "/playground/target/debug/deps/libconst_random-2c7202c77a6d1341.rlib" "/playground/target/debug/deps/libtokio_util-c597572dfab0a5a3.rlib" "/playground/target/debug/deps/libtower_service-25325533e6471f27.rlib" "/playground/target/debug/deps/libpin_project-85290df7927f46fd.rlib" "/playground/target/debug/deps/libhttpdate-7c9ae15df7de953a.rlib" "/playground/target/debug/deps/libtracing-1e9a893c023cc151.rlib" "/playground/target/debug/deps/libtracing_core-f4d747dfd45a5b1b.rlib" "/playground/target/debug/deps/libtokio-6caecbf8c961c6fc.rlib" "/playground/target/debug/deps/libsignal_hook_registry-464320536f92cd1a.rlib" "/playground/target/debug/deps/libnum_cpus-fa9405d418802dba.rlib" "/playground/target/debug/deps/libmio-8208b1b97ee75dd0.rlib" "/playground/target/debug/deps/libparking_lot-c70fd5290b63ba21.rlib" "/playground/target/debug/deps/libparking_lot_core-bec2d0cef1e036dd.rlib" "/playground/target/debug/deps/libsmallvec-be204749242d57d5.rlib" "/playground/target/debug/deps/liblock_api-9b94798a31b72387.rlib" "/playground/target/debug/deps/libscopeguard-9a7fcdcc3ef0c67a.rlib" "/playground/target/debug/deps/libinstant-801a426885a9fdfa.rlib" "/playground/target/debug/deps/libhttp_body-fa23070edd81973e.rlib" "/playground/target/debug/deps/libfutures_util-b297dd64f98a2e4a.rlib" "/playground/target/debug/deps/libmemchr-49ffcb39de512148.rlib" "/playground/target/debug/deps/libtokio_io-15767d74b5cad8b6.rlib" "/playground/target/debug/deps/libbytes-98612ff3704441d9.rlib" "/playground/target/debug/deps/libiovec-059f69bab14804ea.rlib" "/playground/target/debug/deps/liblibc-0a0510b4037c39f2.rlib" "/playground/target/debug/deps/libbyteorder-630514d63ec14067.rlib" "/playground/target/debug/deps/liblog-1181c8ecdf8fff43.rlib" "/playground/target/debug/deps/libcfg_if-ef24fecc97daf057.rlib" "/playground/target/debug/deps/libfutures-341be2426ac8006a.rlib" "/playground/target/debug/deps/libfutures_io-f642e5411fe1b621.rlib" "/playground/target/debug/deps/libslab-fae38ccb0866d90f.rlib" "/playground/target/debug/deps/libfutures_channel-ca57d40e72b73391.rlib" "/playground/target/debug/deps/libpin_project_lite-3a1c1edfcac5da66.rlib" "/playground/target/debug/deps/libfutures_sink-1e577cd08304b39b.rlib" "/playground/target/debug/deps/libfutures_task-285aea8d738140d9.rlib" "/playground/target/debug/deps/libonce_cell-49c2029294b89ee5.rlib" "/playground/target/debug/deps/libpin_utils-9d73d18d1a913b9e.rlib" "/playground/target/debug/deps/libfutures_core-3c03d3ccebe39c3b.rlib" "/playground/target/debug/deps/liblazy_static-a2d7352f0b2d8328.rlib" "/playground/target/debug/deps/liburl-3738c4378d8afb19.rlib" "/playground/target/debug/deps/libidna-44ceb179b4e434c3.rlib" "/playground/target/debug/deps/libunicode_normalization-7b85e62e0830fcdd.rlib" "/playground/target/debug/deps/libtinyvec-0fd102c28a026123.rlib" "/playground/target/debug/deps/libtinyvec_macros-373a732416c546b7.rlib" "/playground/target/debug/deps/libserde-f598327513f0f87c.rlib" "/playground/target/debug/deps/libunicode_bidi-a18e706d77b75aca.rlib" "/playground/target/debug/deps/libform_urlencoded-4539bb7bd3b31a2c.rlib" "/playground/target/debug/deps/libpercent_encoding-6c71419d296d9169.rlib" "/playground/target/debug/deps/libmatches-396398bf8ad55ae0.rlib" "/playground/target/debug/deps/libhttp-bc59be26651c0476.rlib" "/playground/target/debug/deps/libitoa-97b61b74c453bfb8.rlib" "/playground/target/debug/deps/libbytes-196811ca1432aaea.rlib" "/playground/target/debug/deps/libfnv-f0ba3a8dcbb1e827.rlib" "-Wl,--start-group" "/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-6f77337c1826707d.rlib" "/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-e238540f8faf9927.rlib" "/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-78f8506dd5004913.rlib" "/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-c0e64497deb085aa.rlib" "/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-217a514dc8d845c6.rlib" "/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-65e4f8df4b8bbd73.rlib" "/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-fec1b74170245419.rlib" "/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-e74f867eb2f15322.rlib" "/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-72a374d36f3d0a31.rlib" "/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-cb9206ed96de54c3.rlib" "/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-33ee81149d314805.rlib" "/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-2e8740599b11634b.rlib" "/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-241cf59851357bea.rlib" "/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-edc29aa8c04b480f.rlib" "/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-6a141406945fda5a.rlib" "/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-2408224b4af46d83.rlib" "-Wl,--end-group" "/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-d36087076e1dd756.rlib" "-Wl,-Bdynamic" "-lssl" "-lcrypto" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc"
  = note: collect2: fatal error: ld terminated with signal 9 [Killed]
          compilation terminated.
          

error: aborting due to previous error

error: could not compile `playground`

To learn more, run the command again with --verbose.

另一方面,当我在本地计算机(Windows10)上尝试相同的代码时,它确实会编译,但它会导致这个错误:

D:\DANI\rust\projects\httpget>cargo run    Compiling httpget v0.1.0 (D:\DANI\rust\projects\httpget)
    Finished dev [unoptimized + debuginfo] target(s) in 2.80s
     Running `target\debug\httpget.exe` Request: https://httpbin.org/ip thread 'main' panicked at 'not currently running on a Tokio 0.2.x runtime.', C:\Users\dani\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-0.2.25\src\runtime\handle.rs:118:28 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace         error: process didn't exit successfully: `target\debug\httpget.exe` (exit code: 101)

我已经检查了cargo.toml中的依赖关系:

[dependencies]
error-chain = "0.12.4"
reqwest = { version = "0.10" }
tokio = { version = "1", features = ["full"] }
futures = "0.3"

我认为它与Async/Await运行时有关,但我对Rust语言是新手,我在web上找到的关于这个问题的信息对我来说并不清楚。

共有1个答案

董昕
2023-03-14

这是ReqWest版本的问题。将原始版本替换为

reqwest = { version = "0.11" }

在您的cargo.toml应该在您的本地机器上修复它。

 类似资料:
  • reqwest 用于浏览器异步HTTP请求。支持xmlHttpRequest, JSONP, CORS, 和 CommonJS约束。 API reqwest('path/to/html', function (resp) {  qwery('#content').html(resp)})reqwest({    url: 'path/to/html'  , method: 'post'  , da

  • 这段代码来自google drive api示例,我试图实现这段代码,但它在行中显示了错误....Credential=GoogleAccountCredential.usingOAuth2(this,drivescopes.drive);.....给定的错误是......GoogleAccountCredential类型中的方法usingOAuth2(Context,Collection)不适用

  • 问题内容: 鉴于这种: 输出为: 这是为每个对象提供false,但每个String对象的哈希码都相同。为什么会这样呢? 问题答案: 确实比较 对象的 真实相等性(我的意思是-两个引用都指向同一个对象),而不是它们的内容,而比较内容(至少对于String)。 并指向不同的对象。 还要注意,如果对象相等,则它们的哈希必须相同,但是如果哈希码相同,则并不意味着对象相等。

  • 我试图遵循下面的示例:https://rust-lang-nursery.github.io/rust-cookbook/web/scraping.html,它同时使用Reqwest和Select来获取html响应,然后解析数据。 我使用的是Reqwest Version0.10.4并选择Version0.4.3,这就是它在示例中显示的版本。然而,我得到了一个错误: 似乎from_read方法接受

  • 以上图示了正常的消息流。 正常流程: 步骤 描述 1 过程Listener启动工作。 2 Worker通过定期向自己发送Do消息来计划工作 3, 4, 5 接收到Do时Worker通知CounterService更新计数器值,三次。Increment消息被转发给Counter,它会更新自己的计数器变量并将当前值发给Storage。 6, 7 Worker向CounterService请求计数器的当

  • 尝试按照以下说明为python设置ANTLR http://blog . an vard . org/articles/2016/03/15/ANTLR-python . html 另外使用antlr-4.7.2-complete.jar的本地副本 有语法错误。 使用python2这个: 用python3这个: 为了生成python代码,我在工作目录中使用了Antlr4 - 版本4.7.1 - j