2

我目前正在尝试实现基于 Chromium Embedded Framework (CEF) 的软件。

我的目标平台是 windows,我使用的是 CEF 自动构建的最新版本(截至本文发布之日)。

由于与其他项目的兼容性原因,我需要将运行时库分别指定为/MDd/MD用于DebugRelease,并决定测试构建提供的示例。我还使用了 CEF 指南中指示的 make 例程。

为此,我更改了文件cef_variables.cmake。特别是,我已将CEF_COMPILER_FLAGS_DEBUGCEF_COMPILER_FLAGS_RELEASE更改为

list(APPEND CEF_COMPILER_FLAGS_DEBUG
     /MDd          # Multithreaded debug runtime
     /RTC1         # Disable optimizations
     /Od           # Enable basic run-time checks
)
list(APPEND CEF_COMPILER_FLAGS_RELEASE
     /MD           # Multithreaded release runtime
     /O2           # Optimize for maximum speed
     /Ob2          # Inline any suitable function
     /GF           # Enable string pooling
)

默认标志是/MTd/MT

使用默认标志时似乎没有问题,并且libcef_dll_wrappercefclient项目都编译得很好。

但是,当使用更改的标志时,我只能构建libcef_dll_wrapper而构建cefclient会引发以下链接器错误

Severity    Code    Description Project File    Line    Suppression State
Error   LNK2038 mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in binding_test.obj  cefclient   D:\Workspace\CEF\build\tests\cefclient\cef_sandbox.lib(at_exit.obj) 

cmake 命令的输出是

-- The C compiler identification is MSVC 19.0.24215.1
-- The CXX compiler identification is MSVC 19.0.24215.1
-- Check for working C compiler: D:/Program Files (x86)/Microsoft Visual Studio                                                                                                                                                                                                14.0/VC/bin/cl.exe
-- Check for working C compiler: D:/Program Files (x86)/Microsoft Visual Studio                                                                                                                                                                                                14.0/VC/bin/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: D:/Program Files (x86)/Microsoft Visual Studi                                                                                                                                                                                               o 14.0/VC/bin/cl.exe
-- Check for working CXX compiler: D:/Program Files (x86)/Microsoft Visual Studi                                                                                                                                                                                               o 14.0/VC/bin/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- *** CEF CONFIGURATION SETTINGS ***
-- Generator:                    Visual Studio 14 2015
-- Platform:                     Windows
-- Project architecture:         x86
-- Binary distribution root:     D:/Workspace/CEF
-- CEF Windows sandbox:          ON
-- Visual Studio ATL support:    ON
-- Standard libraries:           comctl32.lib;rpcrt4.lib;shlwapi.lib;ws2_32.lib;                                                                                                                                                                                               dbghelp.lib;psapi.lib;version.lib;winmm.lib
-- Compile defines:              __STDC_CONSTANT_MACROS;__STDC_FORMAT_MACROS;WIN                                                                                                                                                                                               32;_WIN32;_WINDOWS;UNICODE;_UNICODE;WINVER=0x0601;_WIN32_WINNT=0x601;NOMINMAX;WI                                                                                                                                                                                               N32_LEAN_AND_MEAN;_HAS_EXCEPTIONS=0;PSAPI_VERSION=1;CEF_USE_SANDBOX;CEF_USE_ATL
-- Compile defines (Debug):
-- Compile defines (Release):    NDEBUG;_NDEBUG
-- C compile flags:              /MP;/Gy;/GR-;/W4;/WX;/wd4100;/wd4127;/wd4244;/w                                                                                                                                                                                               d4481;/wd4512;/wd4701;/wd4702;/wd4996;/Zi
-- C compile flags (Debug):      /MDd;/RTC1;/Od
-- C compile flags (Release):    /MD;/O2;/Ob2;/GF
-- C++ compile flags:            /MP;/Gy;/GR-;/W4;/WX;/wd4100;/wd4127;/wd4244;/w                                                                                                                                                                                               d4481;/wd4512;/wd4701;/wd4702;/wd4996;/Zi
-- C++ compile flags (Debug):    /MDd;/RTC1;/Od
-- C++ compile flags (Release):  /MD;/O2;/Ob2;/GF
-- Exe link flags:                /MANIFEST:NO;/LARGEADDRESSAWARE
-- Exe link flags (Debug):       /DEBUG
-- Exe link flags (Release):
-- Shared link flags:
-- Shared link flags (Debug):    /DEBUG
-- Shared link flags (Release):
-- CEF Binary files:             chrome_elf.dll;d3dcompiler_43.dll;d3dcompiler_4                                                                                                                                                                                               7.dll;libcef.dll;libEGL.dll;libGLESv2.dll;natives_blob.bin;snapshot_blob.bin
-- CEF Resource files:           cef.pak;cef_100_percent.pak;cef_200_percent.pak                                                                                                                                                                                               ;cef_extensions.pak;devtools_resources.pak;icudtl.dat;locales
-- Configuring done
-- Generating done
-- Build files have been written to: D:/Workspace/CEF/build

我在这里想念什么?我认为如果我更改宏变量,所有项目都将使用相同的设置构建,因此编译时不会出错。

4

1 回答 1

2

我继续研究,发现在使用自动构建时,它使用官方的cef_sandbox.lib,它使用/MTd/MT运行时。

我的解决方法是更改​​ macro_variables并将USE_SANDBOX设置为OFF。我仍然有一些错误,但现在cefclient编译正确

于 2017-10-10T11:02:01.617 回答