I have a library VMSCore which has VMSObject::public QObject.
I implemented factory class which inherit from VMSObject class.
After I built my library, I try to link it to my exe project.
I get linkage error:
Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol "public: virtual int __cdecl
VMS::Factory::qt_metacall(enum QMetaObject::Call,int,void * *)"
(?qt_metacall#Factory#VMS##UEAAHW4Call#QMetaObject##HPEAPEAX#Z)
referenced in function "public: virtual int __cdecl
VMS::Algorithm::Factory::qt_metacall(enum QMetaObject::Call,int,void *
*)" (?qt_metacall#Factory#Algorithm#VMS##UEAAHW4Call#QMetaObject##HPEAPEAX#Z) CVFnVMSExperimental C:\Users\Matvey\cvfn\build\Products\CVFnVMS\mocs_compilation.obj 1
As far as I understand the error, I don't link functions defined in moc files.
What is a right way to link moc-created files in CMake?
Solved.
I had to "set (CMAKE_AUTOMOC ON)" in my cmake file for library.
Related
Using Visual Studio 2017, I am trying to build my latest project which imports libraries, which in turn import methods and functions from .dll files.
When building my project, I get a list of errors like this:
error LNK2001: unresolved external symbol "__declspec(dllimport) void __cdecl UserTracking(void *)" (__imp_?UserTracking##YAXPEAX#Z)
error LNK2001: unresolved external symbol "public: bool __cdecl EACServer::Destroy(void)const " (?Destroy#EACServer##QEBA_NXZ)
error LNK2001: unresolved external symbol "public: bool __cdecl EACServer::Initialize(void)const " (?Initialize#EACServer##QEBA_NXZ)
...
All of the functions listed are from imported libraries.
As an example, the EACServer::Initialize method is defined as so in EACServer.h:
bool Initialize() const;
In the code I am compiling, this function is used as so (the appropriate header files are imported in the .h file ofc):
this->eacServer = EACServer();
this->eacServer.Initialize();
The class definition of EACServer is basic:
class EACServer : IRoot {
...
}
I have been told that these errors are thrown because I am missing the macro which correctly sets the __declspec.
How can I find/implement this macro?
Turns out that although I added the paths to my libraries in the linker additional library directories, I had neglected to add the .lib files in the linker additional dependencies.
I am a newbie to Open Cascade.After building occt-7.3.0-vc14-64 with cmake with no error, i added inc/ in Include Directories and added win64/vc14/libd/ in Library Directories, then added only "include" in main.cpp. But after clicked debug button, i got link error as following:
Error LNK2019 unresolved external symbol "public: __cdecl
Standard_OutOfMemory::Standard_OutOfMemory(char const * const)" (??
0Standard_OutOfMemory##QEAA#QEBD#Z) referenced in function "public:
void __cdecl Standard_OutOfMemory::`default constructor closure'(void)"
(??_FStandard_OutOfMemory##QEAAXXZ)
What else should have be done?
Thanks for any help.
This error is that can't find lib that contain Standard_OutOfMemory.
Standard_OutOfMemory is a class in TKernel.dll, you should add TKernel.lib to project's Additional Dependencies, like on the image below:
There's this class MailHandler in the solution MailTest, which I use to send signals to the class MailCom in the solution MailResponse. My problem revolves around creating an object of the MailHandler class in the MailCom class, which is in a different project, and doing operations from here. What is the most efficient way of establishing the connection without modifying the MailTest project into a lib or DLL?
I need to link with a correct path, but I'm not sure at which settings are important in this case. This is the current error I'm getting when trying to instantiate the MailHandler object:
1> Creating library ..\..\bin\pvc6d.lib and object ..\..\bin\pvc6d.exp
1>CMailCom.obj : error LNK2019: unresolved external symbol "public: class QStringList __thiscall MailHandler::ReturnAllFunctions(void)" (?ReturnAllFunctions#MailHandler##QAE?AVQStringList##XZ) referenced in function "public: __thiscall pvc::hardwarecom::CMailCom::CMailCom(class pvc::data::CData &,class pvc::data::CRudderServo *,class pvc::data::CPropulsionManager *,class QGraphicsScene *)" (??0CMailCom#hardwarecom#pvc##QAE#AAVCData#data#2#PAVCRudderServo#42#PAVCPropulsionManager#42#PAVQGraphicsScene###Z)
1>CMailCom.obj : error LNK2019: unresolved external symbol "public: __thiscall MailHandler::MailHandler(class QObject *)" (??0MailHandler##QAE#PAVQObject###Z) referenced in function "public: __thiscall pvc::hardwarecom::CMailCom::CMailCom(class pvc::data::CData &,class pvc::data::CRudderServo *,class pvc::data::CPropulsionManager *,class QGraphicsScene *)" (??0CMailCom#hardwarecom#pvc##QAE#AAVCData#data#2#PAVCRudderServo#42#PAVCPropulsionManager#42#PAVQGraphicsScene###Z)
1>..\..\bin\pvc6d.exe : fatal error LNK1120: 2 unresolved externals
If you want to use a class of a external project, you can try to #include its header file (MailHandler.h, MailHandler.hxx etc.). I assume thats what you did. Obviously there is also a according source file (MailHandler.cpp, MailHandler.cxx). You can try to add this file to your current project. If you are lucky it compiles and links and your unresolved externals go away. More likely the source file has other dependencies and does not compile/link right away.
This is rather a hack - not a robust long term solution.
It's better to copy the file with its dependencies into your project
It's best to extract the needed classes in a separate project (i.e creating a lib or dll) that your project and that the other solution 'MailTest' are using as a independent client.
You are missing the correct libraries. The linker does not know about the functions called, add LIBS += -Lpath/to/lib -lthelib to your pro file.
I would like to use the features of QCustomPlot to draw some results from my openCV projects.
I didn't find a way to include QCustomPlot to my Microsoft Visual Studio 2010. I have included or course the cpp and h file into my project. But, I think what is still missing for me is regarding its linker and the additional dependencies (.lib file)
1>moc_ex4.obj : error LNK2019: unresolved external symbol "public: void __thiscall ex4::plot_graphs(void)" (?plot_graphs#ex4##QAEXXZ) referenced in function "private: static void __cdecl ex4::qt_static_metacall(class QObject *,enum QMetaObject::Call,int,void * *)" (?qt_static_metacall#ex4##CAXPAVQObject##W4Call#QMetaObject##HPAPAX#Z)
1>C:\Users\310114602\Documents\Visual Studio 2010\Projects\ex4_120313\Win32\Debug\\ex4.exe : fatal error LNK1120: 1 unresolved externals
I searched for it but no results.
Where shall I download it?
It looks like you either didn't moc your cpp file or you simply forgot to compile and link against the moc generated .cpp file.
I'm trying to compile osgearth library with VS2010. The library uses CMake, so after setting all dependencies it generates a VS2010 solution file. However when running build in VS I get this linker error (and 200 similar ones)
Error 7 error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall std::basic_ofstream >::`vbase destructor'(void)" (_imp??_D?$basic_ofstream#DU?$char_traits#D#std###std##QAEXXZ) referenced in function "public: virtual void __thiscall osgEarth::DiskCache::setImage(class osgEarth::TileKey const &,struct osgEarth::CacheSpec const &,class osg::Image const *)" (?setImage#DiskCache#osgEarth##UAEXABVTileKey#2#ABUCacheSpec#2#PBVImage#osg###Z) C:\swproj\osgearth-src\src\osgEarth\Caching.obj osgEarth
I'm not very familiar with C++, is there anything else I have to set up?
You're missing a reference to std::ofstream. You either need an #include in one of your files or a reference to the standard library dll in your project.