返回> 网站首页 

ChromiumEmbedded - 链接不同的运行时库

yoours2011-10-17 10:36:35 阅读 1559

简介一边听听音乐,一边写写文章。

Introduction

Visual Studio supports multiple run-time libraries. The different libraries are identified by flags such as /MD, /MT and /LD. By default, CEF uses the /MT flag that is also used by the Chromium project. Different applications, however, can sometimes require different run-time libraries.

Details

There are two ways currently to link CEF with your application.

Static Linking (without a CEF DLL)

If you wish to link CEF with your application statically then all Chromium and CEF projects must use the same run-time flag as your application. If your application already uses the /MT flag then you can build CEF statically as follows:

  1. Set up the environment required to build Chromium and CEF as described on the project page and build it.
  2. Link your application against the resulting libcef_static.lib file.

If, however, your application does not use the /MT flag then you're effectively out of luck. Important parts of Chromium will not compile with a flag other than /MT.

Dynamic Linking (with a CEF DLL)

If you prefer to link CEF with your application dynamically then the process is faster. CEF provides a binary distribution on the downloads page that contains everything you need to link CEF with your application -- provided your application uses the /MT flag. If your application does not use the /MT flag then you will need to rebuild the libcef_dll_wrapper project with the same flags as your application. Unlike with static linking, you will not need to rebuild all of CEF or Chromium in order to do this.

  1. Download a CEF binary release from the project downloads page.
  2. Set up the environment required to build Chromium and CEF at that release as described on the project page but do not build it.
  3. Create a Debug\lib directory underneath the CEF directory and copy the lib\Debug\libcef.lib file from the binary release archive into that directory. If your CEF directory is "c:\Chromium\src\cef" then the lib file should now be at "c:\Chromium\src\cef\Debug\lib\libcef.lib".
  4. Open cef.sln in Visual Studio and change the flags on the libcef_dll_wrapper project to match your application.
  5. Right click on the libcef_dll_wrapper project and choose the "Project Only -> Build Only libcef_dll_wrapper" option.

If you set the flags in step 4 correctly then the above steps will result in the creation of a libcef_dll_wrapper static library in the "Debug\lib" directory that will link successfully with your application. Repeat the above steps replacing "Debug" with "Release" for a Release build.

Additional Information

More information on Microsoft run-time flags can be found here: http://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx


微信小程序扫码登陆

文章评论

1559人参与,0条评论