< 返回版块

fashionbrot 发表于 2023-10-31 13:47

Tags:rust

error: failed to run custom build command for ring v0.16.20 哪个大佬给看看到底是哪里的问题? 运行环境 win10 64位,RustRover2023.3

运行的代码如下 Cargo.toml

[package]
name = "mybatis-test"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
log = "0.4"
serde = { version = "1.0", features = ["derive"] }
mybatis = { version = "2.0.4"}
tokio = { version = "1.33.0", features = ["rt", "rt-multi-thread", "macros"] }

main.rs

use mybatis::mybatis::Mybatis;
use mybatis::mybatis_plus;
use mybatis::plus::Mapping;
use mybatis::snowflake::SNOWFLAKE;
use serde::{Serialize, Deserialize};

#[mybatis_plus]
#[derive(Debug, Serialize, Deserialize)]
pub struct Books {
    pub id: Option<String>,
    pub name: Option<String>,
    pub types: Option<String>
}

#[tokio::main]
async fn main() {

    let mybatis = Mybatis::new();

    mybatis.link("mysql://root:123456@localhost:3306/test").await.unwrap();

    let id = SNOWFLAKE.generate();
    let cat = Books {
        id: Some(id.to_string()),
        name: Some("《Daughter of the sea》".to_string()),
        types: Some("Fairy Tales".to_string()),
    };

    mybatis.save(&cat,&[]).await;

}



评论区

写评论
Pikachu 2023-11-01 03:59

See BUILDING.md for instructions on how to build it. These instructions are especially important for cross-compiling and for building on Windows when not building from crates.io, as there are build prerequisites that need to be installed.

Ring的文档特别强调在windows下build需要特殊处理。 https://github.com/briansmith/ring/blob/main/BUILDING.md

Pikachu 2023-11-01 03:54

ring尝试使用gcc编译一些东西。你的windows系统上装gcc了吗?没装的话是必然编译失败的。

github.com/shanliu/lsys 2023-10-31 23:57

建议用 SeaORM ,rbatis 真不咋的

--
👇
lsk569937453: 我和你的报错不一样,我是报找不到rbson这个依赖,加上rbson = "2.0.5",就可以运行了。

顺便说下,https://github.com/rbatis/rbatis 好像这个ORM,用的人更多一些。

作者 fashionbrot 2023-10-31 14:56

--
👇
Pikachu: 贴一下你的详细报错信息。

Ubuntu22.04下面build没问题。


C:/Users/jxkj/.cargo/bin/cargo.exe build --color=always --message-format=json-diagnostic-rendered-ansi --bin mybatis-test --manifest-path E:\dev\rust\project\rust-project-examples\mybatis-example\Cargo.toml
warning: some crates are on edition 2021 which defaults to `resolver = "2"`, but virtual workspaces default to `resolver = "1"`
note: to keep the current resolver, specify `workspace.resolver = "1"` in the workspace root's manifest
note: to use the edition 2021 resolver, specify `workspace.resolver = "2"` in the workspace root's manifest
   Compiling cfg-if v1.0.0
   Compiling memchr v2.6.4
   Compiling typenum v1.17.0
   Compiling winapi-x86_64-pc-windows-gnu v0.4.0
   Compiling syn v2.0.38
   Compiling windows_x86_64_gnu v0.48.5
   Compiling subtle v2.5.0
   Compiling libm v0.2.8
   Compiling winapi v0.3.9
   Compiling windows-targets v0.48.5
   Compiling spin v0.5.2
   Compiling once_cell v1.18.0
   Compiling getrandom v0.2.10
   Compiling ring v0.16.20
