Question

I'm getting this bizarre linker errors on Visual C++ 6 (I didn't choose the tool). I don't even know where to start looking on this one (I have limited C++ experience). These are the errors:

CScripting.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall CScripting::~CScripting(void)" (??1CScripting@@UAE@XZ) 
CPythonPg.obj : error LNK2001: unresolved external symbol "private: static struct _object * CPythonPg::pyPgEnv" (?pyPgEnv@CPythonPm@@0PAU_object@@A)

This is CPythonPg.h:

#ifndef _CPYTHONPG_H_
#define _CPYTHONPG_H_

#include <sstream>
#include <Python.h>
#include "pgt.h"

using namespace std;

class CPythonPg {

private:

    static PyObject* pyPgEnv;

public: 

CPythonPg();
~CPythonPg();

protected:

static PyObject* getPyPgEnv(PGTYPE* pgt1, PGTYPE* pgt2);

};
#endif

This is CSripting.h: (I didn't create this class, and I can't change it except for adding the instance to my class CPythonPg)

#ifndef _CSCRIPTING_H_
#define _CSCRIPTING_H_

#include <string>
#include <vector>
#include <map>
#include <set>
#include <exception>
#include <sstream>
#include <fstream>
#include <locale>
#include <stdlib.h>
#include <direct.h>
#include <windows.h>
#include <io.h>
#include "pgt.h"

class CPythonPg;          // added for python functionality

using namespace std;

class CScripting {

private:

    string sMod;
    string sCust;
    string sProf;
    string sScript;
    CPythonPg* pyInst;   // added for python functionality

    typedef vector<pair<string, string> > cmdLines_t;
    cmdLines_t vCmdLines;

    bool bFoundPy;        // added for python functionality

public: 

    typedef map<string, string> catalog_t;
    typedef map<string, string> envVars_t;

    CScripting(){}; 
    CScripting(string _sMod, string _sCust, string _sProf, string _sScript, PGTYPE* Pgt1, PGTYPE* Pgt2);

    virtual ~CScripting();

    int findProcessingScripts();
    void run(envVars_t& mEnvVars);
};

#endif

What could cause this type of error?

EDIT: Fixed some typos.

Was it helpful?

Solution

This is the answer from @Mike Vine, given in a comment. Putting it here for bette visibility:

You are declaring a static called pyPgEnv but not defining it. In your CPythonPgsm.cpp file add PyObject* CPythonPg::pyPgEnv;. That should fix the first error. The second error looks like you're including the CScripting.h which declares that the destructor for CScripting but it isn't defined in any of your cpp files. Looks like you need to define it in CScripting.cpp or maybe its already defined in another cpp which which you're not including

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top