1

I am working on a cmake qt project. While I was trying to compile a custom library, which is a QObject, and a custom executable, which is a QApplication, a linker error was occured.

[build] Undefined symbols for architecture x86_64:
[build]   "vtable for ChessieObjects::Syntax", referenced from:
[build]       ChessieObjects::Syntax::Syntax(QObject*) in libChessieSyntaxObject.a(ChessieSyntaxObject.cpp.o)
[build]       ChessieObjects::Syntax::~Syntax() in libChessieSyntaxObject.a(ChessieSyntaxObject.cpp.o)
[build]   NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
[build] ld: symbol(s) not found for architecture x86_64

Header file is below:

class Syntax : public QObject
{
    Q_OBJECT
    
public:
    Syntax(QObject* parent = NULL);
    virtual ~Syntax();

};

Source file is below:

Syntax::Syntax(QObject* parent)
    : QObject(parent)
{
    CHESSIE_EXPECT(TRUE);
}

Syntax::~Syntax()
{
    CHESSIE_EXPECT(TRUE);
}

CMakeLists.txt is below

add_library(
    ChessieSyntaxObject
)

target_link_libraries(
    ChessieSyntaxObject
    PUBLIC
        ChessieCore
        Qt5::Core
        Qt5::Widgets
)
target_sources(
    ChessieSyntaxObject
    PRIVATE
        ChessieSyntaxObject.cpp
)

I could not find where the problem is. If you help me, I will be very appreciate.

0 Answers0