【问题标题】:undefined symbols error in c++, while the header file existsc++中的未定义符号错误,而头文件存在
【发布时间】:2010-12-02 14:01:23
【问题描述】:

对不起,如果我问的是一个愚蠢的问题,但我已经被这个问题困扰了很长一段时间了。因此,我正在尝试使用 cmake 编译一个程序,该程序从 videosource.cpp 文件调用函数及其对应的 videosource.h 文件。

编译器找到了文件,但是在链接的时候出现这个错误:

Undefined symbols:
"VideoSourceFactory::construct()", referenced from:
_main in main.cpp.o

然而,在videosource.h中,函数被定义为:

class VideoSourceFactory {
public:
VideoSourceFactory();
...}

有谁知道是什么导致了这种错误的发生??

提前致谢!

【问题讨论】:

    标签: cmake symbols undefined


    【解决方案1】:

    videosource.cpp 文件必须与 main.cpp 一起添加到文件列表中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-08-07
      • 2011-02-27
      • 2014-06-01
      • 2018-04-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多