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 vb.net and follows the hierarchyax example.
#ifndef NEWCOSMIC17_H #define NEWCOSMIC17_H #include <QObject> class NewCosmic17 : public QObject { Q_OBJECT Q_CLASSINFO("ClassID","{4B2125A6-746A-4BDA-8F20-D2B97DE8839E}") Q_CLASSINFO("InterfaceID","{FC4F46E8-7875-4157-BFD7-2A448BD73E9B}") Q_CLASSINFO("EventsID","{41D6CF05-462F-4DCE-A328-8037659BCDC0}") public: NewCosmic17(QObject *parent = nullptr); ~NewCosmic17(); //signals: /* * 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); private: 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 externalsUnable to find any clue as to what more is required to be done so that the signals work in the library.
-
Hello
I have made a library with this header file. This is library created to be used with C# and vb.net and follows the hierarchyax example.
#ifndef NEWCOSMIC17_H #define NEWCOSMIC17_H #include <QObject> class NewCosmic17 : public QObject { Q_OBJECT Q_CLASSINFO("ClassID","{4B2125A6-746A-4BDA-8F20-D2B97DE8839E}") Q_CLASSINFO("InterfaceID","{FC4F46E8-7875-4157-BFD7-2A448BD73E9B}") Q_CLASSINFO("EventsID","{41D6CF05-462F-4DCE-A328-8037659BCDC0}") public: NewCosmic17(QObject *parent = nullptr); ~NewCosmic17(); //signals: /* * 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); private: 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 externalsUnable to find any clue as to what more is required to be done so that the signals work in the library.
@TheCrowKaka
Hi
You must flag/place under it with
signals:
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.
-
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.
@TheCrowKaka
Super :)
Well that is why code review is super effective.
Its far easier to spot something in other code that one's own.