简体   繁体   English

Python嵌入项目中的VC ++ 6“无法解析的外部”

[英]VC++ 6 “unresolved externals” on Python embedding project

I'm getting this bizarre linker errors on Visual C++ 6 (I didn't choose the tool). 我在Visual C ++ 6上遇到这个奇怪的链接器错误(我没有选择工具)。 I don't even know where to start looking on this one (I have limited C++ experience). 我什至不知道从哪里开始着手(我的C ++经验有限)。 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 : 这是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) 这是CSripting.h :(我没有创建此类,除了将实例添加到类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. 编辑 :修正了一些错字。

This is the answer from @Mike Vine, given in a comment. 这是@Mike Vine的回答,并在评论中给出。 Putting it here for bette visibility: 将其放置在此处以提高可见度:

You are declaring a static called pyPgEnv but not defining it. 您正在声明一个名为pyPgEnv的静态变量,但未定义它。 In your CPythonPgsm.cpp file add PyObject* CPythonPg::pyPgEnv;. 在您的CPythonPgsm.cpp文件中添加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. 第二个错误似乎是您包含了CScripting.h,它声明了CScripting的析构函数,但未在任何cpp文件中定义它。 Looks like you need to define it in CScripting.cpp or maybe its already defined in another cpp which which you're not including 看起来您需要在CScripting.cpp中定义它,或者可能已经在另一个cpp中定义了它,但您不包括它

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM