未解决的外部符号 - 来自其他项目的静态函数

unresolved external symbol - calling static function from other project

本文关键字:其他 项目 静态函数 外部 符号 未解决      更新时间:2023-10-16

我有两个项目 - proj_1proj_2

proj_1是LIB项目,proj_2是常规项目

proj_2中,我的功能名为 static void proj_2_func()。我试图从 proj_1调用该函数(无需创建对象),但我会得到链接错误-unresolved external symbol

proj_2:
class proj_2_class
{
  public:
   static void proj_2_func();  //the implementation is not relevant
}

proj_1:
in cpp file:
#include proj_2_class.h  // I added the path to "additional include files" in proj_1
void proj_1_class::proj_1_func()
{
  proj_2_class::proj_2_func();
}

很高兴为该错误提供指导。

谢谢。

因为您的函数proj_1_class::proj_1_func调用函数proj_2_class::proj_2_func,后者需要在某个地方提供实现 - 不这样做是导致链接器错误

的原因。