LNK2001 unresolved external symbol with CPP_XLOPER - c++

I'm migrating a XLL from 32-Bit to 64-Bit with VS2015 and C++.
I started changing the datatypes. So I switched 'int' to '_int64'.
CPP_XLOPER Create_XLOperHeader_form_Str(const wchar_t*aBegin,_int64 strlen,bool aTranspose){
static CPP_XLOPER xlDefault(L" ");
_int64 l = strlen;
and it throws me the error:
Error
LNK2001 unresolved external symbol
"class CPP_XLOPER __cdecl Create_XLOperTable_from_Str(wchar_t const *,__int64,bool,bool)"
(?Create_XLOperTable_from_Str##YA?AVCPP_XLOPER##PEB_W_J_N2#Z)
I guess I have to modify 'class CPP_XLOPER', isn't it?
Any hint much appreciated,
thx in advance;
surplus

The method linker is complaining about has last two parameters of type bool - ...,int64,bool,bool), while the one you have modified has only one last parameter of type bool. Either you have deleted another existing method, or you have also removed one bool from the implementation (and only you know if this was or was not intentional). But yeah, in general you should fix the function declaration to match the definition.

Related

Unresolving external symbol error

New to C++ programming I am trying to get some open source software running so I can build upon it.
I have 3 *cpp modules. One contains...
const double Qcf[6]= { 1.0, 448.831, 0.64632,0.02832, 28.317, 2.4466};
The other two modules make use of this constant and have a reference to it included in their body
extern double Qcf[];
Each of these modules then has a method/ function
i.e. something like
void routine1()
{
double i;
i = 2 * Qcf[1];
}
I have built the code and it appears that it has compiled (i.e. the *cpp goes to obj) but I get 2 error messages.
LNK2001 unresolved external symbol "double Qcf"
Each error pertains to each of the *obj files
(I also get another LNK1120 Two unresolved externals error, but I think if I solve the LNK2001 issue this will self correct).
Any advice on how to correct this is appreciated in advance.
Qcf is defined as a const double[] in one module, and declared as double[] in the other. You should declare it const too.
(or std::array<double, 6> instead of a C-style array, if your compiler supports C++11)

c++ LNK2001 & LNK1120 compile errors [duplicate]

This question already has answers here:
What is an undefined reference/unresolved external symbol error and how do I fix it?
(39 answers)
Closed 7 years ago.
I am debugging some C++ software, and want to modify an existing function slightly, so that it changes the value of a particular variable used elsewhere in the program.
The function is currently defined as so:
void DataStore::setEraseSelected(){
...
// Function code here
...
}
As it stands, the function works correctly with no problems whatsoever. But, I now want to modify the function, so that it will change the value of a variable used elsewhere in the program. To do this, I have tried passing the variable into the function as a parameter (I have also updated the header file to reflect the changes to the function), and then assigning a value to the variable inside the function:
void DataStore::setEraseSelected(toAMS::DataMessage statusMsg){
...
// Function code here
...
statusMsg.CODE_ERASE = Types::Activated;
...
}
As mentioned, I have added the declaration to the header file, so that it now has the declaration for the function with the parameter, as well as the one for the function without the parameter:
void DataStore::setEraseSelected(toAMS::DataMessage statusMsg);
But when I try and build the code (using Visual Studio 2010), I get the following two compile errors:
error LNK2001: unresolved external symbol "public void_thiscall DataStore::setEraseSelected(void)" (? setEraseSelected#DataStore::QAEXXZ)
error LNK1120: 1 unresolved externals
The first error highlights the project .obj file, which I have tried deleting and building again, but get the same error, and second one highlights the project .exe file, which I have also tried deleting and building again, but get the same error.
Anyone have any ideas why? I've had a look on SO for questions regarding these errors, but none of them seem to clearly explain why I might be getting them. They all seem to suggest that the compiler is possibly looking in the wrong place, but if I undo my changes, then the code compiles with no problems, and I haven't told the compiler to look anywhere else when building the code with my changes...
void DataStore::setEraseSelected(int );
Pass that variable

There is a linkerror when I use opengl in Qt5, about gluOrtho2D

I have try all solutions appeared on the web, but the error still exist.
Here are the error information:
error LNK2019: unresolved external symbol _gluOrtho2D#16 referenced in function "protected: virtual void __thiscall widget::initializeGL(void)" (?initializeGL#widget##MAEXXZ)
I am sure that I have included all the head files correctly, and link files are in their right position, and I also add #define GLUT_DISABLE_ATEXIT_HACK in my file. Besides, when I didn't use Qt, every thing is OK. While I put my code into QGLWidget, the error appeared!
Any more, I noticed that the error information after _gluOrtho2D# is 16, not 32 as other's on the web...
Why? How to correct them?
To answer your question regarding the 16 following the decorated _gluOrhto2D#, that is the size of the argument list you are passing (in bytes) when using the __stdcall calling convention.
Considering gluOrtho2D (...) is supposed to take 4 GLdouble arguments and GLdouble is supposed to be a 64-bit type something seems seriously wrong (the proper decorated name is _gluOrtho2D#32).
Did you by any chance confuse your compiler by attempting to pass gluOrtho2D (...) 4 GLfloat / float variables and/or re-define the prototype for gluOrtho2D (...) anywhere?

C++ Visual Studio Linker Error

I made a boolean method which will return true or false. I want to see the actual value it returns, so I tried this in my main method:
bool answer = methodName(); // I made sure to include the parameters in my code
cout << answer << endl;
It gives me the following error:
error LINK2019: unresolved external symbol "bool ___cdec1" methodName(parameters)
Thanks in advance for the help!
The linker is complaining because you declared your function methodName() but you did not provide a definition for it.

unresolved external symbol due to name mangling

I am facing linker error for a XERCES function while upgrading it from 2.6 to 2.8
unresolved external symbol (?resolveEntity#HandlerBase#xercesc_2_8##UAEPAVInputSource#2#QBG0#Z)
I checked the xerces-c_2.8.lib and found that name lib is bit different that the one in my .obj file It is as shown
?resolveEntity#HandlerBase#xercesc_2_8##UAEPAVInputSource#2#QB_W0#Z
So I understand that linker wont find the match and throw error.
But I am unable to understand why my .obj file contains different signature.
code is including correct header files and lib from still incorrect name.
Any help would be appreciated.
You can use the undname.exe utility to recover the original C++ declaration.
?resolveEntity#HandlerBase#xercesc_2_8##UAEPAVInputSource#2#QBG0#Z converts to:
virtual class xercesc_2_8::InputSource *
__thiscall xercesc_2_8::HandlerBase::resolveEntity(
unsigned short const * const,
unsigned short const * const)
?resolveEntity#HandlerBase#xercesc_2_8##UAEPAVInputSource#2#QB_W0#Z converts to:
virtual class xercesc_2_8::InputSource *
__thiscall xercesc_2_8::HandlerBase::resolveEntity(
wchar_t const * const,
wchar_t const * const)
Note the differences in the argument types, unsigned short vs wchar_t. For some reason, your compiler is not recognizing the wchar_t type. That could be because you have a very old compiler. Or it can be an option set wrong, on msvc it is C/C++, Language, "Treat wchar_t as Built-in type". Or you've got a macro that hacks the string type to unsigned short.
C++ allows function overloading so the parameters to a function are recorded in the name mangling. you might be trying to call the function with different parameter types than what the DLL expects.
Make sure that your header file matches the version of your DLL.