error LNK2019: unresolved external symbol
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].unions
.partners[nPartner] = atoi(member.getAttribute("id"));
networkMatrix[j]
= 1;//The element of matrix (jth row and ith column) is set as "1"
nPartner++;
}
if (memberType == "offspring") {
interviews[currentInterview].unions
.offsprings[nOffspring] = atoi(member.getAttribute("id"));
networkMatrix[j]
= 2;//The element of matrix(jth row and ith column) is set as "2"
nOffspring++;
}
if ( (memberType !="partner") & (memberType !="offspring") ){
networkMatrix[j]
= 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 ", networkMatrix
[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

