Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How can I solve this bug in share-ptr signal slot ::-1: error: [CMakeFiles/signalSlotsharePtr_autogen.dir/build.make:58: CMakeFiles/signalSlotsharePtr_autogen] Error 1
Qt 6.12 LTS is out! See what's new in the release blog

How can I solve this bug in share-ptr signal slot ::-1: error: [CMakeFiles/signalSlotsharePtr_autogen.dir/build.make:58: CMakeFiles/signalSlotsharePtr_autogen] Error 1

Scheduled Pinned Locked Moved Unsolved General and Desktop
11 Posts 2 Posters 2.1k 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.
  • N nasimChildOfDesert

    Re: Can't pass a signal with QSharedPointer (or std::shared_ptr<>) between threads

    hi
    the program is this:
    #include <QCoreApplication>
    #include <iostream>
    #include <memory>
    #include <QObject>
    #include <QMetaType>

    class Student : public QObject
    {
    Q_OBJECT

    public:
    void printOrder()
    {
    emit calledtoPrint();
    }

    signals:
    void calledtoPrint();
    };
    Q_DECLARE_METATYPE(Student)

    class Printer : public QObject
    {
    Q_OBJECT
    //uncrustify off
    public slots:
    //uncrustify on
    void print()
    {
    std::cout << " print the request" << std::endl;
    }
    };
    Q_DECLARE_METATYPE(Printer)
    int main(int argc, char* argv[])
    {
    QCoreApplication a(argc, argv);

    std::shared_ptr<Student> std = std::make_shared<Student>();
    std::shared_ptr<Printer> print = std::make_shared<Printer>();
    QObject::connect(std.get(), &Student::printOrder, print.get(), &Printer::print);
    
    std::cout << "Program start " << std::endl;
    
    std->printOrder();
    
    return a.exec();
    

    }

    jsulmJ Offline
    jsulmJ Offline
    jsulm
    Lifetime Qt Champion
    wrote on last edited by
    #2

    @nasimChildOfDesert Please post the actual error.

    https://forum.qt.io/topic/113070/qt-code-of-conduct

    1 Reply Last reply
    0
    • N nasimChildOfDesert

      Re: Can't pass a signal with QSharedPointer (or std::shared_ptr<>) between threads

      hi
      the program is this:
      #include <QCoreApplication>
      #include <iostream>
      #include <memory>
      #include <QObject>
      #include <QMetaType>

      class Student : public QObject
      {
      Q_OBJECT

      public:
      void printOrder()
      {
      emit calledtoPrint();
      }

      signals:
      void calledtoPrint();
      };
      Q_DECLARE_METATYPE(Student)

      class Printer : public QObject
      {
      Q_OBJECT
      //uncrustify off
      public slots:
      //uncrustify on
      void print()
      {
      std::cout << " print the request" << std::endl;
      }
      };
      Q_DECLARE_METATYPE(Printer)
      int main(int argc, char* argv[])
      {
      QCoreApplication a(argc, argv);

      std::shared_ptr<Student> std = std::make_shared<Student>();
      std::shared_ptr<Printer> print = std::make_shared<Printer>();
      QObject::connect(std.get(), &Student::printOrder, print.get(), &Printer::print);
      
      std::cout << "Program start " << std::endl;
      
      std->printOrder();
      
      return a.exec();
      

      }

      N Offline
      N Offline
      nasimChildOfDesert
      wrote on last edited by
      #3

      @nasimChildOfDesert

      it doesnt build and show this:
      :-1: error: [CMakeFiles/signalSlotsharePtr_autogen.dir/build.make:58: CMakeFiles/signalSlotsharePtr_autogen] Error 1

      jsulmJ N 2 Replies Last reply
      0
      • N nasimChildOfDesert

        @nasimChildOfDesert

        it doesnt build and show this:
        :-1: error: [CMakeFiles/signalSlotsharePtr_autogen.dir/build.make:58: CMakeFiles/signalSlotsharePtr_autogen] Error 1

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #4

        @nasimChildOfDesert This is not the actual error!
        The actual error should be somewhere wbove that line. Please post it...

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • N nasimChildOfDesert

          @nasimChildOfDesert

          it doesnt build and show this:
          :-1: error: [CMakeFiles/signalSlotsharePtr_autogen.dir/build.make:58: CMakeFiles/signalSlotsharePtr_autogen] Error 1

          N Offline
          N Offline
          nasimChildOfDesert
          wrote on last edited by
          #5

          @nasimChildOfDesert
          iknow it is not specific error but i have this problem and share it . maybe someone help me.i cant build ,y cmake program in qt

          jsulmJ 1 Reply Last reply
          0
          • N nasimChildOfDesert

            @nasimChildOfDesert
            iknow it is not specific error but i have this problem and share it . maybe someone help me.i cant build ,y cmake program in qt

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #6

            @nasimChildOfDesert Why don't you simply post the error message?!

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            N 1 Reply Last reply
            0
            • jsulmJ jsulm

              @nasimChildOfDesert Why don't you simply post the error message?!

              N Offline
              N Offline
              nasimChildOfDesert
              wrote on last edited by
              #7

              @jsulm
              you know , when i build my program it show this error .
              i send all of the code.did you see that?

              jsulmJ 2 Replies Last reply
              0
              • N nasimChildOfDesert

                @jsulm
                you know , when i build my program it show this error .
                i send all of the code.did you see that?

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #8

                @nasimChildOfDesert I will repeat this one more time: the actual error is above the line you posted! Can you please post the error? You can also post the whole build log.

                This is not the error: :-1: error: [CMakeFiles/signalSlotsharePtr_autogen.dir/build.make:58: CMakeFiles/signalSlotsharePtr_autogen] Error 1
                It just tells you that there was an error. The error message must be ABOVE that line...

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                N 1 Reply Last reply
                0
                • N nasimChildOfDesert

                  @jsulm
                  you know , when i build my program it show this error .
                  i send all of the code.did you see that?

                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #9

                  @nasimChildOfDesert said in How can I solve this bug in share-ptr signal slot ::-1: error: [CMakeFiles/signalSlotsharePtr_autogen.dir/build.make:58: CMakeFiles/signalSlotsharePtr_autogen] Error 1:

                  i send all of the code.did you see that?

                  I'm not asking for code, but for the error message...

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • jsulmJ jsulm

                    @nasimChildOfDesert I will repeat this one more time: the actual error is above the line you posted! Can you please post the error? You can also post the whole build log.

                    This is not the error: :-1: error: [CMakeFiles/signalSlotsharePtr_autogen.dir/build.make:58: CMakeFiles/signalSlotsharePtr_autogen] Error 1
                    It just tells you that there was an error. The error message must be ABOVE that line...

                    N Offline
                    N Offline
                    nasimChildOfDesert
                    wrote on last edited by
                    #10

                    @jsulm
                    im sorry : the compile out put is:
                    11:39:22: Running steps for project signalSlotsharePtr...
                    11:39:23: Starting: "/usr/bin/cmake" --build . --target clean
                    11:39:23: The process "/usr/bin/cmake" exited normally.
                    11:39:23: Starting: "/usr/bin/cmake" --build . --target all
                    [ 25%] Automatic MOC and UIC for target signalSlotsharePtr

                    AutoMoc error

                    "SRC:/main.cpp"
                    contains a "Q_OBJECT" macro, but does not include "main.moc"!
                    Consider to

                    • add #include "main.moc"
                    • enable SKIP_AUTOMOC for this file

                    make[2]: *** [CMakeFiles/signalSlotsharePtr_autogen.dir/build.make:58: CMakeFiles/signalSlotsharePtr_autogen] Error 1
                    make[1]: *** [CMakeFiles/Makefile2:104: CMakeFiles/signalSlotsharePtr_autogen.dir/all] Error 2
                    make: *** [Makefile:84: all] Error 2
                    11:39:23: The process "/usr/bin/cmake" exited with code 2.
                    Error while building/deploying project signalSlotsharePtr (kit: Desktop Qt 5.13.1 GCC 64bit)
                    When executing step "CMake Build"
                    11:39:23: Elapsed time: ۰:۰۰:۰۰.

                    jsulmJ 1 Reply Last reply
                    0
                    • N nasimChildOfDesert

                      @jsulm
                      im sorry : the compile out put is:
                      11:39:22: Running steps for project signalSlotsharePtr...
                      11:39:23: Starting: "/usr/bin/cmake" --build . --target clean
                      11:39:23: The process "/usr/bin/cmake" exited normally.
                      11:39:23: Starting: "/usr/bin/cmake" --build . --target all
                      [ 25%] Automatic MOC and UIC for target signalSlotsharePtr

                      AutoMoc error

                      "SRC:/main.cpp"
                      contains a "Q_OBJECT" macro, but does not include "main.moc"!
                      Consider to

                      • add #include "main.moc"
                      • enable SKIP_AUTOMOC for this file

                      make[2]: *** [CMakeFiles/signalSlotsharePtr_autogen.dir/build.make:58: CMakeFiles/signalSlotsharePtr_autogen] Error 1
                      make[1]: *** [CMakeFiles/Makefile2:104: CMakeFiles/signalSlotsharePtr_autogen.dir/all] Error 2
                      make: *** [Makefile:84: all] Error 2
                      11:39:23: The process "/usr/bin/cmake" exited with code 2.
                      Error while building/deploying project signalSlotsharePtr (kit: Desktop Qt 5.13.1 GCC 64bit)
                      When executing step "CMake Build"
                      11:39:23: Elapsed time: ۰:۰۰:۰۰.

                      jsulmJ Offline
                      jsulmJ Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on last edited by
                      #11

                      @nasimChildOfDesert said in How can I solve this bug in share-ptr signal slot ::-1: error: [CMakeFiles/signalSlotsharePtr_autogen.dir/build.make:58: CMakeFiles/signalSlotsharePtr_autogen] Error 1:

                      contains a "Q_OBJECT" macro, but does not include "main.moc"!

                      This is the error and it also tells you what you should do to fix it:

                      Consider to
                      
                          add #include "main.moc"
                          enable SKIP_AUTOMOC for this file
                      

                      It is better to define QObject based classes in their own header and cpp files.

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      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
                      • Unsolved