Important: Please read the Qt Code of Conduct -

Signals in the DLL giving unresolved external symbol error...

  • Hello

    I have made a library with this header file. This is library created to be used with C# and and follows the hierarchyax example.

    #ifndef NEWCOSMIC17_H
    #define NEWCOSMIC17_H
    #include <QObject>
    class NewCosmic17 : public QObject
        NewCosmic17(QObject *parent = nullptr);
         * this signal is emitted when ever the state of machine changes or
         * a command to change the state of machine is called.
         * */
        void MachineState(bool isConnected);
         * This signal is emitted whenever an error occurs.
         * */
        void ErrorEmitted(int ErrNum,QString ErrDescript);  //
         * This signal is emitted whenever the marking complete signal is recieved
         * from the marking machine.
         * */
        void MarkingComplete();
         * This signal is emitted whenever marking is stopped with a stop button.
         * */
        void MarkingStopped();
    public slots:
        int ConnecttoMachine(QString ipaddress);
        void DisConnect();
        int StartMarking(bool issimulate);
        int AssignDesign(QString designnamewithpath);
        void macstate(bool value);
        void StartBtnTriggered();
        void MarkComp();
        void EmStopisPressed();
        void DisconMachine();
    #endif // NEWCOSMIC17_H

    Now, if i remove the signals given here, the library compiles well.

    However, with the signals, it gives errors...

    Creating library release\newCosmic171.lib and object release\newCosmic171.exp
    newcosmic17.obj : error LNK2019: unresolved external symbol "public: void __thiscall NewCosmic17::MachineState(bool)" (?MachineState@NewCosmic17@@QAEX_N@Z) referenced in function "private: void __thiscall NewCosmic17::macstate(bool)" (?macstate@NewCosmic17@@AAEX_N@Z)
    newcosmic17.obj : error LNK2019: unresolved external symbol "public: void __thiscall NewCosmic17::ErrorEmitted(int,class QString)" (?ErrorEmitted@NewCosmic17@@QAEXHVQString@@@Z) referenced in function "public: int __thiscall NewCosmic17::AssignDesign(class QString)" (?AssignDesign@NewCosmic17@@QAEHVQString@@@Z)
    newcosmic17.obj : error LNK2019: unresolved external symbol "public: void __thiscall NewCosmic17::MarkingComplete(void)" (?MarkingComplete@NewCosmic17@@QAEXXZ) referenced in function "private: void __thiscall NewCosmic17::MarkComp(void)" (?MarkComp@NewCosmic17@@AAEXXZ)
    newcosmic17.obj : error LNK2019: unresolved external symbol "public: void __thiscall NewCosmic17::MarkingStopped(void)" (?MarkingStopped@NewCosmic17@@QAEXXZ) referenced in function "private: void __thiscall NewCosmic17::EmStopisPressed(void)" (?EmStopisPressed@NewCosmic17@@AAEXXZ)
    release\newCosmic171.dll : fatal error LNK1120: 4 unresolved externals

    Unable to find any clue as to what more is required to be done so that the signals work in the library.

  • Lifetime Qt Champion

    You must flag/place under it with
    Else the compiler just see a function signature with no body defined and that's an undefined.

    Also to emit signals, there must be an event loop running.
    Its unclear how you handle that.

  • Ha Ha

    Thanks mrJJ for pointing out a very silly mistake that I was doing.

    I just happened to comment out the signals: and forgot to uncomment that in the process of solving the other errors that i faced and solved step by step.

    I just uncommented the signals and the library got compiled.

    Thanks for poniting out my mistake.

  • Lifetime Qt Champion

    Super :)
    Well that is why code review is super effective.
    Its far easier to spot something in other code that one's own.

Log in to reply