error: failed to run custom build command for `ring v0.16.20`
note: To improve backtraces for build dependencies, set the CARGO_PROFILE_DEV_BUILD_OVERRIDE_DEBUG=true environment variable to enable debug information generation.
Caused by:
  process didn't exit successfully: `E:\dev\rust\project\rust-project-examples\target\debug\build\ring-a1678af766c289b9\build-script-build` (exit code: 101)
  --- stdout
  OPT_LEVEL = Some("0")
  TARGET = Some("x86_64-pc-windows-gnu")
  HOST = Some("x86_64-pc-windows-gnu")
  cargo:rerun-if-env-changed=CC_x86_64-pc-windows-gnu
  CC_x86_64-pc-windows-gnu = None
  cargo:rerun-if-env-changed=CC_x86_64_pc_windows_gnu
  CC_x86_64_pc_windows_gnu = None
  cargo:rerun-if-env-changed=HOST_CC
  HOST_CC = None
  cargo:rerun-if-env-changed=CC
  CC = None
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("true")
  CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
  cargo:rerun-if-env-changed=CFLAGS_x86_64-pc-windows-gnu
  CFLAGS_x86_64-pc-windows-gnu = None
  cargo:rerun-if-env-changed=CFLAGS_x86_64_pc_windows_gnu
  CFLAGS_x86_64_pc_windows_gnu = None
  cargo:rerun-if-env-changed=HOST_CFLAGS
  HOST_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  --- stderr
  running "gcc.exe" "-O0" "-ffunction-sections" "-fdata-sections" "-gdwarf-2" "-fno-omit-frame-pointer" "-m64" "-I" "include" "-Wall" "-Wextra" "-std=c1x" "-Wbad-function-cast" "-Wnested-externs" "-Wstrict-prototypes" "-pedantic" "-pedantic-errors" "-Wall" "-Wextra" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wenum-compare" "-Wfloat-equal" "-Wformat=2" "-Winline" "-Winvalid-pch" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wundef" "-Wuninitialized" "-Wwrite-strings" "-fno-strict-aliasing" "-fvisibility=hidden" "-g3" "-DNDEBUG" "-c" "-oE:\\dev\\rust\\project\\rust-project-examples\\target\\debug\\build\\ring-feb9b0bff42918b2\\out\\aes_nohw.o" "crypto/fipsmodule/aes/aes_nohw.c"
  thread 'main' panicked at C:\Users\jxkj\.cargo\registry\src\index.crates.io-6f17d22bba15001f\ring-0.16.20\build.rs:653:9:
  failed to execute ["gcc.exe" "-O0" "-ffunction-sections" "-fdata-sections" "-gdwarf-2" "-fno-omit-frame-pointer" "-m64" "-I" "include" "-Wall" "-Wextra" "-std=c1x" "-Wbad-function-cast" "-Wnested-externs" "-Wstrict-prototypes" "-pedantic" "-pedantic-errors" "-Wall" "-Wextra" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wenum-compare" "-Wfloat-equal" "-Wformat=2" "-Winline" "-Winvalid-pch" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wundef" "-Wuninitialized" "-Wwrite-strings" "-fno-strict-aliasing" "-fvisibility=hidden" "-g3" "-DNDEBUG" "-c" "-oE:\\dev\\rust\\project\\rust-project-examples\\target\\debug\\build\\ring-feb9b0bff42918b2\\out\\aes_nohw.o" "crypto/fipsmodule/aes/aes_nohw.c"]: program not found
  stack backtrace:
     0: rust_begin_unwind
               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src/panicking.rs:595:5
     1: core::panicking::panic_fmt
               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\core\src/panicking.rs:67:14
     2: build_script_build::run_command::{{closure}}
     3: core::result::Result<T,E>::unwrap_or_else
     4: build_script_build::run_command
     5: build_script_build::compile
     6: build_script_build::build_library::{{closure}}
     7: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &mut F>::call_once
     8: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next
     9: alloc::vec::Vec<T,A>::extend_desugared
    10: <alloc::vec::Vec<T,A> as alloc::vec::spec_extend::SpecExtend<T,I>>::spec_extend
    11: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter_nested::SpecFromIterNested<T,I>>::from_iter
    12: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
    13: <alloc::vec::Vec<T> as core::iter::traits::collect::FromIterator<T>>::from_iter
    14: core::iter::traits::iterator::Iterator::collect
    15: build_script_build::build_library
    16: build_script_build::build_c_code::{{closure}}
    17: <core::slice::iter::Iter<T> as core::iter::traits::iterator::Iterator>::for_each
    18: build_script_build::build_c_code
    19: build_script_build::ring_build_rs_main
    20: build_script_build::main
    21: core::ops::function::FnOnce::call_once
  note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
warning: build failed, waiting for other jobs to finish...
Process finished with exit code 101
lsk569937453 2023-10-31 14:42

我和你的报错不一样,我是报找不到rbson这个依赖,加上rbson = "2.0.5",就可以运行了。

顺便说下,https://github.com/rbatis/rbatis 好像这个ORM,用的人更多一些。

Pikachu 2023-10-31 14:40

贴一下你的详细报错信息。

Ubuntu22.04下面build没问题。

1 共 6 条评论, 1 页