error LNK2019: unresolved external symbol

Hello,
I have been learning C++ just for a month. I tried to write a code which uses an external xmlParser.
My code is:
#include "stdafx.h"
#include <vector>
#include <windows.h>
#include <malloc.h>
#include <string>
#include <iostream>
#include <stdlib.h>
#include "xmlParser.h"
#include <fstream>
//The matrix is defined, it is max 1000*1000
#define MAX_COLS 1000
#define MAX_ROWS 1000
using namespace std;
// In the firts part of the program the main data structure are build. Those are interview, person, union. An interview consists of many
// persons and unions.
struct Union
{
int partners[3];
int nPartners;
int offsprings[10];
int nOffsprings;
int membertype[2];
};
struct person
{
int pid;

};

struct interview
{
Union unions[100]; // set the size of the arrays to store Unions and Persons (must be larger than the relevant Number of unions and persons)
person persons[100];
int nPersons;
};
int nUnions;
// Now the programm can start to parse the kxml file(s) and store the data. To parse
// the file(s) a GNU parser by Frank Vanden Berghen is implemented (http://iridia.ulb.ac.be/~fvandenb/tools/xmlParser.html).
int main(int argc, char **argv)
{
int networkMatrix[MAX_COLS][MAX_ROWS];
interview interviews[40]; // set the number of interviews
CString fileName;
CFileFind finder;
int currentInterview = 0;
BOOL bWorking = finder.FindFile("*.xml");
while (bWorking) // This while loop examines all *.xml files in the current directory one by one. If there are no new files it ends. If the
// *.xml is not a KASS data file the program _seems_ to overlook it and continue with the next one. No error checking built
// in at that point in time.
{
int currentPerson = 0;
int currentUnion = 0;
bWorking = finder.FindNextFile();
fileName = (LPCTSTR) finder.GetFileName();
XMLNode xMainNode=XMLNode::openFileHelper(fileName,"KASS"); // open and parse one Kxml file:
// Now we go through all "persons" and collect the data stored
XMLNode xNode=xMainNode.getChildNode("people");
int i,iterator=0;
interviews[currentInterview].nPersons=xNode.nChildNode("person"); // set n = the number of persons in the file
for (i=0; i<interviews[currentInterview].nPersons; i++)
{
XMLNode person = xNode.getChildNode("person",&iterator);
interviews[currentInterview].persons[currentPerson].pid = atoi(person.getAttribute("pid")); // get pid

currentPerson++;
} // all persons are parsed
// We move on with the the unions. For each union we build to arrays with the ids of partners and offsprings.
XMLNode xUnions=xMainNode.getChildNode("unions");
iterator=0;
nUnions=xUnions.nChildNode("union");

for (i=0; i<nUnions && i<MAX_ROWS; i++)
{
XMLNode xUnion = xUnions.getChildNode("union",&iterator);
int m=xUnion.nChildNode("member");
int l=0;
int nPartner=0;
int nOffspring=0;
for (int j=0; j<m && j<MAX_COLS; j++)
{
XMLNode member = xUnion.getChildNode("member",&l);
string memberType = member.getAttribute("type");

if (memberType == "partner") {
interviews[currentInterview].unionsIdea.partners[nPartner] = atoi(member.getAttribute("id"));
networkMatrix[j]Idea = 1;//The element of matrix (jth row and ith column) is set as "1"
nPartner++;
}
if (memberType == "offspring") {
interviews[currentInterview].unionsIdea.offsprings[nOffspring] = atoi(member.getAttribute("id"));
networkMatrix[j]Idea = 2;//The element of matrix(jth row and ith column) is set as "2"
nOffspring++;
}
if ( (memberType !="partner") & (memberType !="offspring") ){
networkMatrix[j]Idea = 0;//The element of matrix(jth row and ith column) is set as "0"
}
}

} // unions are finished

for (i=0;i<MAX_COLS;i++)
{
for (int j=0;j<MAX_ROWS;j++)
{
printf("%d ", networkMatrixIdea[j]);
}
}
currentInterview++;
} // end while
return 0;
}

I used to have Visual Studio 6.0. the code did not run but compiled with 0 errors. In order to solve the problem I upgraded and have Visual Studio 7.1.
Whereas, the did not run and also not even compile. The errors are like:
networkmatrix3 warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/INCREMENTAL:NO' specification
networkmatrix3 error LNK2019: unresolved external symbol "public: __thiscall XMLNode::~XMLNode(void)" (?1XMLNode@@QAE@XZ) referenced in function _main
networkmatrix3 error LNK2019: unresolved external symbol "public: char const * __thiscall XMLNode::getAttribute(char const *,int *)" (?getAttribute@XMLNode@@QAEPBDPBDPAH@Z) referenced in function _main
networkmatrix3 error LNK2019: unresolved external symbol "public: int __thiscall XMLNode::nChildNode(char const *)" (?nChildNode@XMLNode@@QAEHPBD@Z) referenced in function _main
networkmatrix3 error LNK2019: unresolved external symbol "public: struct XMLNode __thiscall XMLNode::getChildNode(char const *,int *)" (?getChildNode@XMLNode@@QAE?AU1@PBDPAH@Z) referenced in function _main
networkmatrix3 error LNK2019: unresolved external symbol "public: static struct XMLNode __cdecl XMLNode::openFileHelper(char const *,char const *)" (?openFileHelper@XMLNode@@SA?AU1@PBD0@Z) referenced in function _main
networkmatrix3 error LNK2019: unresolved external symbol __endthreadex referenced in function "void __stdcall AfxEndThread(unsigned int,int)" (?AfxEndThread@@YGXIH@Z)
networkmatrix3 error LNK2019: unresolved external symbol __beginthreadex referenced in function "public: int __thiscall CWinThread::CreateThread(unsigned long,unsigned int,struct _SECURITY_ATTRIBUTES *)" (?CreateThread@CWinThread@@QAEHKIPAU_SECURITY_ATTRIBUTES@@@Z)
networkmatrix3 fatal error LNK1120: 7 unresolved externals
How can I solve this problem?
Thanks in advance

