【发布时间】:2020-04-28 16:22:51
【问题描述】:
我正在尝试构建pe-parse 库来做一些事情。我的桌面上安装了 Visual Studio 2019 和 cmake。 pe-parse library git 说用下面的命令编译库。
# Compile 64-bit binaries with Visual Studio 2017
cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_BUILD_TYPE=Release ..
# Compile 32-bit binaries with Visual Studio 2017
cmake -G "Visual Studio 15 2017" -DCMAKE_BUILD_TYPE=Release ..
我只有 Visual Studio 2019,所以我用 cmake -G "Visual Studio 16 2019" -DCMAKE_BUILD_TYPE=Release .. 编译。但是,库是为 64 位计算机编译的,所以如果我尝试在 x86 中使用,它会显示该库是针对 x64 的,并且失败并显示以下消息。
1>main.obj : error LNK2019: unresolved external symbol "struct peparse::_parsed_pe * __cdecl peparse::ParsePEFromFile(char const *)" (?ParsePEFromFile@peparse@@YAPAU_parsed_pe@1@PBD@Z) referenced in function _main
1>lib\pe-parser-library.lib : warning LNK4272: library machine type 'x64' conflicts with target machine type 'x86'
1>C:\Workspace\Windows\CPP\MalwareAnalysis\Debug\MalwareAnalysis.exe : fatal error LNK1120: 1 unresolved externals
我已经安装了 MSVC v141 - VS2107 C++ x64/x86 构建工具(v14.16),但cmake -G "Visual Studio 15 2017" -DCMAKE_BUILD_TYPE=Release .. 在下面显示错误。
CMake Error at CMakeLists.txt:2 (project):
Generator
Visual Studio 15 2017
could not find any instance of Visual Studio.
是否必须安装 Visual Studio 2017 才能为 x86 系统构建库?
【问题讨论】:
标签: c++ visual-studio cmake static-libraries