Undefined reference to class constructor, including .cpp file fixes

前端 未结 6 1624
萌比男神i
萌比男神i 2020-12-24 14:14

The problem I am having is that, when I call a constructor for a class I have created I get the following error.

main.cpp:20: undefined reference to

6条回答
  •  悲&欢浪女
    2020-12-24 14:42

    I had the same issue in Qt, where I forgot to add the class to the pro file. Apparently, without adding it to the pro file, the compiler doesn't recognize it. So I added it in, and then ran qmake again, and that silved the problem.

    Basically, you need to add the file in the sources.

提交回复
热议问题