windows 編譯 boringssl和lsquic


目標是要安裝lsquic的依賴庫boringssl
參考 BUILD-WINDOWS.md

boringssl構建方式有幾種,ndk,cmake,反正都不要在win7上折騰,ndk環境不好配置,各種報錯。cmake到最后nasm安裝了,但是匯編還是出問題了,放棄了,還是BUILD-WINDOWS.md指示的用vcpkg裝

看下依賴:

一定要在win10上進行安裝,win7坑太多。我就卡在powershell6.21版本死活要netframework4,明明已經安裝了4或者4.5甚至更高版本,但是檢測不到,就是不行。。。
虛擬機安裝win10又iso太大,通過U盤安裝還沒開始安裝啟動直接自動暫停,不繼續執行了。。。不想折騰就主機重裝了win10

另外因為我裝的是閹割版本vs2017。編譯vcpkg用到VS找不到。。。只好重新安裝了vs2017,記住 語言包勾上 英語, 不然后后面vcpkg安裝又會報問題。。。

vcpkg安裝依賴的部分開源庫下載自己找吧,默認很多資源在官網和github,速度很感人,能卡半天。最好csdn有幣。。。下載后丟到vcpkg-master\installed里面重新運行vcpkg.exe就好。

主要是從安裝./vcpkg.exe install zlib:x64-windows-static 開始一路報錯。

1.vcpkg安裝
vcpkg安裝指南

2.安裝powershell6.2.1版本,win10上基本沒啥問題,
PowerShell-6.2.1-win-x86.zip

3.VS安裝就不說了,強調下勾選上 英語 的語言包
vs2017安裝英文語言包

4.安裝7zip
7-zip.commandline.18.1.0.nupkg

5.安裝zlib,中間還有nuget.exe和PortableGit-2.26.2-32-bit.7z.exe會自動安裝,划算快

6.cmake自己下載安裝吧,最新版沒啥問題

7.然后安裝Libevent

PS C:\vcpkg-master> .\vcpkg.exe install zlib:x64-windows-static
Computing installation plan...
The following packages will be built and installed:
    zlib[core]:x64-windows-static
A suitable version of powershell-core was not found (required v6.2.1). **Downloading portable powershell-core v6.2.1**...
Extracting powershell-core...
A suitable version of 7zip was not found (required v18.1.0). **Downloading portable 7zip v18.1.0**...
Downloading 7zip...
  https://www.nuget.org/api/v2/package/**7-Zip.CommandLine/18.1.0** -> C:\vcpkg-master\downloads\7-zip.commandline.18.1.0.nupkg
PS C:\vcpkg-master> .\vcpkg.exe install zlib:x64-windows-static
Computing installation plan...
The following packages will be built and installed:
    zlib[core]:x64-windows-static
A suitable version of powershell-core was not found (required v6.2.1). Downloading portable powershell-core v6.2.1...
Extracting powershell-core...
A suitable version of 7zip was not found (required v18.1.0). Downloading portable 7zip v18.1.0...
Downloading 7zip...
  https://www.nuget.org/api/v2/package/7-Zip.CommandLine/18.1.0 -> C:\vcpkg-master\downloads\**7-zip.commandline.18.1.0.nupkg**
Could not download https://www.nuget.org/api/v2/package/7-Zip.CommandLine/18.1.0. Failed to open file C:\vcpkg-master\downloads\7-zip.commandline.18.1.0.nupkg.part. Error code was 13
PS C:\vcpkg-master> .\vcpkg.exe install zlib:x64-windows-static
Computing installation plan...
The following packages will be built and installed:
    zlib[core]:x64-windows-static
A suitable version of powershell-core was not found (required v6.2.1). Downloading portable powershell-core v6.2.1...
Extracting powershell-core...
A suitable version of 7zip was not found (required v18.1.0). Downloading portable 7zip v18.1.0...
Downloading 7zip...
  https://www.nuget.org/api/v2/package/7-Zip.CommandLine/18.1.0 -> C:\vcpkg-master\downloads\7-zip.commandline.18.1.0.nupkg
WinHttpQueryDataAvailable() failed: 12002
PS C:\vcpkg-master> .\vcpkg.exe install zlib:x64-windows-static
Computing installation plan...
The following packages will be built and installed:
    zlib[core]:x64-windows-static
