使用Visual Studio构建UEFI驱动程序 [英] Building UEFI driver using Visual Studio

查看:482
本文介绍了使用Visual Studio构建UEFI驱动程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找有关如何使用Visual Studio 2012项目使用EDK2 SDK构建UEFI驱动程序的建议.我正在尝试静态链接UefiLib.lib,但失败了.我已将lib添加到链接器下的其他依赖项.

I'm looking for advice on how to build UEFI drivers with the EDK2 SDK using a Visual Studio 2012 project. I'm trying to statically link UefiLib.lib but failing miserably. I've added the lib to the additional dependencies under linker.

#include  <Uefi.h>
#include  <Library/UefiLib.h>

EFI_STATUS
EFIAPI
UefiMain (
  IN EFI_HANDLE        ImageHandle,
  IN EFI_SYSTEM_TABLE  *SystemTable
  )
{
 Print((CHAR16 *)L"Welcome to the world of EDK II.\n");
 return EFI_SUCCESS;
}

错误是

test.obj : error LNK2001: unresolved external symbol "unsigned __int64 __cdecl Print(unsigned short const *,...)" (?Print@@YA_KPEBGZZ)

现在我已经使用DUMPBIN来确保Print在lib中存在,但是它不是作为导出或导入而是作为存档成员存在.我不确定这是否是问题所在.

Now i've used DUMPBIN to make sure that Print exists in the lib, however it exists not as an export or import but as an archivemember. I'm not sure if thats the issue.

推荐答案

您不能单独构建UEFI驱动程序或应用程序,它必须在EDK2源代码树中完成,该源代码树具有许多头文件和库,这些文件和库对于编译和链接EDK2组件. EDK2组件必须使用EDK2构建工具构建,C编译器/链接器只是EDK2构建过程中的一步.您应该从使用命令行进行构建开始,以确保正确设置了环境,然后可以尝试将要开发的组件引入Visual Studio.

You cannot build a UEFI driver or application separately, it must be done within the EDK2 source tree, which has a lot of header files and libraries necessary to compile and link an EDK2 component. EDK2 components must be built with EDK2 build tools, the C compiler/linker is only a step in the EDK2 build process. You should start from building using command line to make sure you have the environment setup properly, then you can try bringing the components you want to develop into Visual Studio.

在Visual Studio中,您可以从创建Makefile项目开始-这对于指定所有自定义生成步骤是必需的.例如,转到项目的属性页",在配置属性"->"NMake"->常规"->构建命令行"下.将以下代码放入Build命令行;它将允许您构建整个AppPkg程序包,其中包括您要构建的Hello应用程序.

In Visual Studio you can start with creating a Makefile Project - this is necessary to specify all the custom build steps. For example, go to your project's Property Pages, under Configuration Properties -> NMake -> General -> Build Command Line. Put the following code in the Build Command Line; it will allow you to build the entire AppPkg package, which includes the Hello app you are trying to build.

cd C:\src\edk2
call "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcvarsall.bat" x86
call edksetup.bat
build.exe -p c:\src\edk2\AppPkg\AppPkg.dsc -t VS2012x86  -b DEBUG

如果仅要构建Hello,则必须自定义AppPkg.dsc文件,该文件用于构建AppPkg程序包.有一些方法可以通过使用带有build.exe实用程序的更高级的命令行开关来进一步调整构建过程-您必须研究TianoCore.org上可用的EDK2手册.

If you want to only build Hello, you would have to customize the AppPkg.dsc file, which is used to build the AppPkg package. There are ways to further tweak the build process by using more advanced command line switches with the build.exe utility - you would have to study the EDK2 manuals available at TianoCore.org.

上述步骤应该可以帮助您开始在Visual Studio中构建UEFI应用程序/驱动程序,但是您可能希望将Visual Studio用于其强大的IntelliSense和调试功能.为此,您应该先构建Nt32Pkg程序包,该程序包将在Windows中创建EFI仿真环境,并允许您逐步执行代码并调试UEFI驱动程序/应用程序作为常规Windows应用程序.设置Visual Studio项目来完成此操作有些棘手,除非您使用专门的VS扩展进行UEFI开发,从而自动为您完成所有工作,例如Phoenix Core Architect.但是,可以手动执行,您只需要手工将EDK2源的一部分或全部文件/文件夹结构带入VS解决方案资源管理器. Nt32Pkg构建的结果是Windows应用程序C:\ src \ edk2 \ Build \ NT32IA32 \ DEBUG_VS2012x86 \ IA32 \ SecMain.exe-应该可以让您在Windows环境中入门,并向您介绍UEFI.

The above-mentioned steps should help you to get started with building a UEFI app/driver within Visual Studio, but you probably want to use Visual Studio for its powerful IntelliSense and Debugging features. To do this you should start with building the Nt32Pkg package, which creates an EFI emulated environment in Windows and allows you to step through the code and debug a UEFI driver/app as a regular Windows application. Setting up a Visual Studio project to do this is a bit tricky, unless you use a specialized VS extension for UEFI development that automates all this work for you, such as Phoenix Core Architect. However, it is possible to do manually, you just need to bring a part or all the of file/folder structure of EDK2 source into the VS Solution Explorer by hand. The result of Nt32Pkg build is the Windows application C:\src\edk2\Build\NT32IA32\DEBUG_VS2012x86\IA32\SecMain.exe - that should get you started in Windows environment and introduce you to UEFI.

这篇关于使用Visual Studio构建UEFI驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