Visual C++ 6에서이 이상한 링커 오류가 발생합니다. 도구를 선택하지 않았습니다. 어디서부터 시작해야할지 모르겠다. (제한된 C++ 경험이있다.)파이썬 임베딩 프로젝트에서 VC++ 6 "unresolved externals"
CScripting.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall CScripting::~CScripting(void)" ([email protected]@[email protected])
CPythonPg.obj : error LNK2001: unresolved external symbol "private: static struct _object * CPythonPg::pyPgEnv" ([email protected]@@[email protected]@A)
이 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
이 CSripting.h이다 (I는이 클래스를 작성하지 않았고, 나는 변경할 수 없습니다 그것은 내 수업 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
이 유형의 오류가 발생할 수 있습니까?
수정 : 일부 오타가 수정되었습니다.
을 포함하지 않는 다른 cpp에있는 정의처럼 보인다. CPythonPgsm.cpp 파일에'PyObject * CPythonPg :: pyPgEnv;'를 추가하십시오. 그러면 첫 번째 오류가 해결됩니다. 두 번째 오류는 'CScripting'에 대한 소멸자를 선언하지만 cpp 파일에 정의되어 있지 않은 CScripting.h를 포함하는 것처럼 보입니다. CScripting.cpp에서 정의해야하거나, 이미 포함되어 있지 않은 다른 cpp에서 이미 정의 된 것처럼 보입니다. –
우수. 정적 인'pyPgEnv'를 선언했지만 정의하지는 않았습니다. CPythonPg.cpp에'PyObject * CPythonPg :: pyPgEnv;'를 추가하여이 문제를 해결했습니다. 오늘 새로운 것을 배웠습니다. 소멸자'CScripting'에서는 이미 정의되어 있습니다. 'pyPgEnv'에 대한 정의를 추가하면 오류가 사라졌습니다 (첫 번째 오류). 감사! (이 질문을 적절한 대답으로 만들면 나는 최선의 선택을 할 것입니다.) –