Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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.

share|improve this question
1  
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? –  Mike Vine May 8 '13 at 22:38
 
Excellent. I was declaring a static pyPgEnv but not defining it. Added PyObject* CPythonPg::pyPgEnv; to CPythonPg.cpp and that solved the issue. Learned something new today. On the destructor CScripting, it was already defined. The error went away when I added the definition for pyPgEnv (first error). Thanks! (if you make this a proper answer I will selected as best). –  nemesys May 9 '13 at 14:51
add comment

1 Answer

up vote 0 down vote accepted

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.