Sign in to follow this  
Plasmarobo

Linker Errors solved

Recommended Posts

I am somewhat new to using DirectX I encountered a few linker errors on the test project that I am doing. I cannot tell if these are windows (MSPSDK) linker errors, or DirectX library errors. Anyway, I looked up the error codes, but found myself overwhelmed. I am not using MFC or any of the Standard C options that it tells me I should turn off (at least, I don't think I am). Anyway, if I could get somehelp debugging this that would be awesome :) EDIT: Ahhh! forgot to post code and errors:
1>------ Rebuild All started: Project: Austens Direct X, Configuration: Debug Win32 ------
1>Deleting intermediate and output files for project 'Austens Direct X', configuration 'Debug|Win32'
1>Compiling...
1>stdafx.cpp
1>Compiling...
1>Austens Direct X.cpp
1>Compiling resources...
1>Compiling manifest to resources...
1>Linking...
1>Austens Direct X.obj : error LNK2019: unresolved external symbol _Direct3DCreate9@4 referenced in function _WinMain@16
1>C:\Documents and Settings\Admin\My Documents\C++ Projects\Direct X\Austens Direct X\Debug\Austens Direct X.exe : fatal error LNK1120: 1 unresolved externals
1>Build log was saved at "file://c:\Documents and Settings\Admin\My Documents\C++ Projects\Direct X\Austens Direct X\Austens Direct X\Debug\BuildLog.htm"
1>Austens Direct X - 2 error(s), 0 warning(s)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========


and the Main File:
// Austens Direct X.cpp : Defines the entry point for the application.
//
#include <windows.h>
#include <windowsx.h>
#include "stdafx.h"


#include <d3d9.h>
#include <d3dx9.h>
#include "Austens Direct X.h"

#define WIN32_LEAN_AND_MEAN


bool bactive = true;

bool Init();
bool Frame();
bool Shutdown();
void Error(int code);

LRESULT CALLBACK MsgHandler(
    HWND hwnd,     // window handle
    UINT msg,      // the message identifier
    WPARAM wparam, // message parameters
    LPARAM lparam  // more message parameters
);




int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hPrevInstance,
                   LPSTR lpCmdLine, int nCmdShow)
{


WNDCLASSEX WindowsClass;                                   // declare structure variable

WindowsClass.cbSize =        sizeof(WNDCLASSEX);           // always use this!
WindowsClass.style =         CS_DBLCLKS | CS_OWNDC |
                            CS_HREDRAW | CS_VREDRAW;      // standard settings
WindowsClass.lpfnWndProc =   MsgHandler;                   // we need to write this!
WindowsClass.cbClsExtra =    0;                            // extra class info, not used
WindowsClass.cbWndExtra =    0;                            // extra window info, not used
WindowsClass.hInstance =     hinstance;                    // parameter passed to WinMain()
WindowsClass.hIcon =         LoadIcon(NULL, IDI_WINLOGO);  // Windows logo
WindowsClass.hCursor =       LoadCursor(NULL, IDC_ARROW);  // standard cursor
WindowsClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);  // a simple black brush
WindowsClass.lpszMenuName =  NULL;                         // no menu
WindowsClass.lpszClassName = TEXT("Windows Class");                // class name
WindowsClass.hIconSm =       LoadIcon(NULL, IDI_WINLOGO);  // Windows logo again

RegisterClassEx(&WindowsClass);
MSG msg;
HWND hwnd;

if (!(hwnd = CreateWindowEx(NULL,                   // extended style, not needed
                            TEXT("Windows Class"),         // class identifier
                            TEXT("Windows Class"),        // window title
                            WS_POPUP | WS_VISIBLE,  // parameters
                            0, 0, 800, 600,         // initial position, size
                            NULL,                   // handle to parent (the desktop)
                            NULL,                   // handle to menu (none)
                            hinstance,              // application instance handle
                            NULL)))                 // who needs it?
return(0);



//Initilize DirectX here
IDirect3D9 *iD3D;
if((iD3D = Direct3DCreate9(D3D_SDK_VERSION)) == NULL)
{

}



while(bactive)
{
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
    TranslateMessage(&msg);
    DispatchMessage(&msg);
}





}
    return(0);
}

LRESULT CALLBACK MsgHandler(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
	switch(msg)
	{
	case WM_CREATE:
		//Initialize windows here
		return(0);
	
	case WM_DESTROY:
		
		PostQuitMessage(0);
		return(0);

	case WM_CLOSE:
		DestroyWindow(hwnd);
		return(0);

	case WM_KEYDOWN:
		switch(wparam)
		{
		case VK_ESCAPE:
			//SendMessage (hwnd, WM_DESTROY, NULL, 0) ;
			PostQuitMessage(0);
			bactive = false;
			break;
		}
		return(0);
	}

    return(DefWindowProc(hwnd, msg, wparam, lparam));
}


bool Init()
{
	return true;
}

bool Frame()
{
return true;
}

bool Shutdown()
{
	return true;
}

void Error(int code)
{
	MessageBox(NULL, TEXT("An Error has interupted the program \n Please check you error code against \n those commonly encountered in you manual \n Code:" + code),TEXT("Program has Halted"), MB_ICONERROR);
}


[Edited by - Plasmarobo on April 29, 2006 8:44:45 PM]

Share this post


Link to post
Share on other sites
Hey there Plasmarobo,

Ensure that you're creating a "Win32 Application" and not a "Win32 Console Application".

If you're doing the above correctly then remember to add d3d9.lib and d3dx9.lib to your linker.

Share this post


Link to post
Share on other sites
I am using VC++ 2005 Express's default compiler......

I have linked the Library directory of my DXSDK, so I think that does it.... if not, do I need to use Pragma to link them? Or should I link to each one in the project settings (could you give me the path, ya know, like File-Edit-Projectsettings-lib or something?)
Thanks!


The project is a Win32 Application (not a consol one)

Share this post


Link to post
Share on other sites
go to project settings, then linker, then input, and type the name of each library you need in Additional dependencies (or at least thats how you do it in VC2k3; i haven't downloaded VC2k5, so it might be a tad bit different).

Share this post


Link to post
Share on other sites
I don't have that directory. My linker thing is under Options-Project and Solutions- VC++ Directories- and then it only allows me to link to directories, not single files.

Edit: Oh, I have it under project settings, thank you!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this