- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在尝试使用来自库 https://github.com/trusch/libbcrypt 的 crypt blowfish 项目的 c 包装器还有一个 cpp 包装器围绕两个文件 bcrypt.c 和 bcrypt.h。我从源代码创建了一个 bcryptcpp.lib,但是当将它们与可执行文件一起使用时,我得到了 undefined symbol 错误。这是我的 cmakelists.txt -
# BCrypt CPP
enable_language(ASM)
set(CMAKE_ASM_FLAGS "${CXXFLAGS} -x assembler-with-cpp")
include_directories( ${CMAKE_CURRENT_SOURCE_DIR})
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/crypt_blowfish-1.3)
set(BCRYPT_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/BCrypt.hpp
${CMAKE_CURRENT_SOURCE_DIR}/BCrypt.cpp
${CMAKE_CURRENT_SOURCE_DIR}/WinBCrypt.hpp
${CMAKE_CURRENT_SOURCE_DIR}/bcrypt.c
${CMAKE_CURRENT_SOURCE_DIR}/bcrypt.h
${CMAKE_CURRENT_SOURCE_DIR}/crypt_blowfish-1.3/crypt_blowfish.c
${CMAKE_CURRENT_SOURCE_DIR}/crypt_blowfish-1.3/crypt_blowfish.h
${CMAKE_CURRENT_SOURCE_DIR}/crypt_blowfish-1.3/crypt_gensalt.c
${CMAKE_CURRENT_SOURCE_DIR}/crypt_blowfish-1.3/crypt_gensalt.h
${CMAKE_CURRENT_SOURCE_DIR}/crypt_blowfish-1.3/wrapper.c
${CMAKE_CURRENT_SOURCE_DIR}/crypt_blowfish-1.3/x86.S
)
add_library(bcryptcpp
STATIC
${BCRYPT_SOURCES})
set_target_properties(bcryptcpp
PROPERTIES
VERSION "${PROJECT_VERSION}"
PUBLIC_HEADER BCrypt.hpp
LINKER_LANGUAGE CXX
FOLDER "BCrypt"
)
visual studio生成的bcryptcpp.lib只有2kb。会不会是c文件没有编译?这可能是什么问题?
错误如下,编译测试可执行文件时生成,该可执行文件仅包含上述库链接中的 3 个 header (BCrypt.hpp、BCrypt.cpp、winbcrypt.h)-
Severity Code Description Project File Line Suppression State
Error LNK1120 3 unresolved externals BCryptTest C:\Program Files (x86)\Horizon\test\Debug\BCryptTest.exe 1
Error LNK2019 unresolved external symbol _bcrypt_gensalt referenced in function "public: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl BCrypt::generateHash(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,int)" (?generateHash@BCrypt@@SA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV23@H@Z) BCryptTest C:\Users\sagun\horizon-cpp\build\src\Tests\BCryptTest.obj 1
Error LNK2019 unresolved external symbol _bcrypt_hashpw referenced in function "public: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl BCrypt::generateHash(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,int)" (?generateHash@BCrypt@@SA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV23@H@Z) BCryptTest C:\Users\sagun\horizon-cpp\build\src\Tests\BCryptTest.obj 1
Error LNK2019 unresolved external symbol _bcrypt_checkpw referenced in function "public: static bool __cdecl BCrypt::validate_password(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?validate_password@BCrypt@@SA_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0@Z) BCryptTest C:\Users\sagun\horizon-cpp\build\src\Tests\BCryptTest.obj 1
dumpbin/EXPORTS bcryptcpp.lib
的输出显示没有导出,所以我猜它编译错误 -
Dump of file bcryptcpp.lib
File Type: LIBRARY
Summary
20 .chks64
43C .debug$S
74 .debug$T
30 .drectve
最佳答案
为了了解问题的原因(CMakeLists.txt 或另一个项目中的错误链接)您需要检查您的.lib 文件。尝试通过 dumpbin 在 bcryptcpp.lib 中查找导出符号.打开可视命令控制台并运行下一个命令:
dumpbin /EXPORTS bcryptcpp.lib
如果您将在 exports header 下看到您的函数,则表示您的库已正确编译,您需要检查库架构(x86、x64) - 也许您将错误的库链接到您的另一个项目。
在另一种情况下,CMakeLists.txt 中的问题。
关于c++ - add_library 没有使用 c 源代码创建 .lib,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54825815/
我想弄清楚 this 到底是什么行是在这个 github json 项目的 cmake 文件中, add_library(${NLOHMANN_JSON_TARGET_NAME} INTERFACE)
我正在尝试运行 cmake 来生成 makefile。在最小的工作示例中,我有三个文件和 1 个构建目录。 文件 1 是 CMakeLists.txt,其中包含: add_library (MathF
我正在设计一组可以在我的其他 C++ 项目中链接的库。为了使馆藏易于使用,我希望能够链接到各个图书馆,或者链接到一个包含所有其他图书馆的主图书馆。我如何在 CMakeLists.txt 文件中指定它?
我正在使用 CMake add_library 命令构建一个共享库,如下所示: add_library(mylibname OPTION SHARED SOURCES ${source_files}
我在 github 上编写/维护了一个小型单元测试库 https://github.com/acgreek/ExtremeCUnit使用 cmake 构建。您可以在 checkout 后通过“cmak
我正在使用 add_library 在 CMAKE 中导入静态库.lib 导入正常。但我也想验证这一点。所以我这样做: add_library(MYLIB STATIC IMPORTED) set_t
我有一个只有标题的库项目。在我的 CMakeLists.txt 我使用 INTERFACE 库类型 我想将此项目导入 CLion,但是当我打开任何头文件时,IDE 会提示 此文件不属于任何项目目标 那
库至少需要 cpp14,但如果 cpp17 可用,它会解锁更多功能。我尝试了以下。 cmake_minimum_required(VERSION 3.10) project(dummy) add_li
我正在尝试使用来自库 https://github.com/trusch/libbcrypt 的 crypt blowfish 项目的 c 包装器还有一个 cpp 包装器围绕两个文件 bcrypt.c
TLDR: 我想让 CMake 等待 ExternalProject_Add 完成,然后再尝试移动到下一个子目录并构建一个恰好使用一个的库外部项目的文件。换句话说,我喜欢将外部项目声明为共享库的依赖项
Windows 64bit使用cmake编译c++项目:github.com/iHateInventNames/synergy-through-usb 我在这篇文章中修复了之前的一个问题:Compil
我有一个使用 CMake 作为构建工具的项目,并为我和我的同事制作了一个简单的模板。当我在网上搜索最佳且易于使用的实践时,我遇到了创建库的不同方法。 在这个模板中,我在两个单独的变量中列出了头文件和源
我正在尝试从一组 .cs 文件构建 CSharp DLL。我使用 add_library() 函数添加源文件(.cs 文件)。但它发出警告,如“add_library for library libn
我将我的凭据 key 存储在一个 cpp 原生文件中并使用 CMake 构建然后将其链接到我的应用程序: 当前代码: 我的 src/main/cpp/credentials-provider-dev.
CMake是2.8.8在编译时引入了OBJECT库类型:add_library(OBJECT)。这是一个有用的构造,能够将所有类编译为 .o 文件,但还没有将它们添加到库中。 但是,我不确定它最终附加
使用语句的目的是什么: add_library( [SHARED|STATIC] IMPORTED) 根据我的发现,即使您在上面创建了一个导入的库目标,您仍然需要指定实际 .so 或 .a 的具体位置
我正在学习 CMake,但有点吃力。我的“项目”正在使用以一个 .cpp 文件和两个 .h 文件的形式提供的 JsonCpp“库”。结构如下所示: myProject build/ j
我正在尝试为所有具有特定结尾的文件调用 add_library。 目录结构是: src | - CMakeLists.txt (1) | - main.cpp | - gui | -
我们使用 CMake 和普通的 Unix 生成文件进行构建。有一些静态分析检查,例如Cppcheck ,我们在项目中的每个 C/C++ 文件中运行以在编译时捕获错误。 我为 cppcheck 创建了一
我想向我在 Windows 7 中使用 Visual Studio 2013 Update 2 的 cmake 项目添加一个仅 header 目录。我做了一些研究并提出了这个 Cmakelists.t
我是一名优秀的程序员,十分优秀!