Skip to main content
GameDev.net gamedev.net
🔒 Locked

More dreaded linker errors..

Started by Fuzztrek Oct 25, 2002 at 3:14 PM 4 replies 250+ views
Original Post
Fuzztrek
Fuzztrek
Hello all.. Alright.. I have a really really nice direct input class, and all seems to be going.. somewhat alright, but I have a few problems. First of all, when I first compiled my program and ran it, it worked fine and i could use the mouse and keyboard. However, when I shut down my program failed and i got some sort of error in VS.net that directed me to some sort of disassembly.. stuff. Anyway, I thought that it probably had something to do with me not releasing my objects.. or soemthign like that.. anyway. This was kind of a problem when I was making some D3D classes, but most of the time i just had to rearrange the way that I released my interface (ie, release it before clearing other non-related arrays). Anyway, I went to just change some stuff around in my destructor, compiled, and got a couple of linker errors.. I''m not sure what I changed, as far as I know i just commented out a couple of lines. So, I uncommented them, and still got the error. So.. after a day of trying to figure out what might have gone wrong, I''ve decided that I need help.. I feel kinda bad, because just yesterday I had a another linker error, but oh well.. if someone really has a problem with me posting than I guess they''ll tell me. Anyway, this is the error I''m getting:
DI_main.obj : error LNK2001: unresolved external symbol _IID_IDirectInput8A
.\Debug/MainApp.exe : fatal error LNK1120: 1 unresolved externals
 
I understand the error, becuase I''ve had it before, and it was resolved by including dxguid.lib. Note that I include my libs with #pragma comment(lib, "filename.lib"). Not sure if that has anything to do with it. Here are my files: (main.cpp. Seems to be not understanding IID_IDirectInput8 in Init function)
  
#include "DI_cincludes.h"

// Constructor

DI_main::DI_main(){

	pro_lpDI = NULL;
}

// Destructor

DI_main::~DI_main(){

	//Free();

}

// Free

void DI_main::Free(){
	
	RCOM(pro_lpDI);
	
	pro_HWND = NULL;
	pro_HINSTANCE = NULL;
}

// Create Direct Input

HRESULT DI_main::Init(HWND hwnd, HINSTANCE hinstance){

	// Free everything

	Free();

	// Check for HWND

	if(hwnd == NULL){

		LogError("<li>DI Main:  No HWND");
		return E_FAIL;
	}

	// Check for HINSTANCE

	if(hinstance == NULL){

		LogError("<li>DI Main:  No HINSTANCE");
		return E_FAIL;
	}

	// Save HWND and HINSTANCE

	pro_HWND = hwnd;
	pro_HINSTANCE = hinstance;

	// Create Direct Input

	if(FAILED(DirectInput8Create(pro_HINSTANCE, DIRECTINPUT_VERSION, IID_IDirectInput8, (void **)&pro_lpDI, NULL))){

		LogError("<li>DI Main: Failed creating DI");
		return E_FAIL;
	}

	// Successful!

	LogInfo("<li>DI Main: Created successfully");
	return S_OK;
}

// Get HWND

HWND DI_main::GetHWND(){

	return pro_HWND;
}

// Get HINSTANCE

HINSTANCE DI_main::GetHINSTANCE(){

	return pro_HINSTANCE;
}

// Get DI

IDirectInput8 * DI_main::GetDI(){

	return pro_lpDI;
}
  
DI_cincludes.h (just includes files that include common header files and libs)
  
#include "../Log.h"
#include "DI_includes.h"
#include "DI_main.h"
#include "DI_device.h"
  
DI_includes.h (includes common header files and libs)
  
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#pragma comment(lib, "dxguid.lib")
#pragma comment(lib, "dinput8.lib")
#define DIRECTINPUT_VERSION 0x0800
#include <DINPUT.h>


class DI_main;
class DI_device;

typedef DI_main CDI;
typedef DI_device CDevice;
  
Eh.. I know thats a lot to go through.. hopefully its something really stupid that I accidentally erased/added.. such as an extra braket or something.. i don''t know >.< Thanks in advance!! Fuzztrek ¬_¬
Galapaegos
Galapaegos
Fuzztrek,

All you need to do is go to Tools->Options->Directories, and under the header and library settings move the directory of where you installed the sdk all the way to the top. Its a really silly bug, but its catching previous verions of direct input first and thus it doesn''t see directinput 8. Happy Coding!

Brad
-brad
Fuzztrek
Fuzztrek
Thanks for replying!

I tried what you suggested, but unfortunatly it did not work (they were already at the top). Thanks anyway! Any other suggestions?

¬_¬
Zoot
Zoot
Delete them instead...
GSACP: GameDev Society Against Crap PostingTo join: Put these lines in your signature and don't post crap!
Fuzztrek
Fuzztrek
tried that too =(

I even made sure that all copies of dinput.h were the same.

¬_¬
Fuzztrek
Fuzztrek
Fixed. Sorry to all who had to experience my shear stupidity . Turns out I had also (for some reason) included dinput.lib ASWELL as dinput8.lib. Grr.. so annoying. Thanks anyway!!

¬_¬

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.