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. Using Qt5 with CLion and having this problem

Using Qt5 with CLion and having this problem

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 3.1k Views 1 Watching
  • 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.
  • F Offline
    F Offline
    Fuchsiaff
    wrote on last edited by
    #1

    So since my QtCreator syntax highlighting doesn't work, I decided to try out CLion.

    Here's my cmake file:

    cmake_minimum_required(VERSION 3.1.0)
    
    project(untitled)
    
    set (CMAKE_PREFIX_PATH "/Users/fuchsiaff/Qt/5.12.0/clang_64")
    set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
    
    # Find includes in corresponding build directories
    set(SOURCE_FILES main.cpp mainer.cpp mainer.h)
    add_executable(untitled ${SOURCE_FILES})
    
    set(CMAKE_INCLUDE_CURRENT_DIR ON)
    # Instruct CMake to run moc automatically when needed
    set(CMAKE_AUTOMOC ON)
    # Create code from a list of Qt designer ui files
    
    # Find the QtWidgets library
    find_package(Qt5 REQUIRED COMPONENTS Core Widgets Gui)
    
    # Use the Widgets module from Qt 5
    target_link_libraries(untitled Qt5::Core Qt5::Widgets Qt5::Gui)
    

    The program compiles just fine when there are no class definitions but as soon as I add Mainer.h and Mainer.cpp to my code

    Mainer.h :

    #ifndef MAINER_H
    #define MAINER_H
    
    #include <QWidget>
    
    class mainer : public QWidget
    {
    Q_OBJECT
    public:
        explicit mainer(QWidget *parent = nullptr);
    
    signals:
    
    public slots:
    };
    
    #endif // MAINER_H 
    

    Mainer.cpp :

    #include "mainer.h"
    
    mainer::mainer(QWidget *parent) : QWidget(parent)
    {
    
    }
    

    And after trying to compile that, I get this error:

    [ 33%] Linking CXX executable untitled
    Undefined symbols for architecture x86_64:
      "vtable for mainer", referenced from:
          mainer::mainer(QWidget*) in mainer.cpp.o
      NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    make[3]: *** [untitled] Error 1
    make[2]: *** [CMakeFiles/untitled.dir/all] Error 2
    make[1]: *** [CMakeFiles/untitled.dir/rule] Error 2
    make: *** [untitled] Error 2
    
    1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Fuchsiaff said in Using Qt5 with CLion and having this problem:

      add_executable

      move this after setting automoc option - otherwise automoc is not enabled I would guess

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

      F 1 Reply Last reply
      4
      • Christian EhrlicherC Christian Ehrlicher

        @Fuchsiaff said in Using Qt5 with CLion and having this problem:

        add_executable

        move this after setting automoc option - otherwise automoc is not enabled I would guess

        F Offline
        F Offline
        Fuchsiaff
        wrote on last edited by
        #3

        @Christian-Ehrlicher

        THANK YOU!!!

        It worked!

        B 1 Reply Last reply
        0
        • F Fuchsiaff

          @Christian-Ehrlicher

          THANK YOU!!!

          It worked!

          B Offline
          B Offline
          bogong
          wrote on last edited by
          #4

          @Fuchsiaff Have you got good experience in using CLion with QT? I've got a lot of troubles with QT Creator only for last month dozen of crashes and broken highlighting. I am seeking alternative because there are always something wrong with Qt Creator.

          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