gpt4 book ai didi

c++ - Direct2D 仅在 C++ Builder 中部分链接

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:12:56 25 4
gpt4 key购买 nike

我有一个使用 Direct2d 的 C++ Builder (Rad Studio Berlin) 项目设置。 Canvas 绘图与 TDirect2DCanvas 一起工作得很好,这表明 Direct2D 链接正确。一切都顺利呈现。但是,我需要使用矩阵。当我尝试链接时出现链接错误。例如,当我尝试时:

canvas->RenderTarget->SetTransform(D2D1::Matrix3x2F::Rotation(15.0, D2D1PointF(100, 100)));

...我收到以下链接错误:

[ilink32 Error] Error: Unresolved external 'D2D1MakeRotateMatrix' referenced from C:\DP\TRUNK\SRC\CLIENTSIDE\APPLICATIONS\VIEWER\WIN32\DEBUG\MIMAGE.OBJ

如果我只包含 header ,C++ 生成器应该已经设置为链接到 direct2d。任何人都可以帮助我以 C++ Builder 的方式链接到适当的文件吗?

最佳答案

我从其他来源找到了解决方案。在这里:

经过一番研究,这个问题还没有确定是一个错误。

For many of the standard Windows API functions, the IDE will add the correct library automatically so that the dependencies on the function references will be satisfied. With DirectX (which is somewhat uncommonly used), the IDE does not automatically supply the library which corresponds to the header file, so this is causing the unresolved linker errors.

The solution is to either (as I mentioned previously) add the D2D1.lib to the project, or statically reference it in code:

// as long as D2D1.lib is on the library search path, it should be found
#pragma comment(lib,"D2D1.lib")

Some developers add the above line of code to their headers and so all you need to do is include the header and all is well... the DirectX team did not do this and hence the unresolved linker errors.

希望这能澄清问题,

关于c++ - Direct2D 仅在 C++ Builder 中部分链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38000829/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com