You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

C++在VS中出现LNK2019/LNK1120未找到proc函数定义链接错误怎么办

出现LNK2019和LNK1120错误的核心原因是Manipulator类声明的proc成员函数没有对应的实现:你在Manipulator.cpp中定义的proc是全局作用域下的独立函数,和类内声明的成员函数不属于同一个实体,链接器无法找到类成员函数的实现就会抛出未解析外部符号错误。

修正方案

修改Manipulator.cpp中的proc函数定义,添加类作用域限定符Manipulator::,修正后的代码如下:

#include "Manipulator.h"

Manipulator::Manipulator() {}
Manipulator::~Manipulator() {}

void Manipulator::proc(std::string p, int f, std::string c)
{
    // switch-case p to c based on f: 

    return;
}

额外排查项

如果修改后仍报错,可依次排查:

  • 确认Manipulator.cpp已经被添加到当前Visual Studio项目的编译序列中,未加入项目的源文件不会参与编译链接
  • 清理项目编译缓存,执行「清理解决方案」后重新「生成解决方案」,排除增量编译缓存导致的异常
  • 确认头文件守卫语法正确,可将#endif MANIPULATOR_H调整为符合标准的写法#endif // MANIPULATOR_H

内容的提问来源于stack exchange,提问作者AndrewGreen

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.24 12:06:04