A suitable version of powershell-core was not found (required v6.2.1). Downloading portable powershell-core v6.2.1...
Extracting powershell-core...
A suitable version of 7zip was not found (required v18.1.0). Downloading portable 7zip v18.1.0...
Extracting 7zip...
A suitable version of nuget was not found (required v4.8.1). Downloading portable nuget v4.8.1...
Downloading nuget...
  https://dist.nuget.org/win-x86-commandline/v4.8.1/nuget.exe -> C:\vcpkg-master\downloads\nuget.exe
PS C:\vcpkg-master> .\vcpkg.exe install zlib:x64-windows-static
Computing installation plan...
The following packages will be built and installed:
    zlib[core]:x64-windows-static
A suitable version of powershell-core was not found (required v6.2.1). Downloading portable powershell-core v6.2.1...
Extracting powershell-core...
A suitable version of 7zip was not found (required v18.1.0). Downloading portable 7zip v18.1.0...
Extracting 7zip...
A suitable version of nuget was not found (required v4.8.1). Downloading portable nuget v4.8.1...
Starting package 1/1: zlib:x64-windows-static
Building package zlib[core]:x64-windows-static...
Warning: The following VS instances are excluded because the English language pack is unavailable.
    d:\Program Files (x86)\Microsoft Visual Studio\2017\Community
Please install the English language pack.
Could not locate a complete toolset.
The following paths were examined:
    d:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat
    d:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX86\x86\dumpbin.exe
PS C:\vcpkg-master> .\vcpkg.exe install zlib:x64-windows-static
Computing installation plan...
The following packages will be built and installed:
    zlib[core]:x64-windows-static
Starting package 1/1: zlib:x64-windows-static
Building package zlib[core]:x64-windows-static...
Warning: The following VS instances are excluded because the English language pack is unavailable.
    d:\Program Files (x86)\Microsoft Visual Studio\2017\Community
Please install the English language pack.
Could not locate a complete toolset.
The following paths were examined:
    d:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat
    d:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX86\x86\dumpbin.exe
PS C:\vcpkg-master> .\vcpkg.exe install zlib:x64-windows-static
Computing installation plan...
The following packages will be built and installed:
    zlib[core]:x64-windows-static
Starting package 1/1: zlib:x64-windows-static
Building package zlib[core]:x64-windows-static...
A suitable version of git was not found (required v2.26.2). Downloading portable git v2.26.2...
Downloading git...
  https://github.com/git-for-windows/git/releases/download/v2.26.2.windows.1/PortableGit-2.26.2-32-bit.7z.exe -> C:\vcpkg-master\downloads\PortableGit-2.26.2-32-bit.7z.exe
PS C:\vcpkg-master> .\vcpkg.exe install zlib:x64-windows-static
Computing installation plan...
The following packages will be built and installed:
    zlib[core]:x64-windows-static
Starting package 1/1: zlib:x64-windows-static
Building package zlib[core]:x64-windows-static...
A suitable version of git was not found (required v2.26.2). Downloading portable git v2.26.2...
Extracting git...
-- Downloading http://www.zlib.net/zlib-1.2.11.tar.gz...
PS C:\vcpkg-master> .\vcpkg.exe install zlib:x64-windows-static
Computing installation plan...
The following packages will be built and installed:
    zlib[core]:x64-windows-static
Starting package 1/1: zlib:x64-windows-static
Building package zlib[core]:x64-windows-static...
-- Downloading http://www.zlib.net/zlib-1.2.11.tar.gz...
PS C:\vcpkg-master> .\vcpkg.exe install zlib:x64-windows-static
Computing installation plan...
The following packages will be built and installed:
    zlib[core]:x64-windows-static
Starting package 1/1: zlib:x64-windows-static
Building package zlib[core]:x64-windows-static...
-- Downloading http://www.zlib.net/zlib-1.2.11.tar.gz...
-- Extracting source C:/vcpkg-master/downloads/zlib1211.tar.gz
-- Applying patch cmake_dont_build_more_than_needed.patch
-- Using source at C:/vcpkg-master/buildtrees/zlib/src/1.2.11-deec42f53b
-- Configuring x64-windows-static
-- Building x64-windows-static-dbg
-- Building x64-windows-static-rel
-- Installing: C:/vcpkg-master/packages/zlib_x64-windows-static/share/zlib/copyright
-- Performing post-build validation
-- Performing post-build validation done
Building package zlib[core]:x64-windows-static... done
Installing package zlib[core]:x64-windows-static...
Installing package zlib[core]:x64-windows-static... done
Elapsed time for package zlib:x64-windows-static: 2.704 min

