undefined reference to `Class::Class()'

梦想与她 提交于 2019-12-06 11:49:46

Undefined reference errors mean you either forgot to write define the missing function (by writing an implementation in the .cpp file), or you forgot to link the appropriate object file or library into the final binary.

In this case, it's the later reason. You need to include MainWindowPane.o in the linker command in your makefile:

g++  -g -o QPI_frontend main.o MainWindow.o StartButton.o `pkg-config gtkmm-2.4 --libs`
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                        you need MainWindowPane.o in here

It's complaining that you are trying to call a default constructor for MainWindowPane that doesn't exist.

My guess is that MainWindowPane only defines ctors with parameters, and you are using it as a base class, and you either didn't define a ctor for the derived class, or the ctor you did define didn't call the base with parameters.

class MyDerived : public MainWindowPane
{
  public:
      MyDerived() {....}    // bad

      MyDerived(int x) : MainWindowPane(x)  // good
          {....} 

UPDATE:

OK, ignore the above (written before you posted the code). It seems to be complaining about this line"

MainWindow::MainWindow()// : /*list,*/ pane(/*list*/) 
{ 
    pane;     // Error HERE.
}

And I really have no idea what the purpose of that line is. You are just referencing a data member, without doing anything with it. It can probably be deleted.

UPDATE2: pane will be default constructed if you do nothing:

MainWindow::MainWindow()
{ 
}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!