【发布时间】:2010-04-29 23:24:59
【问题描述】:
我已经从微软网站下载了 Direct X SDK,但是当我尝试编译我的代码时,我收到了这个错误:
Error 1 error LNK2019: unresolved external symbol _Direct3DCreate9@4 referenced in function "void __cdecl initD3D(struct HWND__ *)" (?initD3D@@YAXPAUHWND__@@@Z) C:\Users\Josh\Desktop\Tutorial\Tutorial\Tutorial.obj Tutorial
我已将 Direct X 添加到我的 C++ 构建目录中:
$(DXSDK_DIR)include
$(DXSDK_DIR)Lib\x64
我在谷歌上搜索了一下,发现大部分时间人们都忘记了这一行:
#pragma comment (lib, "d3dx9.lib")
但它对我来说是我的包含和库:
#include <windows.h>
#include <windowsx.h>
#include <d3d9.h>
#include <d3dx9.h>
#pragma comment (lib, "d3d9.lib")
#pragma comment (lib, "d3dx9.lib")
谁能帮我解决这个问题?我在 win7 x64 上使用 Visual Studio 2010 Professional
【问题讨论】:
-
尝试删除
pragma并通过Additional Dependencies在项目设置中包含适当的库 (Linker) -
不,我仍然遇到同样的错误。
-
那么问题可能与您的库有关(它可能是错误的版本或类似的东西,不确定,但这可能是您的 64 位系统的特定问题)。尝试检查(通过 ctrl-q,例如在总指挥官中)您的库导出了哪些方法,并尝试在其中找到
_Direct3DCreate。另外,除了Direct3DCreate调用之外,您的代码是否有来自库的内容? -
(如果是,您还应该收到
unresolved的其他方法)
标签: c++ visual-studio-2010 directx linker