[6555 byte] By [bircantuba] at [2007-12-17]
# 1
From where is this XMLNode code?
Is this an external library?
Did you define this LIB in the Linker input section?
MartinRichter at 2007-9-9 > top of Msdn Tech,Visual C++,Visual C++ Language...
# 2
I agree with Martin. It seems that the library definning XMLNode is not linked in your project. Add the Lib to the link command and also use the linker switch /verbose to get details in case this doesn't solve the problem.

Thanks,
Ayman Shoukry
VC++ Team

AymanShoukry at 2007-9-9 > top of Msdn Tech,Visual C++,Visual C++ Language...
# 3

Hello experts,

I got the same error. The program compiles successfully. Below is the source code of my program. It is farily small and simple program. I have also pasted the last part of the output from the linker with verbose. Hopping someone can help me out. It seems a problem with nafxcwd.lib but I am unsure.

/* Setup includes */

#include <stdafx.h>

#include <afxwin.h>

/* Addinitional includes */

#include "ifl.h"

/* Main */

int main(int argc, char** argv)

{

// Variables Declaration

IFL_RC iRetCode = IFL_SUCCESS;

HWND m_hwndMain;

// Get Handle to the main window

m_hwndMain = AfxGetMainWnd()->m_hWnd;

// Initialize the use of IFL

iRetCode = IFLInitialize(m_hwndMain);

if (iRetCode)

{

printf("\n Connection Failed..");

return 4;

}

else

{

printf("\n Connection Succed..");

return 0;

}

// Terminate the use of IFL

IFLTerminate();

}

COMPILE OUTPUT:

Build started: Project: ziden_test, Configuration: Debug Win32

Compiling...

ziden_test.cpp

WINVER not defined. Defaulting to 0x0501 (Windows XP and Windows .NET Server)

Build log was saved at "file://c:\Documents and Settings\jose.moctezuma\My Documents\Visual Studio Projects\ziden_test\ziden_test\Debug\BuildLog.htm"

ziden_test - 0 error(s), 0 warning(s)

- Done -

Build: 1 succeeded, 0 failed, 0 skipped

BUILD OUTPUT:

Rebuild All started: Project: ziden_test, Configuration: Debug Win32

Deleting intermediate files and output files for project 'ziden_test', configuration 'Debug|Win32'.

Compiling...

stdafx.cpp

Compiling...

ziden_test.cpp

WINVER not defined. Defaulting to 0x0501 (Windows XP and Windows .NET Server)

Linking...

Starting pass 1

Processed /DEFAULTLIB:libcpd

Processed /DEFAULTLIB:LIBCD

Processed /DEFAULTLIB:OLDNAMES

Processed /DEFAULTLIB:nafxcwd.lib

Processed /DEFAULTLIB:kernel32.lib

Processed /DEFAULTLIB:user32.lib

Processed /DEFAULTLIB:gdi32.lib

Processed /DEFAULTLIB:msimg32.lib

Processed /DEFAULTLIB:comdlg32.lib

Processed /DEFAULTLIB:winspool.lib

Processed /DEFAULTLIB:advapi32.lib

Processed /DEFAULTLIB:shell32.lib

Processed /DEFAULTLIB:comctl32.lib

Processed /DEFAULTLIB:shlwapi.lib

Processed /DEFAULTLIB:uuid.lib

ziden_test.obj : LNK9038: module unsafe for SAFESEH image.

Searching libraries

Searching ifl.lib:

Found _IFLInitialize@4

Referenced in ziden_test.obj

Loaded ifl.lib(IFL.dll)

Found __IMPORT_DESCRIPTOR_IFL

Referenced in ifl.lib(IFL.dll)

Loaded ifl.lib(IFL.dll)

Found __NULL_IMPORT_DESCRIPTOR

Referenced in ifl.lib(IFL.dll)

Loaded ifl.lib(IFL.dll)

Found IFL_NULL_THUNK_DATA

Referenced in ifl.lib(IFL.dll)

Loaded ifl.lib(IFL.dll)

Searching c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\lib\kernel32.lib:

....

........ here continues searching ....................

....

Finished searching libraries

Finished pass 1

Generating non-SAFESEH image.

nafxcwd.lib(thrdcore.obj) : error LNK2019: unresolved external symbol __endthreadex referenced in function "void __stdcall AfxEndThread(unsigned int,int)" (?AfxEndThread@@YGXIH@Z)

nafxcwd.lib(thrdcore.obj) : error LNK2019: unresolved external symbol __beginthreadex referenced in function "public: int __thiscall CWinThread::CreateThread(unsigned long,unsigned int,struct _SECURITY_ATTRIBUTES *)" (?CreateThread@CWinThread@@QAEHKIPAU_SECURITY_ATTRIBUTES@@@Z)

Debug/ziden_test.exe : fatal error LNK1120: 2 unresolved externals

Build log was saved at "file://c:\Documents and Settings\jose.moctezuma\My Documents\Visual Studio Projects\ziden_test\ziden_test\Debug\BuildLog.htm"

ziden_test - 3 error(s), 0 warning(s)

- Done -

Rebuild All: 0 succeeded, 1 failed, 0 skipped

jimoctezuma at 2007-9-9 > top of Msdn Tech,Visual C++,Visual C++ Language...