首页 > 解决方案 > 为什么使用调试进行构建但发布没有?

问题描述

我能够在 Cyclone DDS 中使用 Debug/x64 构建示例(输出类型为 DLL ),我需要在 Release/X64 中构建它们,当我打开示例代码时,两个构建都显示相同的 3 个错误,但构建总是成功, (VS2017)

但在调试中,输出 DLL 工作正常,在发布 DLL 中不起作用

在此处输入图像描述

Severity    Code    Description Project File    Line    Suppression State
Error (active)  E1097   unknown attribute "no_init_all"  
ddscxxHelloworldSubscriberDLL   C:\Program Files (x86)\Windows 
Kits\10\Include\10.0.19041.0\um\winnt.h 3901    

Severity    Code    Description Project File    Line    Suppression State
Error (active)  E0090   function returning function is not allowed   
ddscxxHelloworldSubscriberDLL

C:\Users\king\Downloads\DDS_2017_Build\cyclonedds_cxx_ins_dir_2017\include\ddscxx\dds\sub\detail\TDataReaderImpl.hpp 186

Severity    Code    Description Project File    Line    Suppression State
Error (active)  E0090   function returning function is not allowed   
ddscxxHelloworldSubscriberDLL    

C:\Users\king\Downloads\DDS_2017_Build\cyclonedds_cxx_ins_dir_2017\include\ddscxx\dds\sub\detail\TDataReaderImpl.hpp 318

Github页面说

Note that the default build type is a release build with debug information included (RelWithDebInfo), 
which is generally the most convenient type of build to use from applications because of a good mix 
between performance and still being able to debug things. If you'd rather have a Debug or pure 
Release build, set CMAKE_BUILD_TYP

我遵循了默认安装,即 RelWithDebInfo

我应该使用 -DCMAKE_BUILD_TYP=RELEASE 构建 CyclonesDDS 安装,以便在 Release/x64 模式下构建示例代码吗?还是我应该修改示例代码?

