我已经用 C 包装器编写了一个 C++ 库,并想从我的 Rust 项目中调用这些函数。然而,当我尝试将我的 Rust 项目链接到 C 库时,我收到了一个很长的错误,并带有注释
\n\n note: /usr/bin/ld: cannot find -l../cpp_library/build/libdisplay.so\nRun Code Online (Sandbox Code Playgroud)\n\n我尝试将绝对路径传递给库并收到类似的错误。
\n\n我的组合项目有以下目录和内容
\n\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 cpp_library\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 CMakeLists.txt\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 include\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 display.h\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 src\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 display.cpp\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 main.cpp\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 rust_project\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 build.rs\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 Cargo.lock\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 Cargo.toml\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 src\n \xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 main.rs\nRun Code Online (Sandbox Code Playgroud)\n\nCMakeLists.txt
\n\ncmake_minimum_required(VERSION 3.1.0)\nproject(directory_test)\nset(CMAKE_BUILD_TYPE Release)\n\n#Bring the headers into the project\ninclude_directories(include)\n\n\nset(SOURCES "src/display.cpp")\n\n#Generate the shared library from the sources\nadd_library(display SHARED ${SOURCES})\nadd_executable(display_test "src/main.cpp" ${SOURCES})\nRun Code Online (Sandbox Code Playgroud)\n\n显示.h
\n\nextern "C" {\n void display();\n}\nRun Code Online (Sandbox Code Playgroud)\n\n … 我有一个包含MyStruct2我需要克隆的可变引用()的结构,所以我派生了Clone该结构的方法:
#[derive(Clone)]
struct MyStruct {
val: usize,
}
#[derive(Clone)]
struct MyStruct2<'a> {
struct_reference: &'a mut MyStruct
}
Run Code Online (Sandbox Code Playgroud)
但是,当我编译此代码时,我收到以下错误消息:
src/main.rs:419:3: 419:37 error: the trait `core::clone::Clone` is not implemented for the type `&mut MyStruct` [E0277]
src/main.rs:419 struct_reference: &'a mut MyStruct
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/main.rs:417:11: 417:16 note: in this expansion of #[derive_Clone] (defined in src/main.rs)
src/main.rs:419:3: 419:37 help: run `rustc --explain E0277` to see a detailed explanation
src/main.rs:419:3: 419:37 help: the following implementations were found:
src/main.rs:419:3: 419:37 help: <MyStruct as core::clone::Clone> …Run Code Online (Sandbox Code Playgroud) 我已经使用 Firebase 设置了用户登录流程,现在正在尝试保护页面在用户未登录时不被访问。从Firebase 文档中,我知道我可以使用 跟踪用户登录状态onAuthStateChanged,但我不能确定该函数中应包含哪些内容,以便我能够识别用户是否从路由防护登录。如何使用 跟踪登录状态onAuthStateChanged?
编辑:
更具体地说,我不确定在onAuthStateChanged被调用时如何引导路由器。我尝试调用注入的路由器
@Component({
selector: 'app-root',
templateUrl: 'app.component.html'
})
export class AppComponent {
constructor(
private afAuth: AngularFireAuth,
private router: Router,
) {
this.afAuth.auth.onAuthStateChanged(function(user) {
if (user) {
this.router.navigate('home');
} else {
this.router.navigate('login');
}
});
}
}
Run Code Online (Sandbox Code Playgroud)
但是当onAuthStateChanged调用时,我收到一条错误,指出this.router未定义。
我上传了一个带有 Play 应用签名的 Android 应用,现在正在尝试获取它的 SHA-1 和 SHA-256 指纹。
Google 的文档指出,您可以在 Google Play Console 的“发布”>“设置”>“应用程序完整性”页面上找到指纹,但据我所知,该页面不存在。
我一直在寻找使用棱镜/模式在clojure中进行打字和文档编制,但我无法找到它的全面文档.github自述文件提供了一些有用的基本用法信息,但是给我留下了许多未解决的问题(例如,为什么你需要(s/one s/str"s"中的"s"参数).有没有人知道棱镜模式的全面教程或文档来源?
我有大量数据(大小大于 500kB),但始终小于 1MB。我可以将这些 blob 存储在 Cloud Storage 之类的地方,但直接从 Firestore 读取/写入它们会方便得多。
Firestore 可以容纳最大 1MB 的文档,因此我的 blob 将适合 Firestore 文档,但Firestore 文档还指出:
Firestore 针对存储大量小文档进行了优化。
这让我认为读取和写入接近 1MB 限制的大量文档会对 Firestore 的性能产生负面影响,从而减慢对其他不相关小文档的访问速度。是这样吗?
firebase ×2
rust ×2
android ×1
angular ×1
c ×1
c++ ×1
clojure ×1
ffi ×1
google-play ×1
javascript ×1