fix: build on windows
This commit is contained in:
parent
5f28bb4dc6
commit
ccff2dde9a
2
.gitignore
vendored
2
.gitignore
vendored
@ -7,3 +7,5 @@ ncmdump
|
|||||||
build
|
build
|
||||||
|
|
||||||
cmake-build-*
|
cmake-build-*
|
||||||
|
|
||||||
|
vcpkg_installed
|
@ -5,6 +5,7 @@ project(ncmdump LANGUAGES CXX)
|
|||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
|
find_package(ZLIB)
|
||||||
find_package(TagLib REQUIRED)
|
find_package(TagLib REQUIRED)
|
||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
@ -33,6 +34,24 @@ if(WIN32)
|
|||||||
${WIN_SOURCES}
|
${WIN_SOURCES}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
# 强制所有配置(Debug/Release 等)使用静态 C 运行时库
|
||||||
|
foreach(flag_var
|
||||||
|
CMAKE_CXX_FLAGS
|
||||||
|
CMAKE_C_FLAGS
|
||||||
|
CMAKE_CXX_FLAGS_DEBUG
|
||||||
|
CMAKE_CXX_FLAGS_RELEASE
|
||||||
|
)
|
||||||
|
if(${flag_var})
|
||||||
|
string(REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
target_include_directories(ncmdump_lib PRIVATE src/include)
|
||||||
|
|
||||||
|
target_compile_definitions(ncmdump_exec PRIVATE TAGLIB_STATIC)
|
||||||
|
|
||||||
set_target_properties(ncmdump_lib PROPERTIES OUTPUT_NAME "libncmdump")
|
set_target_properties(ncmdump_lib PROPERTIES OUTPUT_NAME "libncmdump")
|
||||||
|
|
||||||
target_link_libraries(ncmdump_lib TagLib::tag)
|
target_link_libraries(ncmdump_lib TagLib::tag)
|
||||||
@ -49,6 +68,7 @@ endif()
|
|||||||
set_target_properties(ncmdump_exec PROPERTIES OUTPUT_NAME "ncmdump")
|
set_target_properties(ncmdump_exec PROPERTIES OUTPUT_NAME "ncmdump")
|
||||||
target_include_directories(ncmdump_exec PRIVATE src/include)
|
target_include_directories(ncmdump_exec PRIVATE src/include)
|
||||||
|
|
||||||
|
# link to taglib
|
||||||
target_link_libraries(ncmdump_exec TagLib::tag)
|
target_link_libraries(ncmdump_exec TagLib::tag)
|
||||||
|
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
14
README.md
14
README.md
@ -79,20 +79,18 @@ git clone https://github.com/taurusxin/ncmdump.git
|
|||||||
|
|
||||||
使用 CMake 配置项目。Windows 下若使用 GNU 套件,推荐使用 [msys2](https://www.msys2.org/) 或者 [winlibs](https://winlibs.com/)
|
使用 CMake 配置项目。Windows 下若使用 GNU 套件,推荐使用 [msys2](https://www.msys2.org/) 或者 [winlibs](https://winlibs.com/)
|
||||||
|
|
||||||
注意:从 1.6 版本开始,CMake 构建不再依赖于 gitsubmodule,因此无需再克隆 `taglib` 仓库,改为使用系统的 taglib 库,针对不同系统上的构建,请参照如下方法
|
注意:从 1.6 版本开始,CMake 构建不再依赖于 gitmodule,因此无需再克隆 `taglib` 仓库,改为使用系统的 taglib 库,针对不同系统上的构建,请参照如下方法
|
||||||
|
|
||||||
### Windows
|
### Windows
|
||||||
|
|
||||||
Windows 下,你可以使用 vcpkg 来安装 taglib 库,或者手动下载 taglib 的源码,并使用 CMake 来构建 taglib 库
|
Windows 下,首先使用 vcpkg 来安装 taglib 库,或者手动下载 taglib 的源码,参照[官方文档](https://github.com/taglib/taglib/blob/master/INSTALL.md#building-taglib-msvc)使用 CMake 来构建 taglib 库,当然还需要额外安装依赖。当然首选还是推荐使用 vcpkg 来管理依赖。
|
||||||
|
|
||||||
vcpkg
|
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
# 安装 taglib 库
|
# 安装 taglib 的静态库
|
||||||
vcpkg install taglib:x64-windows
|
vcpkg install taglib:x64-windows-static
|
||||||
|
|
||||||
# 配置项目
|
# 配置项目,替换 %VCPKG_ROOT% 为你的 vcpkg 安装路径
|
||||||
cmake -DCMAKE_TOOLCHAIN_FILE=%VCPKG_ROOT%\scripts\vcpkg.cmake -B build
|
cmake -DCMAKE_TOOLCHAIN_FILE=%VCPKG_ROOT%/scripts/buildsystems/vcpkg.cmake -B build
|
||||||
|
|
||||||
# 编译项目
|
# 编译项目
|
||||||
cmake --build build -j 8 --config Release
|
cmake --build build -j 8 --config Release
|
||||||
|
@ -25,15 +25,16 @@ const unsigned char NeteaseCrypt::mPng[8] = {0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A,
|
|||||||
|
|
||||||
static void aesEcbDecrypt(const unsigned char *key, std::string &src, std::string &dst)
|
static void aesEcbDecrypt(const unsigned char *key, std::string &src, std::string &dst)
|
||||||
{
|
{
|
||||||
|
int i, n;
|
||||||
unsigned char out[16];
|
unsigned char out[16];
|
||||||
|
|
||||||
const int n = src.length() >> 4;
|
n = src.length() >> 4;
|
||||||
|
|
||||||
dst.clear();
|
dst.clear();
|
||||||
|
|
||||||
AES aes(key);
|
AES aes(key);
|
||||||
|
|
||||||
for (int i = 0; i < n - 1; i++)
|
for (i = 0; i < n - 1; i++)
|
||||||
{
|
{
|
||||||
aes.decrypt((unsigned char *)src.c_str() + (i << 4), out);
|
aes.decrypt((unsigned char *)src.c_str() + (i << 4), out);
|
||||||
dst += std::string((char *)out, 16);
|
dst += std::string((char *)out, 16);
|
||||||
|
7
vcpkg.json
Normal file
7
vcpkg.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"name": "ncmdump",
|
||||||
|
"version": "1.6.0",
|
||||||
|
"dependencies": [
|
||||||
|
"taglib"
|
||||||
|
]
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user