QCustomPlot linker - c++

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.

Related

How to define macro which correctly sets the __declspec

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.

linkage of qt objects in cmake

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.

VC++ Problems using gumbo-query (linking error)

I've got a VC++ project, and I'm attempting to use the extension of the gumbo-query library, found here. This library wraps/extends Google's gumbo-parser found here. The following is the exact steps I've taken - I'm not very familiar with importing libraries, so I've done what I do to use the Boost libraries:
In Visual Studio (VS Community 2013), under the project settings -> Configuration Properties -> C/C++ -> General I have put the path to a folder that contains all of the source files from both of the projects linked above. Specifically, I placed the .c, .cpp and .h files from the src folder of both projects and referenced these in my projects settings as an include directory.
Following the example file for the project that extends Google's gumbo-parser (found here), I added these two lines to import the library:
#include "Document.h"
#include "Node.h"
At this point, my solution compiles fine. However, continuing to follow the example file, adding the first variable declaration:
CDocument d;
Causes a linker error, as follows:
1>Main.obj : error LNK2028: unresolved token (0A0003B7) "public: __thiscall CDocument::CDocument(void)" (??0CDocument##$$FQAE#XZ) referenced in function "private: void __clrcall MyApplication::Main::worker_DoWork(class System::Object ^,class System::ComponentModel::DoWorkEventArgs ^)" (?worker_DoWork#Main#MyApplication##$$FA$AAMXP$AAVObject#System##P$AAVDoWorkEventArgs#ComponentModel#4##Z)
1>Main.obj : error LNK2028: unresolved token (0A0003B8) "public: virtual __thiscall CDocument::~CDocument(void)" (??1CDocument##$$FUAE#XZ) referenced in function "private: void __clrcall MyApplication::Main::worker_DoWork(class System::Object ^,class System::ComponentModel::DoWorkEventArgs ^)" (?worker_DoWork#Main#MyApplication##$$FA$AAMXP$AAVObject#System##P$AAVDoWorkEventArgs#ComponentModel#4##Z)
1>Main.obj : error LNK2019: unresolved external symbol "public: __thiscall CDocument::CDocument(void)" (??0CDocument##$$FQAE#XZ) referenced in function "private: void __clrcall MyApplication::Main::worker_DoWork(class System::Object ^,class System::ComponentModel::DoWorkEventArgs ^)" (?worker_DoWork#Main#MyApplication##$$FA$AAMXP$AAVObject#System##P$AAVDoWorkEventArgs#ComponentModel#4##Z)
1>Main.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall CDocument::~CDocument(void)" (??1CDocument##$$FUAE#XZ) referenced in function "private: void __clrcall MyApplication::Main::worker_DoWork(class System::Object ^,class System::ComponentModel::DoWorkEventArgs ^)" (?worker_DoWork#Main#MyApplication##$$FA$AAMXP$AAVObject#System##P$AAVDoWorkEventArgs#ComponentModel#4##Z)
1>..{omitted}..\MyApplication.exe : fatal error LNK1120: 4 unresolved externals
This error appears to occur no matter where I put a CDocument instantiation.
What can I do to rectify this? VS seems to think the includes are fine, and moreso when I put in CDocument d; it lights up to show it recognises the CDocument type.
As always, it's clear I've been a JS developer for too long. I really did need to compile a .lib file. Thank you to Christian for reminding me of this.
The original gumbo-parser project by Google includes a VS project. I opened this and compiled it, fixing all of the project settings problems so that I could import it into my project, which I did via the Configuration Properties -> Linker -> Input -> Additional Dependencies setting for my VS project.
Next, I added the extra source files from the wrapper library gumbo-query, where I had to fix a naming conflict between parser.h/parser.cpp from the original gumbo-parser project and the Parser.h/Parser.cpp file in the wrapper library. I also changed all references to #include <gumbo.h> to #include "gumbo.h"
Eventually, I got a gumbo.lib file containing both the original and the wrapper libraries, and this imported into my project and I now seem to be able to successfully use the functions.

Protobuffers in c++ and error LNK2019: unresolved external symbol

I am new to c++ and visual studio 2012 so probably the problem is between the screen and the chair. I performed the following steps;
I made a simple proto file with the option optimize_for = LITE_RUNTIME
Create the matching h and c files with protoc
Compiled the library libprotobuf-lite.lib
Created a new console Visual Studio 2012 project.
Copied the libprotobuf-lite.lib where my single source file is.
Created a new folder named protobuffers
Copied the c, h and the google directory from the protobuffers src directory to the protobuffers folder
Added the protobuffers folder as an Additional Include Directory
Added the library file to the linker through Additional Dependencies
Compiled the following source file;
#include <iostream>
#include "protobuffers\genome.pb.h"
int main()
{
genomeMessage::Genome genome;
return 0;
}
Stuck... I get the following error;
1>Source.obj : error LNK2019: unresolved external symbol "public: __cdecl genomeMessage::Genome::Genome(void)" (??0Genome#genomeMessage##QEAA#XZ) referenced in function main
1>Source.obj : error LNK2019: unresolved external symbol "public: virtual __cdecl genomeMessage::Genome::~Genome(void)" (??1Genome#genomeMessage##UEAA#XZ) referenced in function main
1>C:\Projects\testproto\x64\Debug\testproto.exe : fatal error LNK1120: 2 unresolved externals
So I know it is not a missing lib file because if I move the lib file the linker complains that it can't find it. The problem is that I have no clue how to fix this ... anyone?
According to this message:
1>Source.obj : error LNK2019: unresolved external symbol "public: __cdecl genomeMessage::Genome::Genome(void)" (??0Genome#genomeMessage##QEAA#XZ) referenced in function main
1>Source.obj : error LNK2019: unresolved external symbol "public: virtual __cdecl genomeMessage::Genome::~Genome(void)" (??1Genome#genomeMessage##UEAA#XZ) referenced in function main
the source file that declares genomeMessage::Genome::Genome(void) and genomeMessage::Genome::~Genome(void) is not part of your project.
In particular, it sounds like you haven't added the genome.pb.cc file (which is created by the Protocol Buffers compiler) to your project.

Help on jrtplib and jthread

I have some link error problems when trying to compile using jrtplib and jthread on my simple project. The errors are:
Error 4 fatal error LNK1120: 3 unresolved externals C:\Users\Chicko\Desktop\tryout\Debug\tryout.exe
Error 1 error LNK2019: unresolved external symbol "public: virtual __thiscall RTPSession::~RTPSession(void)" (??1RTPSession##UAE#XZ) referenced in function _wmain tryout.obj
Error 2 error LNK2019: unresolved external symbol "public: __thiscall RTPSessionParams::RTPSessionParams(void)" (??0RTPSessionParams##QAE#XZ) referenced in function _wmain tryout.obj
Error 3 error LNK2019: unresolved external symbol "public: __thiscall RTPSession::RTPSession(class RTPRandom *,class RTPMemoryManager *)" (??0RTPSession##QAE#PAVRTPRandom##PAVRTPMemoryManager###Z) referenced in function _wmain tryout.obj
and here is my main program:
// tryout.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <rtpsession.h> //Confused to put "" or <>
#include <rtpsessionparams.h>
#include <rtpudpv4transmitter.h>
int _tmain(int argc, _TCHAR* argv[])
{
RTPSession session;
RTPSessionParams sessionparams;
RTPUDPv4TransmissionParams transparams;
sessionparams.SetOwnTimestampUnit(1.0/8000.0);
transparams.SetPortbase(8000);
return 0;
}
For your information, I do not import any header file from those libraries into my project. I use additional include libraries in the project setting and put `"..\jlib\jthread-1.2.1\src";"..\jlib\jrtplib3.8.2\src" (this is the folder where all the headers are stored). How do I fix this? Where should i put jrtplib.lib and jthread.lib? Please help...
Have you added jrtplib.lib and jthread.lib under your project linker options?
You can do this on the project property page under
"Configuration properties->Linker->Input->Additional Dependencies" and make sure that the directory that contains the lib files has been added to your library path: Either on the project properties
"Linker->General->Additional Library Directories"
or under the global VS settings (Doesn't apply to VC2010)
"Tools->Options" "Projects and Solutions->VC++ Directories->Library Files"
Under VC2010 you'll have to edit the property sheet of the project.
I see that it's a bit late to answer and I'm not so expert on Windows (I'm more a Linux user), but some day ago I've tried JRTPLIB on Windows and I had the same problem when I compiled the example in release mode and the lib in debug mode (I see that you use the debug mode). Hope it can help.