# Chromium Embedded Framework build

**URL:** <https://discourse.cmake.org/t/chromium-embedded-framework-build/12796>\
**Category:** Code\
**Tags:** os:windows\
**Created:** [October 18, 2024, 2:04am UTC](https://discourse.cmake.org/t/chromium-embedded-framework-build/12796 "2024-10-18T02:04:31Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sea\_Sea](https://discourse.cmake.org/user_avatar/discourse.cmake.org/sea_sea/32/4025_2.png) [@Sea\_Sea](https://discourse.cmake.org/u/Sea_Sea)\
**Post date:** [October 18, 2024, 2:04am UTC](https://discourse.cmake.org/t/chromium-embedded-framework-build/12796/1 "2024-10-18T02:04:31Z")

</div>

Using windows and vs2022 prompt.  
I try to download CEF binary distribution and build the libcef\_dll\_wrapper

I use [this](https://github.com/chromiumembedded/cef-project/blob/master/cmake/DownloadCEF.cmake) to download cef builds and command

```auto
cmake -G Ninja -S . -B build -DCMAKE_BUILD_TYPE="Release"

cmake --build build --target libcef_dll_wrapper --config Release

```

and it warn

```auto
libcef_dll_wrapper.lib(command_line_ctocpp.obj) : error LNK2038: Mismatched 'RuntimeLibrary' detected: 'MT_StaticRelease' value does not match 'MD_DynamicRelease' value (located in main.obj)

```

I try to set and clean, it still warn.

```auto
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MD")  
# or
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MT")  

```

What do I miss?

[https://cef-builds.spotifycdn.com/index.html](https://cef-builds.spotifycdn.com/index.html)

> **[GitHub - chromiumembedded/cef-project: Chromium Embedded Framework (CEF) sample project...](https://github.com/chromiumembedded/cef-project)**
>
> Chromium Embedded Framework (CEF) sample project official mirror.

---

<div class="post-metadata">

**Author:** ![retif](https://discourse.cmake.org/user_avatar/discourse.cmake.org/retif/32/1776_2.png) [@retif](https://discourse.cmake.org/u/retif)\
**Post date:** [October 18, 2024, 8:22am UTC](https://discourse.cmake.org/t/chromium-embedded-framework-build/12796/2 "2024-10-18T08:22:03Z")

</div>

The CEF project file semi-hardcodes MSVC runtime flag in `CEF_RUNTIME_LIBRARY_FLAG` cache variable (_in `./cmake/cef_variables.cmake`_), so you might want to patch that. Or provide desired value with `-D` on configuration.

---

<div class="post-metadata">

**Author:** ![Sea\_Sea](https://discourse.cmake.org/user_avatar/discourse.cmake.org/sea_sea/32/4025_2.png) [@Sea\_Sea](https://discourse.cmake.org/u/Sea_Sea)\
**Post date:** [October 18, 2024, 9:45am UTC](https://discourse.cmake.org/t/chromium-embedded-framework-build/12796/3 "2024-10-18T09:45:07Z")

</div>

I found the default is using /MT

And I use this to build the library

```auto
cmake -G Ninja -S . -B build -DCMAKE_BUILD_TYPE="Release"
cmake --build build --target libcef_dll_wrapper --config Release

```

And link it with my project

```auto
add_executable(test ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp )
target_link_libraries(test PUBLIC ${CEF_LIBRARIES})

```

```auto
libcpmt.lib(StlLCMapStringA.obj) : error LNK2038: Mismatched 'RuntimeLibrary' detected: 'MT_StaticRelease' value does not match 'MD_DynamicRelease' value (located in base_client_handler.cc.obj)
   Building library tests\cefclient\cefclient.lib and object tests\cefclient\cefclient.exp
LINK : warning LNK4098

```

do you know why it use MD\_DynamicRelease?  
I alreay check the cef lib build with /MT

---

<div class="post-metadata">

**Author:** ![retif](https://discourse.cmake.org/user_avatar/discourse.cmake.org/retif/32/1776_2.png) [@retif](https://discourse.cmake.org/u/retif)\
**Post date:** [October 18, 2024, 10:03am UTC](https://discourse.cmake.org/t/chromium-embedded-framework-build/12796/4 "2024-10-18T10:03:07Z")

</div>

So it would seem that your project is using `MD_DynamicRelease`, wouldn’t it? Then you either set the same value on configuring CEF or set the CEF value on your project configuration. But what I would do is delete that entire block from CEF project file, as one rarely needs to hardcode MSVC runtime linking type, especially given that one’s project might be used in other people projects.

---

<div class="post-metadata">

**Author:** ![Sea\_Sea](https://discourse.cmake.org/user_avatar/discourse.cmake.org/sea_sea/32/4025_2.png) [@Sea\_Sea](https://discourse.cmake.org/u/Sea_Sea)\
**Post date:** [October 19, 2024, 1:23am UTC](https://discourse.cmake.org/t/chromium-embedded-framework-build/12796/5 "2024-10-19T01:23:35Z")

</div>

you are right.

If I build cef lib with /MT and link it to my project that build with vs2022.  
Follow this [message](https://stackoverflow.com/questions/28887001/lnk2038-mismatch-detected-for-runtimelibrary-value-mt-staticrelease-doesn), the linker setting in your Visual Studio project are set to dynamically link (meaning the link will occur during runtime, usually with a .dll file).

But I create my project with cmake project, so I don’t have the IDE to set the Runtime Library.  
Do you have the recommend cmake command to set the Runtime Library to static on my project ?

---

<div class="post-metadata">

**Author:** ![retif](https://discourse.cmake.org/user_avatar/discourse.cmake.org/retif/32/1776_2.png) [@retif](https://discourse.cmake.org/u/retif)\
**Post date:** [October 19, 2024, 10:39am UTC](https://discourse.cmake.org/t/chromium-embedded-framework-build/12796/6 "2024-10-19T10:39:34Z")

</div>

> But I create my project with cmake project

Your question wouldn’t belong to this forum otherwise 🙂

> cmake command to set the Runtime Library

That can be done by setting [MSVC\_RUNTIME\_LIBRARY](https://cmake.org/cmake/help/latest/prop_tgt/MSVC_RUNTIME_LIBRARY.html) to an appropriate value. There are [several examples](https://discourse.cmake.org/search?q=MSVC_RUNTIME_LIBRARY) of this here already.

---

<div class="post-metadata">

**Author:** ![Sea\_Sea](https://discourse.cmake.org/user_avatar/discourse.cmake.org/sea_sea/32/4025_2.png) [@Sea\_Sea](https://discourse.cmake.org/u/Sea_Sea)\
**Post date:** [October 20, 2024, 1:33am UTC](https://discourse.cmake.org/t/chromium-embedded-framework-build/12796/7 "2024-10-20T01:33:27Z")

</div>

I have another question  
Is it possible for the two case

1. using `/MT` to build libcef\_dll\_wrapper.lib (static)
2. using `/MD` to build libcef\_dll\_wrapper.lib (static)

or  
It must be one by one  
/MT =\> generate static lib  
/MD =\> generate dynamic lib
