Question

I'm trying to import some working Visual C++ code into Qt Creator and I'm having some compilation error I can't explain. This is my code:

// TabSprite.h

#include <GraphicsItem.h>

namespace appetizer {

class TabSprite : public GraphicsItem {

public:

  TabSprite(GraphicsWindow* parentWindow);

}

// TabSprite.cpp

#include <TabSprite.h>
using namespace appetizer;

TabSprite::TabSprite(GraphicsWindow* parentWindow): GraphicsItem(parentWindow) {

}

And Qt Creator give me this error (at the constructor declaration in TabSprite.cpp):

Undefined reference to 'appetizer::GraphicsItem::GraphicsItem(appetizer::GraphicsWindow*)

However GraphicsItem is properly declared in GraphicsItem.h so I don't understand why the compilers doesn't find it. Can anybody see what could be wrong with this code?

Was it helpful?

Solution

That means that you didn't define the constructor of GraphicsItem.

OTHER TIPS

The constructor is probably declared in TabSprite.h (although your code doesn't show that). That's why it compiles. But the constructor isn't defined anywhere, or, less likely, the unit where it is defined isn't included in the linking process. That's why it doesn't link.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top