LNK2019

Started by
6 comments, last by BillOB1 19 years, 4 months ago
The following code complies with TERResourceManager.h and ActorInfo(Two related files I wrote) perfectly.But it causes a linker error LNK2019 when I tried to link it with a simple WIN32 application which merely has a tWinMain function in it. I am working under windowsXP SP2 with VS.NET 2003 and DX9c( Octobor Update). I think I have included all files needed to build the program,but it just won't work for me.Can anyone help me on this?

#include "StdAfx.h"
#include "terresourcemanager.h"   //the header file
#include <assert.h>
#include <windows.h>
#include <d3d9types.h>
#include <d3dx9.h>

TERResourceManager::TERResourceManager(LPDIRECT3DDEVICE9 pD3DDevice)
{
	this->pRenderDevice =pD3DDevice; 
	this->pResourceTexture =NULL;
	
	//The line below causes error LNK2019
         //The program runs perfectly without the following line
	D3DXCreateTextureFromFile(this->pRenderDevice," ",&(this->pResourceTexture));    

	/*INITCODE*/
		
	ActorInfo* curAI=new ActorInfo;
	curAI->TextureID=0;
	curAI->numColumns=0;
	curAI->numRows=0;
	curAI->numFrames=0;
	curAI->RelX=0;
	curAI->RelY=0;
	curAI->Width_OneFrame=0;
	curAI->Height_OneFrame=0; 
	curAI->frameNum2X =new int[curAI->numColumns];
	curAI->frameNum2Y=new int[curAI->numRows ]; 
	this->fillTranslationTable(curAI); 

}
Edited by Coder: Source tags [Edited by - Coder on December 16, 2004 11:04:00 PM]
Advertisement
Please post the error string you got (not just the error code).

Sorry about that.
Now all I've got is showing below.
I have turned on /VERBOSE so I can get more information about it.But it doesnt seem quite helpful...

Besides, I have looked up in the help file.Error LNK2019 is often caused by "unresolved symbols".The help file also suggests including essential head files.But I can't figure out what's missing...Hmm


Here's output in the Output Window:
------ Started: Project: ExtCode, Configuration: Debug Win32 ------

Compiling...
TERResourceManager.cpp
Linking...
ExtCode.obj : LNK9038:
TERResourceManager.obj : LNK9038:


/machine:x86
/verbose
/out:"C:\DOCUME~1\SHUANG~1\LOCALS~1\Temp\lnk7B.tmp"
/readonly
".\Debug\ExtCode.res"
Microsoft (R) Windows Resource To Object Converter Version 7.10.3052.4
Copyright (C) Microsoft Corporation. All rights reserved.
adding resource. type:ICON, name:1, language:0x0804, flags:0x1010, size:744
adding resource. type:ICON, name:2, language:0x0804, flags:0x1010, size:296
adding resource. type:ICON, name:3, language:0x0804, flags:0x1010, size:3752
adding resource. type:ICON, name:4, language:0x0804, flags:0x1010, size:2216
adding resource. type:ICON, name:5, language:0x0804, flags:0x1010, size:1384
adding resource. type:ICON, name:6, language:0x0804, flags:0x1010, size:9640
adding resource. type:ICON, name:7, language:0x0804, flags:0x1010, size:4264
adding resource. type:ICON, name:8, language:0x0804, flags:0x1010, size:1128
adding resource. type:GROUP_ICON, name:107, language:0x0804, flags:0x1030, size:118
adding resource. type:ICON, name:9, language:0x0804, flags:0x1010, size:744
adding resource. type:ICON, name:10, language:0x0804, flags:0x1010, size:296
adding resource. type:ICON, name:11, language:0x0804, flags:0x1010, size:3752
adding resource. type:ICON, name:12, language:0x0804, flags:0x1010, size:2216
adding resource. type:ICON, name:13, language:0x0804, flags:0x1010, size:1384
adding resource. type:ICON, name:14, language:0x0804, flags:0x1010, size:9640
adding resource. type:ICON, name:15, language:0x0804, flags:0x1010, size:4264
adding resource. type:ICON, name:16, language:0x0804, flags:0x1010, size:1128
adding resource. type:GROUP_ICON, name:108, language:0x0804, flags:0x1030, size:118
adding resource. type:MENU, name:109, language:0x0804, flags:0x1030, size:78
adding resource. type:ACCELERATOR, name:109, language:0x0804, flags:0x30, size:16
adding resource. type:DIALOG, name:103, language:0x0804, flags:0x1030, size:230
adding resource. type:STRING, name:7, language:0x0804, flags:0x1030, size:60
TERResourceManager.obj : error LNK2019:
Debug/ExtCode.exe : fatal error LNK1120: 1

Log file save as¡°file://d:\Internet\My Projects\Vs\VS.NEt Projects\C#\TextureEditor\ExtCode\Debug\BuildLog.htm"
ExtCode - 2 errors£¬0 warnings


---------------------- Complete ---------------------

[Edited by - BillOB1 on December 16, 2004 11:20:16 PM]
Weird, it doesn't say what symbols were unresolved...Is that a VS.NET change from the way VC6 worked, or there's an option for switching this?

That is something i have never seen before i use VS .Net 2003 and it shows pretty much the exact same stuff, but because of that line you should have a look at the libraries that are beeing linked also in your project settings.

Project->Properties->Configuration Properties->Linker->Input : in the Additional Dependencies field make sure you have all of the directx libraries in there that the documentation recommends. I cant remember off the top of my head here but i think the library you need is d3dx9.lib for that function. You should also add the other commonly used libraries: dxerr9.lib dxguid.lib d3dx9dt.lib d3d9.lib (got that list from one of the sample projects).

Hope that helps.
It IS kind of weird since if add these two files(The .cpp and .h) into my previous DX project(The one I have created in VS.NET 2002 but converted to VS.NET 2003 format already).It links all perfectly.But that project has lots of classes and DX headers which are included in several files.I can't track down to what I was missing to make it work in my new project.But I am pretty sure I first created a standard WIN32 project by selecting New Workspace/ C/C++ / WIN32 application(Not Win32 console).After that,I manually add my classes with dx headers included. Then, my program worked. But now I cant't make my new project work the way it should.I'm just so confused...
Yup thats the problem then:

put: dxerr9.lib dxguid.lib d3dx9dt.lib d3d9.lib winmm.lib comctl32.lib

in the Additional Dependencies field
Project->Properties->Configuration Properties->Linker->Input

for new projects that you create.
Quote:Original post by Wolfdog
That is something i have never seen before i use VS .Net 2003 and it shows pretty much the exact same stuff, but because of that line you should have a look at the libraries that are beeing linked also in your project settings.

Project->Properties->Configuration Properties->Linker->Input : in the Additional Dependencies field make sure you have all of the directx libraries in there that the documentation recommends. I cant remember off the top of my head here but i think the library you need is d3dx9.lib for that function. You should also add the other commonly used libraries: dxerr9.lib dxguid.lib d3dx9dt.lib d3d9.lib (got that list from one of the sample projects).

Hope that helps.



Finally,it works. Yup,the dependencies totally threw me off.
Thanks for your great help!!

This topic is closed to new replies.

Advertisement