无法解析的外部符号 _Direct3DCreate9@4

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Qyee16/article/details/11106761

     机子里有Directx9 和 Directx11, Directx11是安装到系统里面的并配置了环境变量,而Directx9是rar文件解压放在机器里的。

     写了个工程,包含了静态库文件

#pragma comment(lib, "d3d9.lib")
#pragma comment(lib, "d3dx9.lib")

     错误:

错误 1 error LNK2019: 无法解析的外部符号 _Direct3DCreate9@4,该符号在函数 "void __cdecl InitD3D(struct HWND__ *)" (?InitD3D@@YAXPAUHWND__@@@Z) 中被引用

     包含文件文件:

#include <ddraw.h>
#pragma comment(lib, "ddraw.lib")

    报错误找不到 ddraw.lib。到Directx11里面寻找确实没有发现 ddraw.lib 。在 Directx9里存在。包含Directx9路径,编译通过。

注:1、Directx9 和 Directx11 里面都包含了 d3d9.lib 和 d3dx9.lib

        2、Directx9里面包含ddraw.lib, Directx11里面不包含

阅读更多

error LNK2019: 无法解析外部符号 _Direct3DCreate9@4???

08-19

环境 visual studio.net 2005 rn dirctx 9 sdk rn代码rn#include rn#include rnconst wchar_t g_szClassName[] = L"myWindowClass";//rnHWND hwnd;rn//两个全局变量rnLPDIRECT3D9 pD3D;rnLPDIRECT3DDEVICE9 pd3dDevice;rnrn//LPSTR = "myWindowClass";rn// Step 4: the Window Procedurernrn//初始化函数rnrn/********************************************************************* rn* initDirect3Drn*********************************************************************/rnbool initDirect3D()rnrn pD3D = NULL;rn pd3dDevice = NULL;rnrn //create direct objectrn if(NULL == (pD3D = Direct3DCreate9(D3D_SDK_VERSION)))rn rn return false;rn rn //fill in the structurern D3DPRESENT_PARAMETERS d3dpp;rn ZeroMemory(&d3dpp,sizeof(d3dpp));rn d3dpp.Windowed = true;rn d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;rn d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;rn d3dpp.BackBufferCount = 1;rn d3dpp.BackBufferHeight = 480;rn d3dpp.BackBufferWidth = 640;rn d3dpp.hDeviceWindow = hwnd;rnrn //create direct device rn if(FAILED(pD3D->CreateDevice(D3DADAPTER_DEFAULT, rn D3DDEVTYPE_REF, rn hwnd, rn D3DCREATE_SOFTWARE_VERTEXPROCESSING, rn &d3dpp, rn &pd3dDevice)))rn rn return false;rnrn rnrn return true;rnrnrn/********************************************************************* rn* renderrn*********************************************************************/rnvoid render()rnrn //check you have a valid direct devicern if(NULL == pd3dDevice)rn rn return ;rn rn pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET, rn D3DCOLOR_XRGB( 0,0,255 ), 1.0f, 0);rn //present the back buffer contents to the displayrn pd3dDevice->Present(NULL,NULL,NULL,NULL);rnrnrnrn///rnvoid cleanUp(void)rnrn // Release the device and the Direct3D object rn if( pd3dDevice != NULL ) rn pd3dDevice->Release(); rn if( pD3D != NULL ) rn pD3D->Release(); rnrn///rnrnrnrnLRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM rnlParam)rnrn switch(msg)rn rn case WM_LBUTTONDOWN:rn MessageBox(NULL,L"zhang",L"jian",MB_OK);rn break;rnrn case WM_CLOSE:rn DestroyWindow(hwnd);rn break;rn case WM_DESTROY:rn PostQuitMessage(0);rn break;rn default:rn return DefWindowProc(hwnd, msg, wParam, lParam);rn rn return 0;rnrnint WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,rn LPSTR lpCmdLine, int nCmdShow)rnrn //direct 初始化 initDirect3D()自己定义的初始化函数rn if(!initDirect3D())rn rn return false;rn rnrnrnrn WNDCLASSEX wc;rn rn MSG Msg;rn //Step 1: Registering the Window Class 下面的信息是用来设定窗口的相关属性rn wc.cbSize = sizeof(WNDCLASSEX);rn wc.style = 0;rn wc.lpfnWndProc = WndProc;rn wc.cbClsExtra = 0;rn wc.cbWndExtra = 0;rn wc.hInstance = hInstance;rn wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);rn wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);rn wc.lpszMenuName = NULL;rn wc.lpszClassName = g_szClassName;//rn wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);rn if(!RegisterClassEx(&wc))rn rn MessageBox(NULL, L"Window Registration Failed!", L"Error!",rn MB_ICONEXCLAMATION | MB_OK);rn return 0;rn rn // Step 2: Creating the Windowrn hwnd = CreateWindowEx(rn WS_EX_CLIENTEDGE,rn g_szClassName,/// 从注册的类去创建窗口rnL"The title of my window",rn WS_OVERLAPPEDWINDOW,rn CW_USEDEFAULT, CW_USEDEFAULT, 640, 480,rn NULL, NULL, hInstance, NULL);rn if(hwnd == NULL)rn rn MessageBox(NULL, L"Window Creation Failed!", L"Error!",rn MB_ICONEXCLAMATION | MB_OK);rn return 0;rn rn ShowWindow(hwnd, nCmdShow);rn UpdateWindow(hwnd);rn /* // Step 3: The Message Loop //消息循环rn while(GetMessage(&Msg, NULL, 0, 0) > 0)rn rn TranslateMessage(&Msg);rn DispatchMessage(&Msg);rn */rn if( PeekMessage( &Msg, NULL, 0U, 0U, PM_REMOVE ) ) rn rnTranslateMessage ( &Msg ); rnDispatchMessage ( &Msg ); rn rnelse rn rnrender( ); rn rnrnrn return Msg.wParam;rnrnrn错误提示:rnerror LNK2019: 无法解析的外部符号 _Direct3DCreate9@4,该符号在函数 "bool __cdecl initDirect3D(void)" (?initDirect3D@@YA_NXZ) 中被引用rnrn 我已经在工具-》选项-》项目和解决方案-》vc++目录 添加过了 但是还是不行 请大侠指教一下啊 rn

