链接问题求救~!!!!

koala_jx 2010-03-26 10:51:43
以下是我从老师那里复制的代码~但是为什么到了我机子上就不能执行了~~我的编译环境是VS2008英文版~ 而且我不是很熟练~所以麻烦大家写解决方法写清楚点哈~~谢谢谢谢~!!
一共有以下两个错误~~
error LNK2019: unresolved external symbol _D3DXCreateSprite@8 referenced in function _wWinMain@16 MyGame.obj MyGame
error LNK1120: 1 unresolved externals F:\MyGame\Debug\MyGame.exe 1 MyGame

// MyGame.cpp : Defines the entry point for the application.


#include "stdafx.h"
#include <d3d9.h>
#include <d3dx9.h>
#include <D3dx9core.h>

#include "MyGame.h"

#define MAX_LOADSTRING 100

// Global Variables:
HINSTANCE g_hInst; // current instance
HWND g_hWnd;

// Forward declarations of functions included in this code module:
ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);

int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);

// TODO: Place code here.
MSG msg;

// Initialize global strings
MyRegisterClass(hInstance);

// Perform application initialization:
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}

// 在此处对绘图设备进行初始化
IDirect3D9* pD3D9 = NULL;
pD3D9 = Direct3DCreate9(D3D_SDK_VERSION);
// 此处创建了一个D3D9(不是设备!)
// 下面要创建一个用于绘制的设备
IDirect3DDevice9 *pD3DDevice = NULL;

// 初始化设备需要的一些参数
D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory(&d3dpp, sizeof(d3dpp));
d3dpp.Windowed = true;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
d3dpp.EnableAutoDepthStencil = TRUE;
d3dpp.AutoDepthStencilFormat = D3DFMT_D16;

pD3D9->CreateDevice(
0, //D3DADAPTER_DEFAULT·,
D3DDEVTYPE_HAL,
g_hWnd,
D3DCREATE_HARDWARE_VERTEXPROCESSING,
&d3dpp,
&pD3DDevice);

// 创建绘制贴图的工具
LPD3DXSPRITE pSprite = NULL;
D3DXCreateSprite(pD3DDevice, &pSprite);

// Main message loop:
bool bGameOver = false;
while (bGameOver == false)
{
// 去消息队列中看一下有没有新消息
if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);

bGameOver = (msg.message == WM_QUIT);
}

// 处理游戏逻辑与绘制任务
// 处理游戏逻辑的代码全部放在一个函数中
//Update();

// 处理绘制任务的代码全部集中于此
// 用什么设备(硬件、软件)进行绘制?
// 使用设备之前需要对设备进行初始化
// 问题是在哪里进行初始化比较合理
//Render();
pD3DDevice->Clear(0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER,
D3DCOLOR_XRGB(0, 0, 255), 1.0f, 0);
// Begin the scene
if(SUCCEEDED(pD3DDevice->BeginScene()))
{
// 在此绘制
// 2D游戏
//pSprite->Begin(D3DXSPRITE_ALPHABLEND);

// 在这里绘制2D图片
// ......

//pSprite->End();

pD3DDevice->EndScene();
}

pD3DDevice->Present(NULL, NULL, NULL, NULL);
}

pD3D9->Release();
pD3DDevice->Release();

return (int) msg.wParam;
}



//
// FUNCTION: MyRegisterClass()
//
// PURPOSE: Registers the window class.
//
// COMMENTS:
//
// This function and its usage are only necessary if you want this code
// to be compatible with Win32 systems prior to the 'RegisterClassEx'
// function that was added to Windows 95. It is important to call this function
// so that the application will get 'well formed' small icons associated
// with it.
//
ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEX wcex;

wcex.cbSize = sizeof(WNDCLASSEX);

wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_MYGAME));
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = NULL;
wcex.lpszClassName = TEXT("MyGameWnd");
wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));

return RegisterClassEx(&wcex);
}

//
// FUNCTION: InitInstance(HINSTANCE, int)
//
// PURPOSE: Saves instance handle and creates main window
//
// COMMENTS:
//
// In this function, we save the instance handle in a global variable and
// create and display the main program window.
//
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
g_hInst = hInstance; // Store instance handle in our global variable

g_hWnd = CreateWindow(TEXT("MyGameWnd"), TEXT("My Game"), WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);

if (!g_hWnd)
{
return FALSE;
}

ShowWindow(g_hWnd, nCmdShow);
UpdateWindow(g_hWnd);

return TRUE;
}

//
// FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
//
// PURPOSE: Processes messages for the main window.
//
// WM_COMMAND - process the application menu
// WM_PAINT - Paint tmhe main window
// WM_DESTROY - post a quit message and return
//

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;

switch (message)
{
case WM_KEYUP:
if (wParam == VK_ESCAPE)
{
PostQuitMessage(0);
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}

// Message handler for about box.
INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
UNREFERENCED_PARAMETER(lParam);
switch (message)
{
case WM_INITDIALOG:
return (INT_PTR)TRUE;

case WM_COMMAND:
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
{
EndDialog(hDlg, LOWORD(wParam));
return (INT_PTR)TRUE;
}
break;
}
return (INT_PTR)FALSE;
}
...全文
137 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
koala_jx 2010-03-26
  • 打赏
  • 举报
回复
[Quote=引用 11 楼 nola 的回复:]
项目属性-》linker->input写上,d3dx9.lib
[/Quote]
试了 没有用呀~~~
踏实每一步 2010-03-26
  • 打赏
  • 举报
回复
项目属性-》linker->input写上,d3dx9.lib
koala_jx 2010-03-26
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 xyzhaopeng 的回复:]
引用 8 楼 koala_jx 的回复:

引用 7 楼 nola 的回复:
d3dx9.lib有没有链接或者也有可能其他版本的。

那要怎么解决呀····

你去VS2008的Tools->Option下找到Project And solutions下的VC++ Directors,把DX的Include和Library目录设置好试试看。
[/Quote]

设置没有问题呀···路径对的哦···
cdsnpeter 2010-03-26
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 koala_jx 的回复:]

引用 7 楼 nola 的回复:
d3dx9.lib有没有链接或者也有可能其他版本的。

那要怎么解决呀····
[/Quote]
你去VS2008的Tools->Option下找到Project And solutions下的VC++ Directors,把DX的Include和Library目录设置好试试看。
koala_jx 2010-03-26
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 nola 的回复:]
d3dx9.lib有没有链接或者也有可能其他版本的。
[/Quote]
那要怎么解决呀····
踏实每一步 2010-03-26
  • 打赏
  • 举报
回复
d3dx9.lib有没有链接或者也有可能其他版本的。
qc_jmy 2010-03-26
  • 打赏
  • 举报
回复
工程属性设置问题
qc_jmy 2010-03-26
  • 打赏
  • 举报
回复
工程属性设置问题
koala_jx 2010-03-26
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 xyzhaopeng 的回复:]
装DirectX SDK没有?
[/Quote]

装了~~ ~就是解压缩后把.H和.LIB复制到了VS9里面的对应位置~
这样也不知道对不对~
VC_ZSY 2010-03-26
  • 打赏
  • 举报
回复
哥啊··这么长的代码怎么看呢··你自己调试下看看是哪里的问题·
cdsnpeter 2010-03-26
  • 打赏
  • 举报
回复
装DirectX SDK没有?
bragi523 2010-03-26
  • 打赏
  • 举报
回复
去改工程属性吧

里面的目录应该有问题

16,550

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Creator Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