[Qt-interest] LNK2001: unresolved external symbol "private: __cdecl QObject::QObject(class QObject const &)"

Stuart Longland redhatter at gentoo.org
Tue May 10 10:54:03 CEST 2011


On 10/05/2011 6:21 PM, Stuart Longland wrote:
> QObject(parent), where parent is a QObject* should not be calling
> QObject(QObject &).  The only other place QObject appears is right up
> the top of the file where I #include <QObject>.

Okay, found the problem.

This class, since its a proxy class for a SOAP web service sometimes
might fail for various reasons, and so in the event of such a failure, I
throw this error class as an exception:

> #ifndef _DATA_SOAPERROR_H
> #define _DATA_SOAPERROR_H
> 
> #include <QString>
> #include <QObject>
> #include <QMetaType>
> 
> namespace PTrak {
> 	namespace SOAP {
> 		/*! 
> 		 * Type for gSOAP errors
> 		 */
> 		class Error : public QObject {
> 			Q_OBJECT
> 			public:
> 				Error();
> 				Error(const Error& err);
> 				Error(int code, const char* fault, const char* detail);
> 
> 				int	code;
> 				QString	fault;
> 				QString	detail;
> 		};
> 	}
> }
> 
> Q_DECLARE_METATYPE(PTrak::SOAP::Error)
> 
> #endif

I was creating one of these and throwing it; passing by value... i.e:
> 		throw Error(rv, 	this->proxy->soap_fault_string(),
> 					this->proxy->soap_fault_detail());

For whatever reason, while gcc gets the idea, MSVC decides that this
requires the use of the QObject copy constructor.  I've decided to
remove the references to QObject and ditch the metatype declarations
since this was a left-over from earlier troubleshooting.

As always, the problems are found in the place you least expect them. :-)

Thanks to all who replied.  Hopefully the above gives others' clues to
solving similar problems.

Regards,
-- 
Stuart Longland (aka Redhatter, VK4MSL)      .'''.
Gentoo Linux/MIPS Cobalt and Docs Developer  '.'` :
. . . . . . . . . . . . . . . . . . . . . .   .'.'
http://dev.gentoo.org/~redhatter             :.'

I haven't lost my mind...
  ...it's backed up on a tape somewhere.



More information about the Qt-interest-old mailing list