Debugging 如何在Windows下支持grpc的调试和发布版本
遵循源文档中的grpc版本,并使用默认的Win32发布目标安装了grpc的系统范围版本。在调试模式下编译客户机/服务器时,我发现链接器不匹配(MD_dynamiccrease与MDd_DynamicDebug不匹配) 但是,当我构建并安装Win32调试目标时,安装程序会用相同的名称覆盖发行版库,因此我会遇到与所有发行版客户端/服务器代码无法链接相反的问题Debugging 如何在Windows下支持grpc的调试和发布版本,debugging,grpc,release,Debugging,Grpc,Release,遵循源文档中的grpc版本,并使用默认的Win32发布目标安装了grpc的系统范围版本。在调试模式下编译客户机/服务器时,我发现链接器不匹配(MD_dynamiccrease与MDd_DynamicDebug不匹配) 但是,当我构建并安装Win32调试目标时,安装程序会用相同的名称覆盖发行版库,因此我会遇到与所有发行版客户端/服务器代码无法链接相反的问题 创建和部署grpc发布版和调试版的正确方法是什么?我面临着同样的问题,我看到了至少两种可能的解决方案: 使用(或几乎等效的方法),即通过add
创建和部署grpc发布版和调试版的正确方法是什么?我面临着同样的问题,我看到了至少两种可能的解决方案:
add_子目录
命令将grpc代码直接添加到CMakeLists.txt中。这是最简单的方法,因为CMake将基于当前构建类型链接approprate C运行时库;但是,您将在项目树中找到所有grpc代码和目标
CMake_PREFIX_PATH
变量设置为调试或刚刚生成的Release grpc安装文件夹的位置。如果在Visual Studio中使用CMake集成,可以在CMakeSettings.json
文件中添加CMake_PREFIX_PATH
变量的正确定义,如下所示
{
"configurations": [
{
"name": "x64-Debug",
"generator": "Ninja",
"configurationType": "Debug",
"inheritEnvironments": [ "msvc_x64_x64" ],
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "-DCMAKE_PREFIX_PATH=C:\\Dev\\grpc\\install\\x64\\Debug"
},
{
"name": "x64-Release",
"generator": "Ninja",
"configurationType": "RelWithDebInfo",
"inheritEnvironments": [ "msvc_x64_x64" ],
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "-DCMAKE_PREFIX_PATH=C:\\Dev\\grpc\\install\\x64\\Release"
}
]
}
{
"configurations": [
{
"name": "x64-Debug",
"generator": "Ninja",
"configurationType": "Debug",
"inheritEnvironments": [ "msvc_x64_x64" ],
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "-DCMAKE_PREFIX_PATH=C:\\Dev\\grpc\\install\\x64\\Debug"
},
{
"name": "x64-Release",
"generator": "Ninja",
"configurationType": "RelWithDebInfo",
"inheritEnvironments": [ "msvc_x64_x64" ],
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "-DCMAKE_PREFIX_PATH=C:\\Dev\\grpc\\install\\x64\\Release"
}
]
}