求助:error LNK2019: 无法解析外部符号 _Direct3DCreate9@4

04-27

环境:rn visual studio.net 2003rn dirctx 9 sdkrn错误信息:rnrn error LNK2019: 无法解析的外部符号 _Direct3DCreate9@4 ,该符号在函数 "long __cdecl InitD3D(struct HWND__ *)rn源代码如下:rnrn#include rnrnLPDIRECT3D9 g_pD3D = NULL;rnLPDIRECT3DDEVICE9 g_pd3dDevice = NULL;rnrnLRESULT WINAPI MsgProc( HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam);rnHRESULT InitD3D(HWND hWnd);rnvoid Cleanup();rnvoid Render();rnrnrnint WINAPI WinMain(HINSTANCE hinst,HINSTANCE,LPSTR,INT)rnrn WNDCLASSEX wc=sizeof(WNDCLASSEX),CS_CLASSDC,MsgProc,0L,rn 0L,GetModuleHandle(NULL),NULL,NULL,NULL,rn "D3D Tutorial",NULL;rn RegisterClassEx(&wc);rn HWND hWnd=CreateWindow("D3D Tutorial","D3D ",WS_OVERLAPPEDWINDOW,rn 100,100,300,300,GetDesktopWindow(),NULL,rn wc.hInstance,NULL);rn rn //初始化direct3drn rn if ( SUCCEEDED (InitD3D( hWnd ) ) )rn rn //show windowsrnrn ShowWindow( hWnd, SW_SHOWDEFAULT );rn UpdateWindow( hWnd);rnrn // get windows messagernrn MSG msg;rn while( GetMessage(&msg,NULL,0,0))rn rn TranslateMessage(&msg);rn DispatchMessage(&msg);rn rn rn Cleanup();rn UnregisterClass("D3D Tutorial",wc.hInstance);rn return 0;rnrnrnLRESULT WINAPI MsgProc( HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)rnrn switch( msg )rn rn case WM_DESTROY:rn PostQuitMessage(0);rn return 0;rn case WM_PAINT:rn Render();rn ValidateRect( hWnd,NULL);rn return 0;rn rn return DefWindowProc( hWnd,msg,wParam,lParam);rnrnrnHRESULT InitD3D(HWND hWnd)rnrn if ( NULL == ( g_pD3D = Direct3DCreate9 ( D3D_SDK_VERSION ) ) )rn return E_FAIL;rn D3DDISPLAYMODE d3ddm;rn if ( FAILED ( g_pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT,&d3ddm) ) )rn return E_FAIL;rn D3DPRESENT_PARAMETERS d3dpp;rn ZeroMemory( &d3dpp,sizeof(d3dpp));rn d3dpp.Windowed =TRUE;rn d3dpp.SwapEffect= D3DSWAPEFFECT_DISCARD;rn d3dpp.BackBufferFormat = d3ddm.Format;rn if ( FAILED ( g_pD3D->CreateDevice( D3DADAPTER_DEFAULT,rn D3DDEVTYPE_HAL,rn hWnd,rn D3DCREATE_SOFTWARE_VERTEXPROCESSING,rn &d3dpp,rn &g_pd3dDevicern ) ) )rn return E_FAIL;rn return S_OK;rnrnrnvoid Cleanup()rnrn if ( g_pd3dDevice != NULL)rn g_pd3dDevice->Release();rn if ( g_pD3D != NULL )rn g_pD3D->Release();rnrnrnvoid Render()rnrn if( NULL == g_pd3dDevice )rn return;rn g_pd3dDevice->Clear( 0,NULL,D3DCLEAR_TARGET,D3DCOLOR_XRGB (0,0,255),1.0f,0);rn g_pd3dDevice->BeginScene();rn g_pd3dDevice->EndScene();rn g_pd3dDevice->Present (NULL,NULL,NULL,NULL);rn

没有更多推荐了,返回首页