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

标签 c++ graphics linker c++builder direct2

我有一个使用 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/

相关文章:

c++ - 需要在 jsoncpp 中将空字典打印为 {} 而不是 null

c# - 如何从 Amibroker 持续导出数据

c++ - OpenGL - 如何快速绘制以特殊形式给出的线数组?

linux - 如何链接 C 中的共享对象?

c++ - 在 Embarcadero Tools API 中的光标位置插入文本

c++ - 了解 TCP 校验和功能

c++ - 如何汇编、链接和编译 C++、NASM 文件和 .o 驱动程序的组合

c++ - 将 C++ 程序与 Fortran 库链接时对 _rpoly_ 的 undefined reference

java - 如何在绘画时改变颜色(图)

image - Qt jpg图像显示