前提
- Clion使用的msvc工具链
编译Botan
py configure.py --cc=msvc --os=windows --cpu=x86 --amalgamation --disable-shared
代码
# CMakeLists.txt
cmake_minimum_required(VERSION 3.22)
project(untitled13)
set(CMAKE_CXX_STANDARD 23)
# 必须的,不然报错
link_libraries(ws2_32 wsock32)
# pkcs11.h pkcs11f.h pkcs11t.h 这三个非必要引入,但是也要拷贝过去。文件在这个目录:\build\include\external
add_executable(untitled13 main.cpp
botan_all.h botan_all.cpp
)
# 使用/bigobj GNU compiler 要用 -Wa,-mbig-obj 选项
target_compile_options(untitled13
PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:/bigobj>
$<$<CXX_COMPILER_ID:GNU>:-Wa,-mbig-obj>)
//main.cpp
#include "iostream"
#include <string>
#include "botan_all.h"
#pragma comment (lib, "crypt32")
int main()
{
system("chcp 65001");//非必须 将