   Linked error(s)
  I'm using Bloodshed Dev C++ compiler and when compiling a simple non-drawing DirectX window I get these errors:  [Linker error] undefined reference to `D3DXMatrixPerspectiveFovLH@20'  [Linker error] undefined reference to `Direct3DCreate9@4'Compile log looks like this:Compiler: Default compilerExecuting  g++.exe...g++.exe "C:\Documents and Settings\Administratorius\Desktop\Simple Basecode\main.cpp" -o "C:\Documents and Settings\Administratorius\Desktop\Simple Basecode\main.exe"    -I"D:\Dev-Cpp\include\c++\3.3.1"  -I"D:\Dev-Cpp\include\c++\3.3.1\mingw32"  -I"D:\Dev-Cpp\include\c++\3.3.1\backward"  -I"D:\Dev-Cpp\lib\gcc-lib\mingw32\3.3.1\include"  -I"D:\Dev-Cpp\include"   -L"D:\Dev-Cpp\lib" C:\DOCUME~1\ADMINI~2\LOCALS~1\Temp/ccUhcaaa.o(.text+0x4c):main.cpp: undefined reference to `D3DXMatrixPerspectiveFovLH@20'C:\DOCUME~1\ADMINI~2\LOCALS~1\Temp/ccUhcaaa.o(.text+0x72c):main.cpp: undefined reference to `Direct3DCreate9@4'Execution terminatedAny suggestions why and how to fix these problems?   
  You forgot to include the DirectX libraries   ;  Did not.Here is the source:#include <windows.h>#include <d3dx9.h>#include <d3d9.h>#include "main.h"#pragma comment(lib, "D3d9.lib")#pragma comment(lib, "D3dx9.lib")HDChDC= NULL;    // Private GDI Device ContextHWNDhWnd= NULL;    // Holds Our Window HandleHINSTANCEhInstance;    // Holds The Instance Of The ApplicationLPDIRECT3D9pD3D= NULL;    // DirectX 3D Version 9LPDIRECT3DDEVICE9pD3DDevice= NULL;    // DirectX 3D Rendering Deviceboolkeys[256];   // Array Used For The Keyboard Routineboolactive=TRUE;   // Window Active Flag Set To TRUE By Defaultboolfullscreen=TRUE;   // Fullscreen Flag Set To Fullscreen Mode By DefaultLRESULTCALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);// Declaration For WndProcvoid ReSizeD3DScene(int width, int height)// Resize And Initialize The D3D Window{if (height==0)// Prevent A Divide By Zero By{height=1;// Making Height Equal One}D3DXMATRIXA16 matProjection;// Create A Projection Matrix// Calculate The Aspect Ratio Of The WindowD3DXMatrixPerspectiveFovLH(&matProjection, 45.0f, (float)width/(float)height, 0.1f, 100.0f );pD3DDevice->SetTransform( D3DTS_PROJECTION, &matProjection );D3DXMatrixIdentity(&matProjection);// Reset The Projection Matrix}int InitD3D()   // All Setup For D3D Goes Here{pD3DDevice->SetRenderState(D3DRS_ZENABLE,  TRUE ); // Enable Z-Buffer (Depth Buffer)    pD3DDevice->SetRenderState(D3DRS_CULLMODE, FALSE); // Disable Backface Culling    pD3DDevice->SetRenderState(D3DRS_LIGHTING, FALSE); // Disable Lightreturn TRUE;   // Initialization Went OK}int DrawD3DScene()    // Here's Where We Do All The Drawing{    pD3DDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, // Clear Screen And Depth BufferD3DCOLOR_COLORVALUE(0.0f,0.0f,0.0f,0.0f), 1.0f, 0 );pD3DDevice->BeginScene();// Nothing To draw!!!pD3DDevice->EndScene();pD3DDevice->Present( NULL, NULL, NULL, NULL );// Display Resultreturn TRUE;// Keep Going}void KillD3DWindow()// Properly Kill The Window{    if (pD3DDevice != NULL)pD3DDevice->Release();// Release D3D Deviceif (pD3D != NULL) pD3D->Release();// Release D3D Interfaceif (fullscreen)// Are We In Fullscreen Mode?{ChangeDisplaySettings(NULL,0);// If So Switch Back To The DesktopShowCursor(TRUE);// Show Mouse Pointer}if (hDC && !ReleaseDC(hWnd,hDC))// Are We Able To Release The DC{MessageBox(NULL,"Release Device Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);hDC=NULL;// Set DC To NULL}if (hWnd && !DestroyWindow(hWnd))// Are We Able To Destroy The Window?{MessageBox(NULL,"Could Not Release hWnd.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);hWnd=NULL;// Set hWnd To NULL}if (!UnregisterClass("Direct3D",hInstance))// Are We Able To Unregister Class{MessageBox(NULL,"Could Not Unregister Class.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);hInstance=NULL;// Set hInstance To NULL}}/*This Code Creates Our DirectX 3D Window.  Parameters Are:* *title- Title To Appear At The Top Of The Window* *width- Width Of The D3D Window Or Fullscreen Mode* *height- Height Of The D3D Window Or Fullscreen Mode* *fullscreenflag- Use Fullscreen Mode (TRUE) Or Windowed Mode (FALSE)*/BOOL CreateD3DWindow(char* title, int width, int height, bool fullscreenflag){WNDCLASSwc;DWORDdwExstyle;// Window Extended styleDWORDdwstyle;// Window styleRECTWindowRect;// Grabs Rectangle Upper Left / Lower Right ValuesWindowRect.left=(long)0;// Set Left Value To 0WindowRect.right=(long)width;// Set Right Value To Requested WidthWindowRect.top=(long)0;// Set Top Value To 0WindowRect.bottom=(long)height;// Set Bottom Value To Requested Heightfullscreen=fullscreenflag;// Set The Global Fullscreen FlaghInstance= GetModuleHandle(NULL);// Grab An Instance For Our Windowwc.style= CS_HREDRAW | CS_VREDRAW | CS_OWNDC;// Redraw On Size, And Own DC For Window.wc.lpfnWndProc= (WNDPROC) WndProc;// WndProc Handles Messageswc.cbClsExtra= 0;// No Extra Window Datawc.cbWndExtra= 0;// No Extra Window Datawc.hInstance= hInstance;// Set The Instancewc.hIcon= LoadIcon(NULL, IDI_WINLOGO);// Load The Default Iconwc.hCursor= LoadCursor(NULL, IDC_ARROW);// Load The Arrow Pointerwc.hbrBackground= NULL;// No Background Required For D3Dwc.lpszMenuName= NULL;// We Don't Want A Menuwc.lpszClassName= "Direct3D";// Set The Class Nameif (!RegisterClass(&wc))// Attempt To Register The Window Class{MessageBox(NULL,"Failed To Register The Window Class.","ERROR",MB_OK|MB_ICONEXCLAMATION);return FALSE;// Return FALSE}if (fullscreen)// Fullscreen Mode?{dwExstyle=WS_EX_APPWINDOW;// Window Extended styledwstyle=WS_POPUP;// Windows styleShowCursor(FALSE);// Hide Mouse Pointer}else{dwExstyle=WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;// Window Extended styledwstyle=WS_OVERLAPPEDWINDOW;// Windows style}AdjustWindowRectEx(&WindowRect, dwstyle, FALSE, dwExstyle);// Adjust Window To True Requested Size// Create The Windowif (!(hWnd=CreateWindowEx(dwExstyle,// Extended style For The Window"Direct3D",// Class Nametitle,// Window Titledwstyle |// Defined Window styleWS_CLIPSIBLINGS |// Required Window styleWS_CLIPCHILDREN,// Required Window style0, 0,// Window PositionWindowRect.right-WindowRect.left,// Calculate Window WidthWindowRect.bottom-WindowRect.top,// Calculate Window HeightNULL,// No Parent WindowNULL,// No MenuhInstance,// InstanceNULL)))// Dont Pass Anything To WM_CREATE{KillD3DWindow();// Reset The DisplayMessageBox(NULL,"Window Creation Error.","ERROR",MB_OK|MB_ICONEXCLAMATION);return FALSE;// Return FALSE}if (!(hDC=GetDC(hWnd)))// Did We Get A Device Context?{KillD3DWindow();// Reset The DisplayMessageBox(NULL,"Can't Create A Device Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);return FALSE;// Return FALSE}pD3D = Direct3DCreate9( D3D_SDK_VERSION );// Check For The Correct DirectX 3D versionif ( pD3D == NULL ){KillD3DWindow();// Reset The DisplayMessageBox(NULL,"Can't find D3D SDK Version 9.","ERROR",MB_OK|MB_ICONEXCLAMATION);return FALSE;// Return FALSE}D3DPRESENT_PARAMETERS d3dpp=// d3dpp Tells Windows How We Want Things To Be{width,// Back Buffer Widthheight,// Back Buffer HeightD3DFMT_R5G6B5,// Back Buffer Format (Color Depth)1,// Back Buffer Count (Double Buffer)D3DMULTISAMPLE_NONE,// No Multi Sample Type0,// No Multi Sample QualityD3DSWAPEFFECT_DISCARD,// Swap Effect (Fast)hWnd,// The Window Handle!fullscreen,// Windowed or FullscreenTRUE,// Enable Auto Depth Stencil  D3DFMT_D16,// 16Bit Z-Buffer (Depth Buffer)0,// No FlagsD3DPRESENT_RATE_DEFAULT,// Default Refresh RateD3DPRESENT_INTERVAL_DEFAULT// Default Presentation Interval (vertical sync)};// Check The Wanted Surface Format.if ( FAILED( pD3D->CheckDeviceFormat( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, d3dpp.BackBufferFormat, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, d3dpp.AutoDepthStencilFormat ) ) ){KillD3DWindow();// Reset The DisplayMessageBox(NULL,"Can't Find Surface Format.","ERROR",MB_OK|MB_ICONEXCLAMATION);return FALSE;// Return FALSE}// Create The DirectX 3D Device if(FAILED( pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &pD3DDevice ) ) ){KillD3DWindow();// Reset The DisplayMessageBox(NULL,"Can't Create DirectX 3D Device.","ERROR",MB_OK|MB_ICONEXCLAMATION);return FALSE;// Return FALSE}ShowWindow(hWnd,SW_SHOW);// Show The WindowSetForegroundWindow(hWnd);// Slightly Higher PrioritySetFocus(hWnd);// Sets Keyboard Focus To The WindowReSizeD3DScene(width, height);// Set Up Our Perspective D3D Screenif (!InitD3D())// Initialize Our Newly Created D3D Window{KillD3DWindow();// Reset The DisplayMessageBox(NULL,"Initialization Failed.","ERROR",MB_OK|MB_ICONEXCLAMATION);return FALSE;// Return FALSE}return TRUE;}LRESULT CALLBACK WndProc(HWNDhWnd, UINTuMsg, WPARAMwParam, LPARAMlParam ){    switch( uMsg ){case WM_ACTIVATE:// Watch For Window Activate Message{if (!HIWORD(wParam))// Check Minimization State{active=TRUE;// Program Is Active}else{active=FALSE;// Program Is No Longer Active}return 0;// Return To The Message Loop}case WM_SYSCOMMAND:// Intercept System Commands{switch (wParam)// Check System Calls{case SC_SCREENSAVE:// Screensaver Trying To Start?case SC_MONITORPOWER:// Monitor Trying To Enter Powersave?return 0;// Prevent From Happening}break;// Exit}case WM_CLOSE:// Did We Receive A Close Message?{PostQuitMessage(0);// Send A Quit Messagereturn 0;// Jump Back}case WM_KEYDOWN:// Is A Key Being Held Down?{keys[wParam] = TRUE;// If So, Mark It As TRUEreturn 0;// Jump Back}case WM_KEYUP:// Has A Key Been Released?{keys[wParam] = FALSE;// If So, Mark It As FALSEreturn 0;// Jump Back}case WM_SIZE:// Resize The Direct3D Window{if(!fullscreen)ReSizeD3DScene(LOWORD(lParam), HIWORD(lParam));  // LoWord=Width, HiWord=Heightreturn 0;// Jump Back}}// Pass All Unhandled Messages To DefWindowProcreturn DefWindowProc(hWnd,uMsg,wParam,lParam);}int WINAPI WinMain( HINSTANCEhInstance,HINSTANCEhPrevInstance,LPSTRlpCmdLine,intnCmdShow ){MSGmsg;BOOLdone=FALSE;// Bool Variable To Exit Loop// Ask The User Which Screen Mode They Preferif (MessageBox(NULL,"Would You Like To Run In Fullscreen Mode?", "Start FullScreen?",MB_YESNO|MB_ICONQUESTION)==IDNO){fullscreen=FALSE;// Windowed Mode}// Create Our DirectX 3D Windowif (!CreateD3DWindow("Apron Tutorials Direct3D Framework",640,480,fullscreen)){return 0;// Quit If Window Was Not Created}while(!done)// Loop That Runs While done=FALSE{if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))// Is There A Message Waiting?{if (msg.message==WM_QUIT)// Have We Received A Quit Message?{done=TRUE;// If So done=TRUE}else// If Not, Deal With Window Messages{TranslateMessage(&msg);// Translate The MessageDispatchMessage(&msg);// Dispatch The Message}}else// If There Are No Messages{// Draw The Scene.  Watch For ESC Key And Quit Messages From DrawD3DScene()if ((active && !DrawD3DScene()) || keys[VK_ESCAPE])// Active?  Was There A Quit Received?{done=TRUE;// ESC or DrawD3DScene Signalled A Quit}if (keys[VK_F1])// Is F1 Being Pressed?{keys[VK_F1]=FALSE;// If So Make Key FALSEKillD3DWindow();// Kill Our Current Windowfullscreen=!fullscreen;// Toggle Fullscreen / Windowed Mode// Recreate Our DirectX 3D Windowif (!CreateD3DWindow("Apron Tutorials Direct3D Framework",640,480,fullscreen)){return 0;// Quit If Window Was Not Created}}}}// ShutdownKillD3DWindow();return (msg.wParam);// Exit The Program} [Edited by - TransistoR on June 11, 2006 10:53:19 AM];Quote:Original post by overflowed_You forgot to include link to the DirectX libraries;  How to link to libraries then?   ;Quote:Original post by Introduction to 3d game programming with DirectX9Note: The location of the DirectX directory DXSDK on your computermay differ; it depends on the location that you specified duringinstallation.Typically, the DirectX SDK installation will add these paths to VC++for you. However, in case it doesn’t, you can do it manually as follows:In VC++ 6.0 go to the menu and select Tools>Options>Directoriesand enter the DirectX header file and library paths, as Figure I.3shows.In VC++ 7.0 go to the menu and select Tools>Options>ProjectsFolder>VC++ Directories and enter the DirectX header and librarypaths, as Figure I.4 shows.Then, in order to build the sample programs, you will need to link thelibrary files d3d9.lib, d3dx9.lib, and winmm.lib into your project. Notethat winmm.lib isn’t a DirectX library file; it is the Windows multimedialibrary file, and we use for its timer functions.In VC++ 6.0 you can specify the library files to link in by going tothe menu and selecting Project>Settings>Link tab and then enteringthe library names, as shown in Figure I.5.Introduction xxiFigure I.3: Adding the DirectX includeand library paths to VC++ 6.0Figure I.4: Adding theDirectX include andlibrary paths to VC++7.0In VC++ 7.0 you can specify the library files to link in by going to themenu and selecting Project>Properties>Linker>Input Folder andthen entering the library names.i donno about blood shed tho , it should be similar.;  So, I linked the libraries and i got more errors:.drectve `%.*s' unrecognized (23 times)[Linker error] undefined reference to `Direct3DCreate9@4' [Linker error] undefined reference to `_except_list' (5 times)more undefined references to `_except_list' follow [Build Error]  [simple.exe] Error 1 Compiler log looked like this:Compiler: Default compilerBuilding Makefile: "C:\Documents and Settings\Administratorius\Desktop\Simple Basecode\Makefile.win"Executing  make...make.exe -f "C:\Documents and Settings\Administratorius\Desktop\Simple Basecode\Makefile.win" allwindres.exe -i simple_private.rc -I rc -o simple_private.res -O coff g++.exe main.o simple_private.res -o "simple.exe" -L"D:/Dev-Cpp/lib" -L"E:/DXSDK/Lib" D:/Dev-Cpp/lib/d3d9.lib D:/Dev-Cpp/lib/d3dx9.lib  Warning: .drectve `%.*s' unrecognizedWarning: .drectve `%.*s' unrecognizedWarning: .drectve `%.*s' unrecognizedWarning: .drectve `%.*s' unrecognizedWarning: .drectve `%.*s' unrecognizedWarning: .drectve `%.*s' unrecognizedWarning: .drectve `%.*s' unrecognizedWarning: .drectve `%.*s' unrecognizedWarning: .drectve `%.*s' unrecognizedWarning: .drectve `%.*s' unrecognizedWarning: .drectve `%.*s' unrecognizedWarning: .drectve `%.*s' unrecognizedWarning: .drectve `%.*s' unrecognizedWarning: .drectve `%.*s' unrecognizedWarning: .drectve `%.*s' unrecognizedWarning: .drectve `%.*s' unrecognizedWarning: .drectve `%.*s' unrecognizedWarning: .drectve `%.*s' unrecognizedWarning: .drectve `%.*s' unrecognizedWarning: .drectve `%.*s' unrecognizedWarning: .drectve `%.*s' unrecognizedWarning: .drectve `%.*s' unrecognizedWarning: .drectve `%.*s' unrecognizedWarning: .drectve `%.*s' unrecognizedmain.o(.text+0x72c):main.cpp: undefined reference to `Direct3DCreate9@4'D:/Dev-Cpp/lib/d3dx9.lib(obj/i386/cpudetect.obj)(.text+0x9c):..\cpudetect.cpp: undefined reference to `_except_list'D:/Dev-Cpp/lib/d3dx9.lib(obj/i386/ssefasttable.obj)(.text+0x11):..\ssefasttable.cp: undefined reference to `_except_list'D:/Dev-Cpp/lib/d3dx9.lib(obj/i386/ssefasttable.obj)(.text+0x19):..\ssefasttable.cp: undefined reference to `_except_list'D:/Dev-Cpp/lib/d3dx9.lib(obj/i386/ssefasttable.obj)(.text+0x75):..\ssefasttable.cp: undefined reference to `_except_list'D:/Dev-Cpp/lib/d3dx9.lib(obj/i386/ssefasttable.obj)(.text+0x11):..\ssefasttable.cp: undefined reference to `_except_list'D:/Dev-Cpp/lib/d3dx9.lib(obj/i386/ssefasttable.obj)(.text+0x19):..\ssefasttable.cp: more undefined references to `_except_list' followmake.exe: *** [simple.exe] Error 1Execution terminatedAny suggestions why and how to fix these problems?   ;  iam not sure , but it seems that it can't call the function . make sure you linked to (d3d9.lib, d3dx9.lib) both.   ;  I checked other projects and linked libraries the right way but I get same result.   