简体   繁体   中英

Rust build fails on Internet Computer canister: syntax error in version script, linking with cc failed exit status: 1

When I tried to follow https://inte.netcomputer.org docs on building a hello canister on my Linux, cargo build failed:

$ dfx new hello --type rust
$ cd hello
$ cargo build
   Compiling hello_backend v0.1.0 (/../hello/src/hello_backend)
error: linking with `cc` failed: exit status: 1
  |
  = note: "cc" "-Wl,--version-script=/tmp/rustcWfyFge/list" "-m64" "/tmp/rustcWfyFge/symbols.o" "/../hello/target/debug/deps/hello_backend.10nr6zeb20w33e2a.rcgu.o" "/../hello/target/debug/deps/hello_backend.157czsoro64x5eud.rcgu.o" "/../hello/target/debug/deps/hello_backend.1csqxeuuyx1q0u8a.rcgu.o" "/../hello/target/debug/deps/hello_backend.1hz32co5wwp7w2vq.rcgu.o" "/../hello/target/debug/deps/hello_backend.1s0tixx7id05nppg.rcgu.o" "/../hello/target/debug/deps/hello_backend.1vd04g1yyn0cn1h.rcgu.o" "/../hello/target/debug/deps/hello_backend.209xp60o9zgkldjz.rcgu.o" "/../hello/target/debug/deps/hello_backend.2307avreogr79j98.rcgu.o" "/../hello/target/debug/deps/hello_backend.2853hlbfyfhgveuk.rcgu.o" "/../hello/target/debug/deps/hello_backend.2cmvrd2w9bzx44li.rcgu.o" "/../hello/target/debug/deps/hello_backend.2g2zezvyqorkc8iu.rcgu.o" "/../hello/target/debug/deps/hello_backend.2nbpah36kktta4ov.rcgu.o" "/../hello/target/debug/deps/hello_backend.2pb3ox66xdvhz5jv.rcgu.o" "/../hello/target/debug/deps/hello_backend.2y3due3txllgk7bf.rcgu.o" "/../hello/target/debug/deps/hello_backend.34n4901fmi06c.rcgu.o" "/../hello/target/debug/deps/hello_backend.3gcgdjd46wtfvz4p.rcgu.o" "/../hello/target/debug/deps/hello_backend.3vqk56phs5yetyua.rcgu.o" "/../hello/target/debug/deps/hello_backend.414p3m7fi96gvqnh.rcgu.o" "/../hello/target/debug/deps/hello_backend.42divil5favbmukk.rcgu.o" "/../hello/target/debug/deps/hello_backend.42k69ejjzdzyvkgt.rcgu.o" "/../hello/target/debug/deps/hello_backend.43ssf5yvycblb7o.rcgu.o" "/../hello/target/debug/deps/hello_backend.4hjme1chn8rzczao.rcgu.o" "/../hello/target/debug/deps/hello_backend.4noiz5ylg6ftgz7f.rcgu.o" "/../hello/target/debug/deps/hello_backend.4pygyoroddtx9lfc.rcgu.o" "/../hello/target/debug/deps/hello_backend.54lxyi8x90q15ee1.rcgu.o" "/../hello/target/debug/deps/hello_backend.zldleds8pu3ntx2.rcgu.o" "/../hello/target/debug/deps/hello_backend.1ih96ippiyozxeo0.rcgu.o" "-Wl,--as-needed" "-L" "/../hello/target/debug/deps" "-L" "/home/user1/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/../hello/target/debug/deps/libic_cdk-ef1173c88e42e0f3.rlib" "/../hello/target/debug/deps/libic0-135f4366adb109a6.rlib" "/../hello/target/debug/deps/libcandid-c60d4fe8eaa54e5b.rlib" "/../hello/target/debug/deps/libcrc32fast-8c3a3677c08bc42f.rlib" "/../hello/target/debug/deps/libdata_encoding-a770dc838198d979.rlib" "/../hello/target/debug/deps/libserde_bytes-c91225e01f36016b.rlib" "/../hello/target/debug/deps/libhex-eecad076cf66a849.rlib" "/../hello/target/debug/deps/libleb128-b6653739d1c7412c.rlib" "/../hello/target/debug/deps/libbyteorder-5b3de8b75aa468f8.rlib" "/../hello/target/debug/deps/liblogos-b7f27420ff44b2d4.rlib" "/../hello/target/debug/deps/libsha2-cf897d332585eabb.rlib" "/../hello/target/debug/deps/libcpufeatures-b308455f658c43c5.rlib" "/../hello/target/debug/deps/libcfg_if-540f49c19097eeb6.rlib" "/../hello/target/debug/deps/libdigest-619290acea0aa221.rlib" "/../hello/target/debug/deps/libblock_buffer-06b9f9cf1d105b75.rlib" "/../hello/target/debug/deps/libcrypto_common-b664ef09f8deefa6.rlib" "/../hello/target/debug/deps/libgeneric_array-c7a74e98ede84af4.rlib" "/../hello/target/debug/deps/libtypenum-e3f03a73493daee7.rlib" "/../hello/target/debug/deps/libnum_bigint-43d45c128e35ceb5.rlib" "/../hello/target/debug/deps/libnum_integer-48c0d962d1653f8f.rlib" "/../hello/target/debug/deps/libnum_traits-e9c5f7d04342d7ef.rlib" "/../hello/target/debug/deps/libanyhow-911f2ad07f570cfd.rlib" "/../hello/target/debug/deps/libnum_enum-9d8db1d7561a5c55.rlib" "/../hello/target/debug/deps/libbinread-4142592fd14fcc03.rlib" "/../hello/target/debug/deps/liblazy_static-0979de6da59c6ace.rlib" "/../hello/target/debug/deps/liblalrpop_util-193f115507938374.rlib" "/../hello/target/debug/deps/libregex-b1ca01a0c15b9e0a.rlib" "/../hello/target/debug/deps/libaho_corasick-5d805f6d03ca32e7.rlib" "/../hello/target/debug/deps/libmemchr-6142047547abf529.rlib" "/../hello/target/debug/deps/libregex_syntax-e5a68ef499797b4e.rlib" "/../hello/target/debug/deps/libthiserror-f14cb5279c76c61f.rlib" "/../hello/target/debug/deps/libcodespan_reporting-a2c495332a5782e9.rlib" "/../hello/target/debug/deps/libunicode_width-e479bb02c653ecc6.rlib" "/../hello/target/debug/deps/libtermcolor-b92eab123848f55e.rlib" "/../hello/target/debug/deps/libpretty-6ccf43a0c97b080b.rlib" "/../hello/target/debug/deps/libarrayvec-a3283f0fe0fc69d3.rlib" "/../hello/target/debug/deps/libtyped_arena-4ea273b6ff2758eb.rlib" "/../hello/target/debug/deps/libserde-c65ed50b5df8f511.rlib" "/home/user1/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-a11e3ca400b3ed09.rlib" "/home/user1/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-3e82a3fced649488.rlib" "/home/user1/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-53a4330185981bcb.rlib" "/home/user1/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libmemchr-2a8b57667b4852b5.rlib" "/home/user1/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-9370462deca12c5a.rlib" "/home/user1/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-7da763b8d3620472.rlib" "/home/user1/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-5bde27582a7f5af7.rlib" "/home/user1/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_detect-1204e05b2d47e3d7.rlib" "/home/user1/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-43987de2766b6923.rlib" "/home/user1/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-d6499a0705316aa5.rlib" "/home/user1/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-c9a27c90d8fbf11e.rlib" "/home/user1/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-8f159929cbfdfaf1.rlib" "/home/user1/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-d2f1e8f3bb5cba95.rlib" "/home/user1/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-9862f486269f442f.rlib" "/home/user1/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-0434381f2f012ae2.rlib" "/home/user1/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-68549403a59fd02e.rlib" "/home/user1/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-4cefb2045f924a5b.rlib" "/home/user1/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-272615fc4f10c50d.rlib" "/home/user1/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-860619b93700e7eb.rlib" "/home/user1/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-b73e5b4656934876.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-znoexecstack" "-L" "/home/user1/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/../hello/target/debug/deps/libhello_backend.so" "-Wl,--gc-sections" "-shared" "-Wl,-zrelro,-znow" "-nodefaultlibs"
  = note: /usr/bin/ld:/tmp/rustcWfyFge/list:3: syntax error in VERSION script
          collect2: error: ld returned 1 exit status

error: could not compile `hello_backend` due to previous error

when I ran dfx deploy after running dfx start in another terminal, I got

Deploying all canisters.
Creating canisters...
Creating canister hello_backend...
hello_backend canister created with canister id: rdmx6-jaaaa-aaaaa-aaadq-cai
Creating canister hello_frontend...
hello_frontend canister created with canister id: qoctq-giaaa-aaaaa-aaaea-cai
Building canisters...
WARN: Cannot check for vulnerabilities in rust canisters because cargo-audit is not installed. Please run 'cargo install cargo-audit' so that vulnerabilities can be detected.
Executing: cargo build --target wasm32-unknown-unknown --release -p hello_backend --locked
   Compiling autocfg v1.1.0
   Compiling proc-macro2 v1.0.49
   Compiling unicode-ident v1.0.6
   Compiling quote v1.0.23
   ...

So from above you can see cargo build --target wasm32-unknown-unknown , which should be used to check if Rust can build properly

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM