MyParser.obj : error LNK2001:-6ren">
gpt4 book ai didi

c++ - 错误 LNK2001 : unresolved external symbol "class ATL::CTraceCategory ATL::atlTraceException" (? atlTraceException@ATL@@3VCTraceCategory@1@A)

转载 作者:行者123 更新时间:2023-11-30 03:58:03 27 4
gpt4 key购买 nike

我试图在 Visual Studio 2013 上运行这个程序,但是当我包含一个对象 - myparser.obj 时,我收到以下错误:

1>MyParser.obj : error LNK2001: unresolved external symbol "class ATL::CTraceCategory ATL::atlTraceException" (?atlTraceException@ATL@@3VCTraceCategory@1@A)
1>MyParser.obj : error LNK2001: unresolved external symbol "public: static class ATL::CTrace ATL::CTrace::s_trace" (?s_trace@CTrace@ATL@@2V12@A)
1>MyParser.obj : error LNK2019: unresolved external symbol _AtlTraceVA referenced in function "public: void __cdecl ATL::CTrace::TraceV(char const *,int,unsigned long,unsigned int,char const *,char *)const " (?TraceV@CTrace@ATL@@QBAXPBDHKI0PAD@Z)

是myparser有问题还是其他原因?

代码4A.h

#include <afxwin.h>
#define IDC_BUTTON 501
#define nInput 6

extern double parse(CString,int,double [],int []);

class CCode4A : public CFrameWnd
{
protected:
typedef struct
{
CString label,item;
CPoint hm;
CEdit ed;
CRect rc,display;
} INPUT;
INPUT input[nInput+1];
CStatic result;
CFont Arial80;
CButton btn;
int idc;
public:
CCode4A();
~CCode4A();
afx_msg void OnPaint(),OnButton();
DECLARE_MESSAGE_MAP()
};

class CMyWinApp : public CWinApp
{
public:
virtual BOOL InitInstance();
};

代码4A.cpp

#include "Code4A.h"

CMyWinApp MyApplication;

BOOL CMyWinApp::InitInstance()
{
CCode4A* pFrame = new CCode4A;
m_pMainWnd = pFrame;
pFrame->ShowWindow(SW_SHOW);
pFrame->UpdateWindow();
return TRUE;
}

BEGIN_MESSAGE_MAP(CCode4A,CFrameWnd)
ON_WM_PAINT()
ON_BN_CLICKED(IDC_BUTTON,OnButton)
END_MESSAGE_MAP()

CCode4A::CCode4A()
{
Create(NULL,"Code4A: Scientific Calculator",
WS_OVERLAPPEDWINDOW,CRect(0,0,700,350),NULL);
Arial80.CreatePointFont(80,"Arial");
idc=301;
input[0].hm=CPoint(200,20);
for (int i=1;i<=nInput;i++)
input[i].hm=CPoint(input[0].hm.x+10,input[0].hm.y+50+(i-1)*30);
input[1].label="t";
input[2].label="u";
input[3].label="v";
input[4].label="x";
input[5].label="y";
input[6].label="Expression";
btn.Create("Compute",WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON,
CRect(CPoint(input[0].hm.x,input[0].hm.y+5),CSize(100,20)),
this,IDC_BUTTON);
for (i=1;i<=nInput-1;i++)
input[i].ed.Create(WS_CHILD | WS_VISIBLE | WS_BORDER,
CRect(input[i].hm.x+70,input[i].hm.y,input[i].hm.x+150,
input[i].hm.y+20),this,idc++);
input[nInput].ed.Create(WS_CHILD | WS_VISIBLE | WS_BORDER,
CRect(input[nInput].hm.x+70,input[nInput].hm.y,
input[nInput].hm.x+350,input[nInput].hm.y+20),this,idc++);
result.Create("",WS_CHILD | WS_VISIBLE | SS_CENTER | WS_BORDER,
CRect(input[nInput].hm.x+50,input[nInput].hm.y+50,
input[6].hm.x+150,input[6].hm.y+70),this,idc++);
}

CCode4A::~CCode4A()
{
}

void CCode4A::OnPaint()
{
CPaintDC dc(this);
CString str;
dc.SelectObject(Arial80);
dc.SetBkColor(RGB(255,255,255));
dc.SetTextColor(RGB(100,100,100));
for (int i=1;i<=nInput;i++)
dc.TextOut(input[i].hm.x,input[i].hm.y,input[i].label);
dc.TextOut(input[6].hm.x,input[6].hm.y+50,"Result");
}

void CCode4A::OnButton()
{
CString str;
int i,psi[nInput+1];
double z,psv[nInput+1];
for (i=1;i<=nInput;i++)
input[i].ed.GetWindowText(input[i].item);
psi[1]=19;
psi[2]=20;
psi[3]=21;
psi[4]=23;
psi[5]=24;
for (i=1;i<=nInput;i++)
psv[i]=atof(input[i].item);
z=parse(input[nInput].item,5,psv,psi);
str.Format("%lf",z);
result.SetWindowText(str);
}

最佳答案

检查您的项目设置,您缺少对 atls.lib 的链接器输入。

将项目设置为/NODEFAULTLIB 并将其显式链接到 atls.lib

/NODEFAULTLIB

关于c++ - 错误 LNK2001 : unresolved external symbol "class ATL::CTraceCategory ATL::atlTraceException" (? atlTraceException@ATL@@3VCTraceCategory@1@A),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27612395/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com