Windows下編譯jcef

來源:互聯網
上載者:User

標籤:code   padding   order   原始碼   run   font   version   mpi   put   

依賴軟體參考

本文參考官方網站上的jcef編譯過程
編譯成功的環境如下:

  • windows 10 64 bit
  • JDK 1.8.0_121 64 bit
  • Python 2.7.13
  • git version 2.12.1.windows.1
  • cmake version 3.12.0-rc1
  • Visual Studio 2015 Enterprise Edition

以上的軟體也是官網上要求安裝的軟體,不過版本稍有不同,官網上的版本要求如下:

  • CMake version 2.8.12.2 or newer.
  • Git.
  • Java version 1.7 or 1.8.
  • Python version 2.6 or newer in the 2.x series (3.x is not supported)

VS官方是建議使用2015版本。

另外在64位機器上編譯,jdk最好裝64位的,由於64位的機器預設編譯64位的依賴,因此,32位jdk找到的依賴會報錯,後面會提到出錯後的處理

下載jcef原始碼
[email protected] MINGW64 ~$ cd /d/learn/jecf/?[email protected]-8K18HPL MINGW64 /d/learn/jecf$ git clone https://bitbucket.org/chromiumembedded/java-cef.git srcCloning into ‘src‘…remote: Counting objects: 3710, done.remote: Compressing objects: 100% (1758/1758), done.remote: Total 3710 (delta 2461), reused 2576 (delta 1682)Receiving objects: 100% (3710/3710), 27.49 MiB | 68.00 KiB/s, done.Resolving deltas: 100% (2461/2461), done.?[email protected]-8K18HPL MINGW64 /d/learn/jecf$
執行make

到了這一步就雖然可以執行make了,make過程有個問題make是需要從Google Storage 下載 clang-format,這個步驟執行一次即可;國內的使用者需要設定代理才可以,不然會停留在 -- Downloading clang-format from Google Storage... 這一步 輸出如下:

-- Found PythonInterp: D:/Python27/python.exe (found version "2.7.13")-- Found JNI: C:/jdk1.8.0_121_x86/lib/jawt.lib (Required is at least version "1.7")-- Generating native/jcef_version.h file…File native/jcef_version.h is already up to date.-- Downloading clang-format from Google Storage…

執行make 前,設定cmd代理:

set http_proxy=http://{ip}:{port}set https_proxy=http://{ip}:{port}

執行make,參考下面官網提供的make流程命令

# Enter the JCEF source code directory.cd /path/to/java-cef/src?# Create and enter the `jcef_build` directory.# The `jcef_build` directory name is required by other JCEF tooling# and should not be changed.mkdir jcef_build && cd jcef_build?# Linux: Generate 64-bit Unix Makefiles.cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release ..# Build using Make.make -j4?# Mac OS X: Generate 64-bit Xcode project files.cmake -G "Xcode" -DPROJECT_ARCH="x86_64" ..# Open jcef.xcodeproj in Xcode# - Select Scheme > Edit Scheme and change the "Build Configuration" to "Release"# - Select Product > Build.?# Windows: Generate 64-bit VS2015 project files.cmake -G "Visual Studio 14 Win64" ..# 32 bit # cmake -G "Visual Studio 14" ..# Open jcef.sln in Visual Studio# - Select Build > Configuration Manager and change the "Active solution configuration" to "Release"# - Select Build > Build Solution.

若這個步驟出現JDK依賴錯誤,通常是使用64 bit 的機器上使用32 bit的JDK,make的時候,看最後的輸出,

-- Java directory:               C:/jdk1.8.0_121_x86-- JNI libraries:                C:/jdk1.8.0_121_x86/lib/jawt.lib;C:/jdk1.8.0_121_x86/lib/jvm.lib-- JNI include directories:      C:/jdk1.8.0_121_x86/include;C:/jdk1.8.0_121_x86/include/win32;C:/jdk1.8.0_121_x86/include-- Configuring done-- Generating done

上面的輸出可以看到,Java directory和JNI libraries 選擇了32位的JDK的路徑,重新安裝JDK和配置了64 bit JDK到環境變數中,刪除jcef build 中的所有檔案,重新執行make 步驟即可。

執行完成後輸入如下:

-- Configuring done-- Generating done-- Build files have been written to: D:/learn/jecf/src/jcef_build
 編譯cef 依賴的dll

由於JCEF是java對CEF的封裝,因此還是需要依賴CEF的,CEF及相關的bridge編譯使用VS來完成的。
進入jcef_build目錄,開啟jcef.sln
將解決方案的項目配置由 debug 改成release ,然後直接產生,生產成功後,輸出如下:

5>------ 已跳過產生: 項目: ALL_BUILD, 配置: Debug x64 ------5>沒有為此解決方案配置選中要產生的項目 ========== 產生: 成功 4 個,失敗 0 個,最新 0 個,跳過 1 個 ==========

 

編譯java 代碼

執行compile.bat win64
32 bit 執行 compile.bat win32

D:\learn\jecf\src\tools>compile.bat win64D:\learn\jecf\src\java\tests\detailed\handler\binding_test.html -> D:\learn\jecf\src\out\win64\tests\detailed\handler\binding_test.htmlD:\learn\jecf\src\java\tests\detailed\handler\binding_test2.html -> D:\learn\jecf\src\out\win64\tests\detailed\handler\binding_test2.htmlD:\learn\jecf\src\java\tests\detailed\handler\localstorage.html -> D:\learn\jecf\src\out\win64\tests\detailed\handler\localstorage.htmlD:\learn\jecf\src\java\tests\detailed\handler\spellcheck.html -> D:\learn\jecf\src\out\win64\tests\detailed\handler\spellcheck.htmlD:\learn\jecf\src\java\tests\detailed\handler\transparency.html -> D:\learn\jecf\src\out\win64\tests\detailed\handler\transparency.html複製了 5 個檔案D:\learn\jecf\src\java\tests\detailed\handler\logo.png -> D:\learn\jecf\src\out\win64\tests\detailed\handler\logo.png複製了 1 個檔案?D:\learn\jecf\src\tools>run.bat win64 Release detailedERROR: Native build output path does not exist?D:\learn\jecf\src\tools>
編譯後的測試

執行run.bat win64 Release detailed
32 bit 執行 run.bat win32 Release detailed
得到一個嵌入了瀏覽器的AWT介面的java應用,在地址欄輸入https://html5test.com/,可以看到得到的分數基本與安裝的Chrome一致

若VS沒有修改項目配置為release,執行時候報Release 路徑沒有找到

編譯後分發

執行 make_distrib.bat win64
32 bit 執行 make_distrib.bat win32

D:\learn\jecf\src\tools>make_distrib.bat win64ERROR: Native Release build output path does not exist

若VS沒有修改項目配置為release,同樣執行時候報Release 路徑沒有找到

分發後測試

若執行成功,在src目錄下會增加一個binary_distrib的檔案夾,裡面就是打包好的分發的檔案了。

進入binary_distrib執行run.bat,運行得到與編譯後的測試一致的應用;

至此,編譯jcef的過程結束

Windows下編譯jcef

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.