简体   繁体   中英

Unresolved external symbol '_D3DX10CreateFontIndirectA@12' in DirectX 11

I am currently trying to write some code to show some text using DirectX 11, but when it came to building it, I received the following error:

1>Source.obj : error LNK2019: unresolved external symbol _D3DX10CreateFontIndirectA@12 referenced in function "bool __cdecl InitScene(void)" (?InitScene@@YA_NXZ)

And for reference, here's the code which I've got, including the line which I think might be causing the problem:

bool InitScene()
{
D3DX10_FONT_DESC fd;
fd.Height = 175;
fd.Width = 0;
fd.Weight = 0;
fd.MipLevels = 1;
fd.Italic = false;
fd.CharSet = OUT_DEFAULT_PRECIS;
fd.Quality = DEFAULT_QUALITY;
fd.PitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
strcpy_s(fd.FaceName, "Impact"); //Need to find out how to fix this.

D3DX10CreateFontIndirect(d3dDevice, &fd, &Font);

return true;
}

Does anyone know why this is happening, and if so, how can it be fixed?

You need to link with D3DX10.lib.

Assuming you are using Visual Studio, right click on your project and open Properties. On left section, expand and select Configuration Properties->Linker->Input. Then on the right section, in "Addition Dependencies" add the library name as D3DX10.lib separating it with any other listed libraries using a semicolon.

To make sure that these "Additional Dependencies" are actually used during build process, two more things should be verified. Under Configuration Properties->Linked->General 1) make sure to select "Yes" for "Link Library Dependencies". 2) make sure to select "Yes" for "Use Library Dependency Inputs".

Also, in future, for any such error which says "Unresolved external symbol", find out which library the Unresolved function/symbol belongs to and add that library in "Additional Dependencies" as mentioned above.

This function D3DX10CreateFontIndirect need to link D3DX10.lib. By the way, if you want to render font in DX11, you are recommended to use DirectWrite, that's the new technology for rendering font in DirectX.

D3DX10CreateFontIndirect

DirectWrite

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM