EDK2 (Development Environment for UEFI) failed after performing a test build

9.3k Views Asked by At

I am using EDK2 and Visual Studio 2019. I followed the instruction to set up EDKII build environment on Windows systems. After sending the following command "edksetup.bat Rebuild" on windows command line, I got the following message.

subprocess not exit successfully
Error while execute command 'nmake all' in direcotry C:\edk2\BaseTools\Source\C\BrotliCompress

...

LINK : fatal error LNK1181: Eingabedatei "brotli\c\tools\brotli.obj" kann nicht geffnet werden.
NMAKE : fatal error U1077: ""C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.26.28801\bin\HostX86\x86\link.exe"": Rckgabe-Code "0x49d"
Stop.
NMAKE : fatal error U1077: "if": Rückgabe-Code "0x1"
Stop.
NMAKE : fatal error U1077: "if": Rückgabe-Code "0x1"
Stop.

Is it because Of Visual Studio 2019 compatibility or is there any problem with "BrotliCompress"? I changed the tag to TOOL_CHAIN_TAG = VS2019x86. But it did not work. What else should I change for VS2019 compatibility? Is anything to do with NMAKE file?

I tested an older version of EDK2 and it works. But the problem is I am using VS2019 and I want to use edk2-stable201911. The older version (edk2-stable201908) can support up to VS2017 only. In tools_de.txt there is no "common path macros" for VS2019. The above error is result of using edk2-stable201911

2

There are 2 best solutions below

1
On

You need to check out (and build) the various submodules.

Run git submodule update --init in your edk2 directory and you should get output similar to this:

Submodule 'BaseTools/Source/C/BrotliCompress/brotli' (https://github.com/google/brotli) registered for path 'BaseTools/Source/C/BrotliCompress/brotli'
Submodule 'CryptoPkg/Library/OpensslLib/openssl' (https://github.com/openssl/openssl) registered for path 'CryptoPkg/Library/OpensslLib/openssl'
Submodule 'MdeModulePkg/Library/BrotliCustomDecompressLib/brotli' (https://github.com/google/brotli) registered for path 'MdeModulePkg/Library/BrotliCustomDecompressLib/brotli'
Submodule 'MdeModulePkg/Universal/RegularExpressionDxe/oniguruma' (https://github.com/kkos/oniguruma) registered for path 'MdeModulePkg/Universal/RegularExpressionDxe/oniguruma'
Submodule 'RedfishPkg/Library/JsonLib/jansson' (https://github.com/akheron/jansson) registered for path 'RedfishPkg/Library/JsonLib/jansson'
Submodule 'UnitTestFrameworkPkg/Library/CmockaLib/cmocka' (https://git.cryptomilk.org/projects/cmocka.git) registered for path 'UnitTestFrameworkPkg/Library/CmockaLib/cmocka'
Cloning into '<path-to-edk2>/ArmPkg/Library/ArmSoftFloatLib/berkeley-softfloat-3'...
Cloning into '<path-to-edk2>/BaseTools/Source/C/BrotliCompress/brotli'...
Cloning into '<path-to-edk2>/CryptoPkg/Library/OpensslLib/openssl'...
Cloning into '<path-to-edk2>/MdeModulePkg/Library/BrotliCustomDecompressLib/brotli'...
Cloning into '<path-to-edk2>/MdeModulePkg/Universal/RegularExpressionDxe/oniguruma'...
Cloning into '<path-to-edk2>/RedfishPkg/Library/JsonLib/jansson'...
Cloning into '<path-to-edk2>/UnitTestFrameworkPkg/Library/CmockaLib/cmocka'...
Submodule path 'ArmPkg/Library/ArmSoftFloatLib/berkeley-softfloat-3': checked out 'b64af41c3276f97f0e181920400ee056b9c88037'
Submodule path 'BaseTools/Source/C/BrotliCompress/brotli': checked out '666c3280cc11dc433c303d79a83d4ffbdd12cc8d'
Submodule path 'CryptoPkg/Library/OpensslLib/openssl': checked out 'e2e09d9fba1187f8d6aafaa34d4172f56f1ffb72'
Submodule path 'MdeModulePkg/Library/BrotliCustomDecompressLib/brotli': checked out '666c3280cc11dc433c303d79a83d4ffbdd12cc8d'
Submodule path 'MdeModulePkg/Universal/RegularExpressionDxe/oniguruma': checked out 'abfc8ff81df4067f309032467785e06975678f0d'
Submodule path 'RedfishPkg/Library/JsonLib/jansson': checked out 'e9ebfa7e77a6bee77df44e096b100e7131044059'
Submodule path 'UnitTestFrameworkPkg/Library/CmockaLib/cmocka': checked out '1cc9cde3448cdd2e000886a26acf1caac2db7cf1'

You may also need to compile stuff first; I don't know how to do it on Windows, but make -C <path-to-edk2>/BaseTools/Source/C is the ticket in Linux.

Once both of these are done you should be able to successfully build EDK2!

1
On

I started from a different place and had the same problem. After some digging around, it seems the source for the Brotli compression module was removed from the tree and replaced with a submodule about 4 months ago. I'm new to this stuff and don't know how to incorporate a submodule into the master tree so I went low-level.

There are two places where the Brotli code is needed:

  1. <your_edk2root>\BaseTools\Source\C\BrotliCompress\brotli\
  2. <your_edk2root>\MdeModulePkg\Library\BrotliCustomDecompressLib\brotli\ (where <your_edk2root> is where you cloned the EDK2 repository, including drive letter).

The Brotli source is available at https://github.com/google/brotli.

I downloaded the zip file and simply extracted everything from the brotli-master folder to each of the two previous paths (you should end up with a c directory and a docs directory and a bunch of files in each of those paths). Run edksetup.bat Rebuild again from <your_edk2root> and it should compile, link and install.

Haven't tried to build any UEFI yet, but looking forward to it!

Note: for VS2019, the TOOL_CHAIN_TAG should be VS2019, not VS2019x86.