errors when building libcef_dll_wrapper with /MD

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

errors when building libcef_dll_wrapper with /MD

Postby jtesolin » Fri Apr 07, 2017 5:01 pm

Hi All,
My project (which I took over a few months ago) uses the /MD flag and pulls in the libcef_dll_wrapper built with that same flag. We currently have a build of the 2785 branch of CEF. I am attempting to upgrade to the 2987 branch of CEF, but I am having trouble linking the wrapper lib. The change I made to add the /MD flag is:
Code: Select all
diff --git a/BUILD.gn b/BUILD.gn
index ce91fb1..9d990b7 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -930,6 +930,7 @@ config("libcef_dll_wrapper_config") {
     # They will be copied to the include/ directory in the binary distribution.
     "$root_out_dir/includes",
   ]
+  cflags_cc = [ "/MD" ]
 }

 # libcef_dll_wrapper target.


I attached the errors I'm getting. Any help would be appreciated.
Attachments
log.txt
errors when i add the flag to the config
(53.1 KiB) Downloaded 383 times
jtesolin
Newbie
 
Posts: 5
Joined: Fri Apr 07, 2017 12:10 pm

Re: errors when building libcef_dll_wrapper with /MD

Postby Czarek » Sat Apr 08, 2017 4:24 am

You are applying /MD flag to all projects that depend on libcef_dll_wrapper, but you're not setting it on the libcef_dll_wrapper target itself. Try instead modifying cef/cmake/cef_variables.cmake.in - replace /MT with /MD (multiple places).
Maintainer of the CEF Python, PHP Desktop and CEF C API projects. My LinkedIn.
User avatar
Czarek
Virtuoso
 
Posts: 1927
Joined: Sun Nov 06, 2011 2:12 am

Re: errors when building libcef_dll_wrapper with /MD

Postby jtesolin » Mon Apr 10, 2017 5:25 pm

So, I reverted the build.gn change and made this change:
Code: Select all
diff --git a/cmake/cef_variables.cmake.in b/cmake/cef_variables.cmake.in
index 94b4b87..c7c509d 100644
--- a/cmake/cef_variables.cmake.in
+++ b/cmake/cef_variables.cmake.in
@@ -360,17 +360,17 @@ if(OS_WINDOWS)
     set(CMAKE_CXX_FLAGS_DEBUG "")

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

CEF then built successfully. I then tried to link the libraries into my project and received linking errors (see attachment 'project build log.txt'). Seeing these errors, I made the following change:
Code: Select all
diff --git a/BUILD.gn b/BUILD.gn
index ce91fb1..4ade9f9 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -947,6 +947,7 @@ static_library("libcef_dll_wrapper") {

   configs += [ ":libcef_dll_wrapper_config" ]
   public_configs = [ ":libcef_dll_wrapper_config" ]
+  cflags_cc = [ "/MD" ]
 }

Which, netted me errors when building CEF (see attachment 'wrapper only md build log.txt'). These errors seem to be related with building a consumer of the wrapper, so I moved the flag to the wrapper config:
Code: Select all
diff --git a/BUILD.gn b/BUILD.gn
index ce91fb1..9d990b7 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -930,6 +930,7 @@ config("libcef_dll_wrapper_config") {
     # They will be copied to the include/ directory in the binary distribution.
     "$root_out_dir/includes",
   ]
+  cflags_cc = [ "/MD" ]
 }

 # libcef_dll_wrapper target.

Which, should apply to the consumers of the wrapper and the wrapper, but now I am getting new errors when trying to build CEF (see attachment 'wrapper config set to build md log.txt'). Not sure what to do next. Any more ideas?
Attachments
wrapper config set to build md log.txt
wrapper and its consumers set to use md
(53.1 KiB) Downloaded 411 times
wrapper only md build log.txt
errors when building the wrapper with md
(32.46 KiB) Downloaded 403 times
project build log.txt
errors linking in cef
(23.79 KiB) Downloaded 389 times
jtesolin
Newbie
 
Posts: 5
Joined: Fri Apr 07, 2017 12:10 pm

Re: errors when building libcef_dll_wrapper with /MD

Postby Czarek » Mon Apr 10, 2017 11:45 pm

Enter cef/binary_distrib/... directory and check for "/MD" in cmake/cef_variables.cmake (no ".in").
Then follow the instructions in CMakeLists.txt to rebuild libcef_dll_wrapper.
Maintainer of the CEF Python, PHP Desktop and CEF C API projects. My LinkedIn.
User avatar
Czarek
Virtuoso
 
Posts: 1927
Joined: Sun Nov 06, 2011 2:12 am

Re: errors when building libcef_dll_wrapper with /MD

Postby jtesolin » Tue Apr 11, 2017 1:56 pm

I can't find that directory. I am following the instructions in https://bitbucket.org/chromiumembedded/ ... ckStart.md, because we have a few patches we need to make in chromium and CEF. Currently, I'm targeting --branch=2987. this is my update.bat:
Code: Select all
set CEF_USE_GN=1
set GN_DEFINES=is_win_fastlink=true
set GN_ARGUMENTS=--ide=vs2015 --sln=cef --filters=//cef/*
python D:\jtesolin\cef\automate\tools\automate\automate-git.py --download-dir=D:\jtesolin\cef\2987 --depot-tools-dir=D:\jtesolin\cef\depot_tools --no-distrib --no-build --branch=2987

this is my create.bat:
Code: Select all
set CEF_USE_GN=1
set GN_DEFINES=is_win_fastlink=true
set GN_ARGUMENTS=--ide=vs2015 --sln=cef --filters=//cef/*
call cef_create_projects.bat


The only build related change I've made is in cmake/cef_variables.cmake.in. I have attached the wrapper's ninja file that is used to build the obj files that my project is complaining about. It is specifying the /MT flag.
Attachments
libcef_dll_wrapper.ninja.txt
only cef_variables.cmake.in edited. added .txt extension, so it could be uploaded
(28.54 KiB) Downloaded 420 times
jtesolin
Newbie
 
Posts: 5
Joined: Fri Apr 07, 2017 12:10 pm

Re: errors when building libcef_dll_wrapper with /MD

Postby Czarek » Wed Apr 12, 2017 12:38 am

The instructions I posted were tested and do work fine when building with ninja. In my case I am using "--force-build" flag and I don't use "--no-distrib --no-build" flags. That's all I can help you, good luck.
Maintainer of the CEF Python, PHP Desktop and CEF C API projects. My LinkedIn.
User avatar
Czarek
Virtuoso
 
Posts: 1927
Joined: Sun Nov 06, 2011 2:12 am


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 32 guests