Total elapsed time: 2.704 min

The package zlib is compatible with built-in CMake targets:

    find_package(ZLIB REQUIRED)
    target_link_libraries(main PRIVATE ZLIB::ZLIB)


PS C:\vcpkg-master> .\vcpkg.exe install libevent:x64-windows-static
Computing installation plan...
The following packages will be built and installed:
    libevent[core,thread]:x64-windows-static
Starting package 1/1: libevent:x64-windows-static
Building package libevent[core,thread]:x64-windows-static...
-- Downloading https://github.com/libevent/libevent/archive/release-2.1.11-stable.tar.gz...
-- Extracting source C:/vcpkg-master/downloads/libevent-libevent-release-2.1.11-stable.tar.gz
-- Applying patch fix-file_path.patch
-- Applying patch fix-crt_linkage.patch
-- Applying patch fix-LibeventConfig_cmake_in_path.patch
-- Using source at C:/vcpkg-master/buildtrees/libevent/src/.11-stable-734e533482
-- Configuring x64-windows-static
-- Building x64-windows-static-dbg
-- Building x64-windows-static-rel
-- Installing: C:/vcpkg-master/packages/libevent_x64-windows-static/share/libevent/copyright
-- Performing post-build validation
-- Performing post-build validation done
Building package libevent[core,thread]:x64-windows-static... done
Installing package libevent[core,thread]:x64-windows-static...
Installing package libevent[core,thread]:x64-windows-static... done
Elapsed time for package libevent:x64-windows-static: 2.505 min

Total elapsed time: 2.505 min

The package libevent:x64-windows-static provides CMake targets:

    find_package(Libevent CONFIG REQUIRED)
    target_link_libraries(main PRIVATE event_static event_core_static event_extra_static)

PS C:\vcpkg-master>

最終算是把zlib和libevent裝上了。

8.自己裝go和perl后面要用

9.自己下載安裝nasm-2.14.02-installer-x64.exe匯編器

然后就可以編譯了,but,將cmake加到path后調不了,全路徑怎么調用懶得查了,直接cmake-gui用起來

PS E:\win\lsquic\boringssl-master\build> C:\Program\ Files\CMake\bin\cmake.exe **-DCMAKE_GENERATOR_PLATFORM=x64 --config Debug -DBUILD_SHARED_LIBS=OFF -DOPENSSL_NO_ASM=1**  ..
C:\Program\ : The term 'C:\Program\' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ C:\Program\ Files\CMake\bin\cmake.exe -DCMAKE_GENERATOR_PLATFORM=x64  ...
+ ~~~~~~~~~~~
+ CategoryInfo          : ObjectNotFound: (C:\Program\:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

10.用cmake-gui編

反正這些依賴項都要找到,框里的是根據lsquic中描述的boringssl的編譯方式,加的,我也不知道對不對。。。
反正生成了boringssl的sln項目,vs可以打開,並且全部編譯正常。。

后來確認是環境變量重啟才生效。。。懷疑cmake-gui的add entry可能配置無效,重新編譯了

以上就是lsquic的boringssl的編譯。

就緒編譯lsquic

1.先要將之前編譯的boring的庫放到一個目錄便於lsquic使用
我是把build\crypto\Debug和build\ssl\Debug和build\decrepit\Debug下的幾個庫都放到了build\libs下
另外,lsquic的cmakefile會檢查boringssl的頭文件和庫路徑

另外為了編譯不將部分部分警告視為錯誤,在cmakefile找到-WX改成-WX-,這樣在生成sln時各項目都不會報找不到obj的警告當成錯誤導致編譯不通過。

PS E:\win\lsquic\lsquic-master\build> `cmake -DCMAKE_GENERATOR_PLATFORM=x64 -DBUILD_SHARED_LIBS=OFF -DVCPKG_TARGET_TRIPLET=x64-windows-static -DCMAKE_BUILD_TYPE=Debug  -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg-master/scripts/buildsystems/vcpkg.cmake -DBORINGSSL_DIR=%boringssl% -DBORINGSSL_INCLUDE=E:/win/lsquic/boringssl-master/include -DBORINGSSL_LIB=E:/win/lsquic/boringssl-master/build/libs  ..

編譯完成,有60個demo。。。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM