尝试使用 cargo build-bpf 构建 rust 项目时出错

Error when trying to build rust project with cargo build-bpf

我目前正在通过教程学习 Solana。创建项目、添加依赖项并编写我的程序后,我应该 运行 以下命令来创建适合部署到 Solana

的 Rust 代码构建
cargo build-bpf --manifest-path=Cargo.toml --bpf-out-dir=dist/program

在 运行 执行此命令后,我收到此错误:

error: linking with `\?\C:\Users\Andrew\.local\share\solana\install\releases.9.6\solana-release\bin\sdk\bpf\dependencies\bpf-tools\llvm\bin\ld.lld` failed: exit code: 1
  |
  = note: "\\?\C:\Users\Andrew\.local\share\solana\install\releases\1.9.6\solana-release\bin\sdk\bpf\dependencies\bpf-tools\llvm\bin\ld.lld" "--version-script=C:\Users\Andrew\AppData\Local\Temp\rustcfP4dWA\list" "C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.0.rcgu.o" "C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.1.rcgu.o" "C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.10.rcgu.o" "C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.11.rcgu.o" "C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.12.rcgu.o" "C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.13.rcgu.o" "C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.14.rcgu.o" "C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.15.rcgu.o" "C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.2.rcgu.o" "C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.3.rcgu.o" "C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.4.rcgu.o" "C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.5.rcgu.o" "C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.6.rcgu.o" "C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.7.rcgu.o" "C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.8.rcgu.o" "C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.9.rcgu.o" "C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.uld0kociqtl6etw.rcgu.o" "--as-needed" "-L" "C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps" "-L" "C:\Users\Andrew\crowd_funding\crowd-funding\program\target\release\deps" "-L" "C:\Users\Andrew\.cache\solana\v1.23\bpf-tools\rust\lib\rustlib\bpfel-unknown-unknown\lib" "-Bstatic" "C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\libsolana_program-b2b13310817f5248.rlib" "C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\libserde_bytes-aef9648808d9c831.rlib" "C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\libblake3-9c296c099c94bc54.rlib" "C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\libconstant_time_eq-5c8fe6fb88b82dcc.rlib" "C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\libarrayvec-5f41e504062ba5bd.rlib" "C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\libdigest-9f0b3cc7612e1076.rlib" "C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\libsubtle-a1562280b43e07dc.rlib" "C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\libblock_buffer-a147e55a99bb097c.rlib" "C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\libcrypto_common-b64c25475c677681.rlib" "C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\libarrayref-62e325660dcbcdad.rlib" "C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\libsolana_frozen_abi-39b4f96965d78918.rlib" "C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\libbs58-4ba0e4b26a8bc639.rlib" "C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\libbv-bb7083cc9f8ca62c.rlib" "C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\libbytemuck-9d74d8b3a4e69402.rlib" "C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\liblazy_static-40cf5ca4fb226fc4.rlib" "C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\libsha3-bbd73384f96d675f.rlib" "C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\libkeccak-2002a05ba274f01b.rlib" "C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\libsha2-a86070b99a0022c7.rlib" "C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\libopaque_debug-2cfb1a43922e8fa5.rlib" "C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\libdigest-ea1685ff6f232064.rlib" "C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\libblock_buffer-167db070cc2bcdb1.rlib" "C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\libblock_padding-aae0a410e0661616.rlib" "C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\libgeneric_array-a6d784931f2d5898.rlib" "C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\libtypenum-5b6a5cc6c27f3e89.rlib" "C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\liblog-c21ec511aa92c880.rlib" "C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\libcfg_if-ff438ac9b30946a3.rlib" "C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\libnum_traits-de22efb352be6c17.rlib" "C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\libbincode-3947f1bf19062b27.rlib" "C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\libserde-04054e8a9cafe1ca.rlib" "C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\libthiserror-10d222c05f59092d.rlib" "C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\libborsh-4c2a80a409a40648.rlib" "--start-group" "C:\Users\Andrew\.cache\solana\v1.23\bpf-tools\rust\lib\rustlib\bpfel-unknown-unknown\lib\libstd-09f30ec6d9bcf4bb.rlib" "C:\Users\Andrew\.cache\solana\v1.23\bpf-tools\rust\lib\rustlib\bpfel-unknown-unknown\lib\libpanic_abort-0129f2b71ae47d8c.rlib" "C:\Users\Andrew\.cache\solana\v1.23\bpf-tools\rust\lib\rustlib\bpfel-unknown-unknown\lib\libstd_detect-291be22324585073.rlib" "C:\Users\Andrew\.cache\solana\v1.23\bpf-tools\rust\lib\rustlib\bpfel-unknown-unknown\lib\libhashbrown-b89a97989cce08e1.rlib" "C:\Users\Andrew\.cache\solana\v1.23\bpf-tools\rust\lib\rustlib\bpfel-unknown-unknown\lib\librustc_std_workspace_alloc-0d0f29f2be0139d5.rlib" "C:\Users\Andrew\.cache\solana\v1.23\bpf-tools\rust\lib\rustlib\bpfel-unknown-unknown\lib\libunwind-43e4d5094e6a98d9.rlib" "C:\Users\Andrew\.cache\solana\v1.23\bpf-tools\rust\lib\rustlib\bpfel-unknown-unknown\lib\libcfg_if-f7de57aa039b1991.rlib" "C:\Users\Andrew\.cache\solana\v1.23\bpf-tools\rust\lib\rustlib\bpfel-unknown-unknown\lib\liblibc-f568e648f8426533.rlib" "C:\Users\Andrew\.cache\solana\v1.23\bpf-tools\rust\lib\rustlib\bpfel-unknown-unknown\lib\liballoc-ca33e91228706d40.rlib" "C:\Users\Andrew\.cache\solana\v1.23\bpf-tools\rust\lib\rustlib\bpfel-unknown-unknown\lib\librustc_std_workspace_core-2e1fdcf37081a104.rlib" "C:\Users\Andrew\.cache\solana\v1.23\bpf-tools\rust\lib\rustlib\bpfel-unknown-unknown\lib\libcore-38e5758490a5e05e.rlib" "--end-group" "C:\Users\Andrew\.cache\solana\v1.23\bpf-tools\rust\lib\rustlib\bpfel-unknown-unknown\lib\libcompiler_builtins-98c1293c09977ba1.rlib" "-Bdynamic" "--script" "C:\Users\Andrew\AppData\Local\Temp\rustcfP4dWA\rustc-bpfel-linkfile.ld" "-znoexecstack" "-L" "C:\Users\Andrew\.cache\solana\v1.23\bpf-tools\rust\lib\rustlib\bpfel-unknown-unknown\lib" "-o" "C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.so" "--gc-sections" "-shared" "--entry=entrypoint" "-O1"
  = note: ld.lld: error: can't create dynamic relocation R_BPF_64_64 against symbol: .L__unnamed_1 in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
          >>> defined in C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.0.rcgu.o
          >>> referenced by crowd_funding.162a58ac-cgu.0
          >>>               C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.0.rcgu.o:(borsh::de::BorshDeserialize::try_from_slice::h47523afb23741a51)

          ld.lld: error: can't create dynamic relocation R_BPF_64_64 against symbol: .L__unnamed_2 in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
          >>> defined in C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.0.rcgu.o
          >>> referenced by crowd_funding.162a58ac-cgu.0
          >>>               C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.0.rcgu.o:(_$LT$alloc..string..String$u20$as$u20$borsh..de..BorshDeserialize$GT$::deserialize::he9fe3c9f5f33a2c2)

          ld.lld: error: can't create dynamic relocation R_BPF_64_64 against symbol: .L__unnamed_3 in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
          >>> defined in C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.0.rcgu.o
          >>> referenced by crowd_funding.162a58ac-cgu.0
          >>>               C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.0.rcgu.o:(_$LT$alloc..string..String$u20$as$u20$borsh..de..BorshDeserialize$GT$::deserialize::he9fe3c9f5f33a2c2)

          ld.lld: error: can't create dynamic relocation R_BPF_64_64 against symbol: .L__unnamed_4 in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
          >>> defined in C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.0.rcgu.o
          >>> referenced by crowd_funding.162a58ac-cgu.0
          >>>               C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.0.rcgu.o:(_$LT$alloc..string..String$u20$as$u20$borsh..de..BorshDeserialize$GT$::deserialize::he9fe3c9f5f33a2c2)

          ld.lld: error: relocation R_BPF_64_32 cannot be used against symbol abort; recompile with -fPIC
          >>> defined in C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.0.rcgu.o
          >>> referenced by crowd_funding.162a58ac-cgu.0
          >>>               C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.0.rcgu.o:(_$LT$alloc..string..String$u20$as$u20$borsh..de..BorshDeserialize$GT$::deserialize::he9fe3c9f5f33a2c2)

          ld.lld: error: can't create dynamic relocation R_BPF_64_64 against symbol: .L__unnamed_5 in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
          >>> defined in C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.0.rcgu.o
          >>> referenced by crowd_funding.162a58ac-cgu.0
          >>>               C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.0.rcgu.o:(_$LT$alloc..string..String$u20$as$u20$borsh..de..BorshDeserialize$GT$::deserialize::he9fe3c9f5f33a2c2)

          ld.lld: error: can't create dynamic relocation R_BPF_64_64 against symbol: .L__unnamed_5 in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
          >>> defined in C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.0.rcgu.o
          >>> referenced by crowd_funding.162a58ac-cgu.0
          >>>               C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.0.rcgu.o:(_$LT$alloc..string..String$u20$as$u20$borsh..de..BorshDeserialize$GT$::deserialize::he9fe3c9f5f33a2c2)

          ld.lld: error: can't create dynamic relocation R_BPF_64_64 against symbol: .L__unnamed_6 in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
          >>> defined in C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.0.rcgu.o
          >>> referenced by crowd_funding.162a58ac-cgu.0
          >>>               C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.0.rcgu.o:(_$LT$alloc..string..String$u20$as$u20$borsh..de..BorshDeserialize$GT$::deserialize::he9fe3c9f5f33a2c2)

          ld.lld: error: can't create dynamic relocation R_BPF_64_64 against symbol: .L__unnamed_7 in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
          >>> defined in C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.0.rcgu.o
          >>> referenced by crowd_funding.162a58ac-cgu.0
          >>>               C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.0.rcgu.o:(_$LT$alloc..string..String$u20$as$u20$borsh..de..BorshDeserialize$GT$::deserialize::he9fe3c9f5f33a2c2)

          ld.lld: error: can't create dynamic relocation R_BPF_64_64 against symbol: .L__unnamed_8 in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
          >>> defined in C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.0.rcgu.o
          >>> referenced by crowd_funding.162a58ac-cgu.0
          >>>               C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.0.rcgu.o:(_$LT$alloc..string..String$u20$as$u20$borsh..de..BorshDeserialize$GT$::deserialize::he9fe3c9f5f33a2c2)

          ld.lld: error: can't create dynamic relocation R_BPF_64_64 against symbol: .L__unnamed_9 in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
          >>> defined in C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.0.rcgu.o
          >>> referenced by crowd_funding.162a58ac-cgu.0
          >>>               C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.0.rcgu.o:(_$LT$alloc..string..String$u20$as$u20$borsh..de..BorshDeserialize$GT$::deserialize::he9fe3c9f5f33a2c2)

          ld.lld: error: relocation R_BPF_64_32 cannot be used against symbol abort; recompile with -fPIC
          >>> defined in C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.0.rcgu.o
          >>> referenced by crowd_funding.162a58ac-cgu.0
          >>>               C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.0.rcgu.o:(_$LT$alloc..string..String$u20$as$u20$borsh..de..BorshDeserialize$GT$::deserialize::he9fe3c9f5f33a2c2)

          ld.lld: error: can't create dynamic relocation R_BPF_64_64 against symbol: .L__unnamed_5 in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
          >>> defined in C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.0.rcgu.o
          >>> referenced by crowd_funding.162a58ac-cgu.0
          >>>               C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.0.rcgu.o:(_$LT$alloc..string..String$u20$as$u20$borsh..de..BorshDeserialize$GT$::deserialize::he9fe3c9f5f33a2c2)

          ld.lld: error: can't create dynamic relocation R_BPF_64_64 against symbol: .L__unnamed_10 in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
          >>> defined in C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.0.rcgu.o
          >>> referenced by crowd_funding.162a58ac-cgu.0
          >>>               C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.0.rcgu.o:(entrypoint)

          ld.lld: error: can't create dynamic relocation R_BPF_64_64 against symbol: .L__unnamed_11 in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
          >>> defined in C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.0.rcgu.o
          >>> referenced by crowd_funding.162a58ac-cgu.0
          >>>               C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.0.rcgu.o:(entrypoint)

          ld.lld: error: can't create dynamic relocation R_BPF_64_64 against symbol: .L__unnamed_12 in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
          >>> defined in C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.0.rcgu.o
          >>> referenced by crowd_funding.162a58ac-cgu.0
          >>>               C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.0.rcgu.o:(entrypoint)

          ld.lld: error: relocation R_BPF_64_32 cannot be used against symbol abort; recompile with -fPIC
          >>> defined in C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.0.rcgu.o
          >>> referenced by crowd_funding.162a58ac-cgu.0
          >>>               C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.0.rcgu.o:(entrypoint)

          ld.lld: error: can't create dynamic relocation R_BPF_64_64 against symbol: .L__unnamed_13 in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
          >>> defined in C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.0.rcgu.o
          >>> referenced by crowd_funding.162a58ac-cgu.0
          >>>               C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.0.rcgu.o:(entrypoint)

          ld.lld: error: relocation R_BPF_64_32 cannot be used against symbol sol_log_; recompile with -fPIC
          >>> defined in C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.0.rcgu.o
          >>> referenced by crowd_funding.162a58ac-cgu.0
          >>>               C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.0.rcgu.o:(entrypoint)

          ld.lld: error: can't create dynamic relocation R_BPF_64_64 against symbol: .L__unnamed_14 in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
          >>> defined in C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.0.rcgu.o
          >>> referenced by crowd_funding.162a58ac-cgu.0
          >>>               C:\Users\Andrew\crowd_funding\crowd-funding\program\target\bpfel-unknown-unknown\release\deps\crowd_funding.crowd_funding.162a58ac-cgu.0.rcgu.o:(entrypoint)

          ld.lld: error: too many errors emitted, stopping now (use -error-limit=0 to see all errors)


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

我目前的Solana版本是1.9.6版本,我目前的rustc版本是1.58.1。 我的 Cargo.toml 文件:

[package]
name = "crowd_funding"
version = "0.1.0"
edition = "2021"


[dependencies]
solana-program = "1.7.14"
borsh = "0.9.1"
borsh-derive = "0.9.1"

[features]
no-entrypoint = []

[dev-dependencies]
solana-program-test = "1.7.14"
solana-sdk = "1.7.14"

[lib]
crate-type = ["cdylib", "lib"]

Xargo.toml 文件:

[target.bpfel-unknown-unknown.dependencies.std]
features = []

请问我该怎么做才能解决这个问题?

我解决了错误。 /你不能在 windows 环境中构建 solana 程序。 您需要使用 WSL ubuntu 子系统。