Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Undefined symbols for architecture x86_64:
Forum Updated to NodeBB v4.3 + New Features

Undefined symbols for architecture x86_64:

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 3.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    Undertone
    wrote on last edited by Undertone
    #1

    Hey gang,

    I've got a brand new laptop with Xcode 11, QT Creator 4.10.1 Based on QT 5.13.1 and OSX SDK 5.12.4 compiling with c++ 11

    I'm attempting to simply create a new project, and add a keyPressEvent. It's failing right away.

    Here's my entire .h file:

    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H
    
    #include <QMainWindow>
    #include <QKeyEvent>
    
    QT_BEGIN_NAMESPACE
    namespace Ui { class MainWindow; }
    QT_END_NAMESPACE
    
    class MainWindow : public QMainWindow
    {
        Q_OBJECT
    
    public:
        MainWindow(QWidget *parent = nullptr);
        ~MainWindow();
    
    protected:
        void keyPressEvent( QKeyEvent *e );
    
    private:
        Ui::MainWindow *ui;
    };
    #endif // MAINWINDOW_H
    

    From project creation, I added these lines:

    #include <QKeyEvent>

    and

    protected:
    void keyPressEvent( QKeyEvent *e );

    That's it.

    Here's my entire .cpp (unchanged from project creation):

    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    
    
    MainWindow::MainWindow(QWidget *parent)
        : QMainWindow(parent)
        , ui(new Ui::MainWindow)
    {
        ui->setupUi(this);
    }
    
    MainWindow::~MainWindow()
    {
        delete ui;
    }
    
    
    

    Here's the error I get:

    Undefined symbols for architecture x86_64:
    "MainWindow::keyPressEvent(QKeyEvent*)", referenced from:
    vtable for MainWindow in moc_mainwindow.o
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    make: *** [ScrollingText3.app/Contents/MacOS/ScrollingText3] Error 1
    12:01:04: The process "/usr/bin/make" exited with code 2.
    Error while building/deploying project ScrollingText3 (kit: Desktop Qt 5.12.4 clang 64bit)
    When executing step "Make"

    I'm following this example:
    https://www.youtube.com/watch?v=44fCm1KlQGY

    Under General messages, I see this:

    "Project WARNING: Qt has only been tested with version 10.14 of the platform SDK, you're using 10.15.
    Project WARNING: This is an unsupported configuration. You may experience build issues, and by using
    Project WARNING: the 10.15 SDK you are opting in to new features that Qt has not been prepared for.
    Project WARNING: Please downgrade the SDK you use to build your app to version 10.14, or configure
    Project WARNING: with CONFIG+=sdk_no_version_check when running qmake to silence this warning."

    Questions:

    1. What does this mean, and how does one address it?:
      Undefined symbols for architecture x86_64:

    2. How does one downgrade from platform SDK 10.15 to 10.14 (I'm attempting to download Xcode 10 to accomplish this)

    3. Are the two above connected? Am I getting the undefined symbols error because of the SDK version impropriety?

    4. Is the QKeyEvent still the proper function to use in the latest QT for capturing key presses and calling functions from them?

    5. How do I correct this?

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      So where did you implement your MainWindow::keyPressEvent() function?

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      U 1 Reply Last reply
      1
      • Christian EhrlicherC Christian Ehrlicher

        So where did you implement your MainWindow::keyPressEvent() function?

        U Offline
        U Offline
        Undertone
        wrote on last edited by
        #3

        @Christian-Ehrlicher In this example I haven't yet. I did in the c++ file in another test project, but in this one I've narrowed it to the minimal code necessary to reproduce the error.

        Interestingly, if I right click over the function, I don't get the usual Refactor -> add definition in .cpp. So it isn't recognizing it as a valid function (unless I eliminate the QKeyEvent *e from the parens).

        1 Reply Last reply
        0
        • Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          So you wonder that the compiler complains that it doesn't find a function when you declare it but did not define it? Mhhh...
          Either remove the definition or implement your function.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          U 1 Reply Last reply
          4
          • Christian EhrlicherC Christian Ehrlicher

            So you wonder that the compiler complains that it doesn't find a function when you declare it but did not define it? Mhhh...
            Either remove the definition or implement your function.

            U Offline
            U Offline
            Undertone
            wrote on last edited by
            #5

            @Christian-Ehrlicher Good catch. Adding the definition in the c++ file eliminated the error. :P

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved