If you want to use C library in your program such as: printf, scanf……. You should use EADK library in EDK2.
1.Decompress EADK_A2_Release. There are 3 directories. Put them to your EDK2 source directory. In fact you should make sure your EDK2 can build and run NT32 well.
2.Run edksetup.bat in your EDK directory.
3.You can build EADK_A2_Release by using
build -a IA32 -p AppPkg\AppPkg.dsc
3.You well get the first error message.(AppPkg.dsc error 000E)
4.You should modify AppPkg.dsc as below as we just want to test program under NT32:
[LibraryClasses.IA32]
# TimerLib|PerformancePkg/Library/DxeTscTimerLib/DxeTscTimerLib.inf
## Comment out the above line and un-comment the line below for running under Nt32 emulation.
TimerLib|MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplate.inf
5.Build again and your will get the second error message (time.h Error C2220)
6.The solution is simple. Use the Notepad to open the time.h and save again.
7.At last all the demos can be build. You can get main.efi hello.efi and Enquire.efi. They can be run in NT32 emulation environment.
They will be placed at “\Build\AppPkg\DEBUG_VS2008\IA32” after compiling. And you can copy them to “\Build\NT32\DEBUG_VS2008\IA32”. After that they can be seen under fsnt0:
8.You can use printf in your program now. Ex.
int
EFIAPI
main (
IN int Argc,
IN char **Argv
)
{
puts(“Hello there fellow Programmer.”);
puts(“Welcome to the world of EDK II.”);
printf(“lab-z.com %x\n”,8212);
return 0;
}
<2016> I find it seems to be hard to download an EADK package from internet, and I put one here EadkPkg_A2
reference:
1.http://www.lab-z.com/step-to-uefi-shell-6-shell-%E4%B8%AD%E4%BD%BF%E7%94%A8-float/
2.http://biosren.com/viewthread.php?tid=5651&fromuid=6339]http://biosren.com/viewthread.php?tid=5651&fromuid=6339 .UEFI 实战(1) 配置开发环境