发布 x64 版本的输出窗口

    ld All started: Project: ZERO_CHECK, Configuration: Release x64 ------
    2>------ Rebuild All started: Project: startClient, Configuration: Release x64 ------
    3>------ Rebuild All started: Project: startServer, Configuration: Release x64 ------
    1>Checking Build System
    4>------ Rebuild All started: Project: isocpp_idlpp, Configuration: Release x64 ------
    4>Building Custom Rule C:/Users/king/Downloads/DDS_2017_Build/cyclonedds_cxx_ins_dir_2017/DDS_3_15/helloworldDLLsource/CMakeLists.txt
    5>------ Rebuild All started: Project: ddscxxHelloWorldData_lib_idl_isocpp_generate, Configuration: Release x64 ------
    3>startServer.cpp
    2>startClient.cpp
    3>   Creating library C:\Users\king\Downloads\DDS_2017_Build\cyclonedds_cxx_ins_dir_2017\DDS_3_15\DDS_DLL_PROJECT_2017\x64\Release\startServer.lib and object C:\Users\king\Downloads\DDS_2017_Build\cyclonedds_cxx_ins_dir_2017\DDS_3_15\DDS_DLL_PROJECT_2017\x64\Release\startServer.exp
    3>Generating code
    3>All 14 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
    3>Finished generating code
    2>   Creating library C:\Users\king\Downloads\DDS_2017_Build\cyclonedds_cxx_ins_dir_2017\DDS_3_15\DDS_DLL_PROJECT_2017\x64\Release\startClient.lib and object C:\Users\king\Downloads\DDS_2017_Build\cyclonedds_cxx_ins_dir_2017\DDS_3_15\DDS_DLL_PROJECT_2017\x64\Release\startClient.exp
    2>Generating code
    2>All 14 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
    2>Finished generating code
    3>startServer.vcxproj -> C:\Users\king\Downloads\DDS_2017_Build\cyclonedds_cxx_ins_dir_2017\DDS_3_15\DDS_DLL_PROJECT_2017\x64\Release\startServer.exe
    5>Running isocpp_idlpp on HelloWorldData.idl
    2>startClient.vcxproj -> C:\Users\king\Downloads\DDS_2017_Build\cyclonedds_cxx_ins_dir_2017\DDS_3_15\DDS_DLL_PROJECT_2017\x64\Release\startClient.exe
    5>Compiling C:\Users\king\Downloads\DDS_2017_Build\cyclonedds_cxx_ins_dir_2017\DDS_3_15\helloworldDLLsource\HelloWorldData.idl
    5>Building Custom Rule C:/Users/king/Downloads/DDS_2017_Build/cyclonedds_cxx_ins_dir_2017/DDS_3_15/helloworldDLLsource/CMakeLists.txt
    5>ANTLR Tool version 4.4 used for code generation does not match the current runtime version 4.5ANTLR Tool version 4.4 used for code generation does not match the current runtime version 4.5
    6>------ Rebuild All started: Project: ddscxxHelloworldPublisherDLL, Configuration: Release x64 ------
    7>------ Rebuild All started: Project: ddscxxHelloworldSubscriberDLL, Configuration: Release x64 ------
    7>Building Custom Rule C:/Users/king/Downloads/DDS_2017_Build/cyclonedds_cxx_ins_dir_2017/DDS_3_15/helloworldDLLsource/CMakeLists.txt
    6>Building Custom Rule C:/Users/king/Downloads/DDS_2017_Build/cyclonedds_cxx_ins_dir_2017/DDS_3_15/helloworldDLLsource/CMakeLists.txt
    7>subscriber.cpp
    6>publisher.cpp
    6>HelloWorldData.cpp
    7>HelloWorldData.cpp
    6>HelloWorldDataSplDcps.cpp
    7>HelloWorldDataSplDcps.cpp
    7>Generating Code...
    6>Generating Code...
    7>HelloWorldData-cyclone.c
    6>HelloWorldData-cyclone.c
    7>   Creating library C:/Users/king/Downloads/DDS_2017_Build/cyclonedds_cxx_ins_dir_2017/DDS_3_15/DDS_DLL_PROJECT_2017/Release/ddscxxHelloworldSubscriberDLL.lib and object C:/Users/king/Downloads/DDS_2017_Build/cyclonedds_cxx_ins_dir_2017/DDS_3_15/DDS_DLL_PROJECT_2017/Release/ddscxxHelloworldSubscriberDLL.exp
    6>   Creating library C:/Users/king/Downloads/DDS_2017_Build/cyclonedds_cxx_ins_dir_2017/DDS_3_15/DDS_DLL_PROJECT_2017/Release/ddscxxHelloworldPublisherDLL.lib and object C:/Users/king/Downloads/DDS_2017_Build/cyclonedds_cxx_ins_dir_2017/DDS_3_15/DDS_DLL_PROJECT_2017/Release/ddscxxHelloworldPublisherDLL.exp
    7>ddscxxHelloworldSubscriberDLL.vcxproj -> C:\Users\king\Downloads\DDS_2017_Build\cyclonedds_cxx_ins_dir_2017\DDS_3_15\DDS_DLL_PROJECT_2017\Release\ddscxxHelloworldSubscriberDLL.dll
    6>ddscxxHelloworldPublisherDLL.vcxproj -> C:\Users\king\Downloads\DDS_2017_Build\cyclonedds_cxx_ins_dir_2017\DDS_3_15\DDS_DLL_PROJECT_2017\Release\ddscxxHelloworldPublisherDLL.dll
    8>------ Skipped Rebuild All: Project: ALL_BUILD, Configuration: Release x64 ------
    8>Project not selected to build for this solution configuration 
    ========== Rebuild All: 7 succeeded, 0 failed, 1 skipped ==========

标签: c++debuggingdllbuildrelease

解决方案


推荐阅读