E
E
Egor Panfilov2015-10-22 02:38:21
C++ / C#
Egor Panfilov, 2015-10-22 02:38:21

How to fix LNK2019 error when using static method?

There is a set of various static functions ( link ).
I need a function in it

static CAAEllipticalObjectDetails Calculate(double JD, const CAAEllipticalObjectElements& elements, bool bHighPrecision);

I'm writing a wrapper for this set of functions so that I can use them in a library so that I can use them in Delphi later.
I decided to do it "cheap and cheerful" (using the so-called flattering method - link ).
The problem occurs in the line with the above function call
CAAEllipticalObjectDetails ResTemp;
ResTemp = CAAElliptical::Calculate(JD, CAAObjectElem, bHighPrecision);

Error text:
AA.obj : error LNK2019: unresolved external symbol "public: static class CAAEllipticalObjectDetails __cdecl CAAElliptical::Calculate(double,class CAAEllipticalObjectElements const &,bool)" ([email protected]@@[email protected]@[email protected]@[email protected]) referenced in function [email protected]

I have suspicions about:
1) __cdecl
2) that somehow I’m calling the method incorrectly
3) I didn’t declare something I
’m studying C ++ recently, I create a library because the main program is written in Delphi and I don’t want to rewrite it and time, and the functions used consist of even more code and there is no desire to rewrite selectively either. There is a desire to understand the work with dll.
Thanks for answers.
UPD: Indeed, I forgot to mention that this set of functions is connected to the project using the include of the main header file (the full text of AA.cpp calling it ).
Connection
#include "aaplus\AA+.h"
In this case, neither the header nor the file with the method is connected to the project. If I understand kloppspb's clarifications correctlyand Stanislav Makarov , then I need to correct this moment.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Martyanov, 2015-10-22
@erakli

There is no method implementation in the project. Add CPP/LIB.

S
Stanislav Makarov, 2015-10-22
@Nipheris

Theoretically, it is not necessary to include the header file in the project, this is for your convenience (so that you do not lose the files that you have in the project). But cpp is necessary for anyone, because. otherwise, the compiler will not be asked to compile it, and the linker will not be told that there is an object file (which will be obtained after compilation) that contains implementations of certain functions. The result is that the linker searches and searches, and does not find the method release.
If you had lib instead of cpp, then the situation is the same, only without the compilation step. Roughly, you can think of a lib file as a group of object files put together. The already compiled code is in it, so it must be transferred immediately to the linker. To do this, the linker's keys specify the so-called Library Directories - directories where to look for libraries, as well as dependencies - which specific lib-files should be viewed when linking. The studio has both a global list of such directories and local settings for each project.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question