Search code examples
c++cmakelinker-errorschromium-embeddedmicrosoft-runtime-library

CEF - Build tests with MDd


I'm currently trying to implement a software that is based on the Chromium Embedded Framework (CEF).

The platform I'm aiming at is windows and I'm using the latest version from the CEF Automated builds (as of the date of this post).

Due to compatibility reasons with other projects, I need to specify the runtime library as /MDd and /MD for Debug and Release, respectively and decided to test-build the provided examples. I've also used the make routines as indicated in the CEF guide.

To do so, I've changed the file cef_variables.cmake. In particular, I've changed the CEF_COMPILER_FLAGS_DEBUG and CEF_COMPILER_FLAGS_RELEASE to

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
)

The default flags are /MTd and /MT.

When using the default flags there seems to be no issue and both the libcef_dll_wrapper and the cefclient projects compile just fine.

However, when using the altered flags, I'm only able to build the libcef_dll_wrapper while building cefclient throws the following linker error

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) 

The output from the cmake command is

-- 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

What am I missing here? I thought that if I altered the macro variables, all the projects would be built using the same settings and thus compile without errors.


Solution

  • I've continued researching and I've found that when using the automated builds, it uses the official cef_sandbox.lib, which uses the /MTd and /MT runtime.

    My fix was to change the macro_variables and set USE_SANDBOX as OFF. I've still have some errors but now the cefclient compile correctly