Unresolved external symbol error - com

I am getting the following error in my VC++ COM project. What is the problem in linking the lib files here?
Error 4 error LNK2019: unresolved external symbol _BVUOpen#8 referenced in function "unsigned int __stdcall AFunc(void *)" (?AFunc##YGIPAX#Z) CBillAcceptor.obj BillAcceptorCOM

Here are the explanation of the LNK2019 error : MSDN.
Look for a problem of definition about BVUOPen symbol ! The problem si inside the method AFunc Maybe, you haven't declare it correctly or haven't link the library or haven't export the symbol...

Probably, you need to link against some external library that contains the object code for the BVUOpen function. The name of that library is not obvious from your error message, but it should be possible to work out from the documentation you are coding from.

Related

Can not use CString parameter (which was built in VC6.0) at VC2019

I have an old DLL which was built in VC6.0.
And I want to use this DLL at VC2019 project.
This DLL file is a MFC DLL, and contains a lot of classes and functions.
There is no problem for using classes and functions except these three functions (which contains CString parameter).
The exported DLL functions (class functions) are like below:
class CColorListCtrl : public CListCtrl
{
...
public:
int AddColumn(CString szHeaderStr, int nColWidth);
int AddItem(CString szItem);
bool SetItemTip(int nRow, int nCol, CString szTip);
...
}
And the link errors are like below:
error LNK2001: unresolved external symbol "public: int __thiscall CColorListCtrl::AddColumn(class ATL::CStringT<char,class StrTraitMFC<char,class ATL::ChTraitsCRT<char> > >,int,int)" (?AddColumn#CColorListCtrl##QAEHV?$CStringT#DV?$StrTraitMFC#DV?$ChTraitsCRT#D#ATL#####ATL##HH#Z)
error LNK2001: unresolved external symbol "public: int __thiscall CColorListCtrl::AddItem(class ATL::CStringT<char,class StrTraitMFC<char,class ATL::ChTraitsCRT<char> > >)" (?AddItem#CColorListCtrl##QAEHV?$CStringT#DV?$StrTraitMFC#DV?$ChTraitsCRT#D#ATL#####ATL###Z)
error LNK2001: unresolved external symbol "public: bool __thiscall CColorListCtrl::SetItemTip(int,int,class ATL::CStringT<char,class StrTraitMFC<char,class ATL::ChTraitsCRT<char> > >)" (?SetItemTip#CColorListCtrl##QAE_NHHV?$CStringT#DV?$StrTraitMFC#DV?$ChTraitsCRT#D#ATL#####ATL###Z)
The DLL exported functions are like below:
?AddColumn#CColorListCtrl##QAEHVCString##HH#Z
?AddItem#CColorListCtrl##QAEHVCString###Z
?SetItemTip#CColorListCtrl##QAE_NHHVCString###Z
For fix this problem, I changed Project Character Set (Project Setting -> General -> Character Set) as "Use Multi-Byte Character Set", but the problem is not solved.
I noticed that CString class was changed, so the CString classes at VC6 and VC2019 are different.
I have no idea to resolve this prblem. Also I can not change DLL, because I removed the project for this DLL.
Please help me.
Thank you.
CString in VC++ 6 and VC++ 2019 are not compatible with each other because there is a difference.
That is, if you use CString as a parameter for the export function in VC6 dll, you cannot directly call VC6 dll in VS2019.
I suggest one solution:
First, create a dll that acts as a repeater in vc6. The export function of this dll uses, for example, LPCTSTR as a parameter. Let this dll be A.dll and the original dll be B.dll.
Inside the A.dll, the export function of the B.dll is called and the result is converted to LPCTSTR and returned.
VS2019 calls the export function of A.dll. LPCTSTR is compatible between VS2019 and VS6, so you can solve your problem in this way.
There is some notes in this article (CStringT Class) where it states:
If your code contains the workaround for linker errors that is
described in Exporting String Classes Using CStringT, you
should remove that code. It is no longer needed.
I notice that the subsequent article that it refers to does state:
In the past, MFC developers have derived from CString to specialize
their own string classes. In Microsoft Visual C++.NET (MFC 8.0), the
CString class was superseded by a template class called CStringT.
It provides an explanation of what you can do to resolve linker issues.

What library in OpenDDS contains "OpenDDS::DCPS::operator<<"?

I'm having an issue linking my shared library against an OpenDDS (v3.9) static library because I am unable to find where this method signature is located.
Here's the error.
[exec] libs/mylib/ABTypeSupportImpl.cpp:74: error: undefined reference to 'OpenDDS::DCPS::operator<<(OpenDDS::DCPS::Serializer&, short)'
[exec] collect2: error: ld returned 1 exit status
[exec] make: *** [/tmp/mybuild/lib_ab/obj/local/armeabi-v7a/lib_ab.so] Error 1
ABTypeSupportImpl.cpp is auto generated from compiling the IDL. More of the same errors follow. Because of the namespace (OpenDDS::DCPS), I would think this would be found within the library libOpenDDS_Dcps.a, but using nm on this lib and then grep'ing for "operator" or "<<", produces no results. Could it be that name mangling is a bit stranger for overloaded operators? I ran this on every library file within $DDS_ROOT/lib, but found nothing.
And if I recompile the IDL and remove member fields of structs with datatypes such as short or long, then there are no errors and everything links fine.
Anyone know what library this method signature might be located?
These operators are declared in 'dds/DCPS/Serializer.h' but implemented inline in Serializer.inl. Probably you compile OpenDDS with inlining enabled (its default) but when you compile your application you compile with inlining disabled.

unresolved external symbol while using a library

i have a header file named NetworkInterfaceInfoProvider.h.
in this header file i declare a class as follow:
#ifndef INETWORK_INTERFACE_INFO_PROVIDER_H
#define INETWORK_INTERFACE_INFO_PROVIDER_H
#pragma once
/*#include "stdafx.h"*/
#include "IConfig.h"
#include "NetworkAddapterAddresses.h"
#include "InstaledAddapters.h"
namespace IRNetwork
{
class CLASS_DECLSPEC INet;
struct CLASS_DECLSPEC GenericIPAddress;
/*
* provide information about all network interface related adapters such as installed interfaces , addresses , best routes and ...
* TO DO: implement Other OS's
*/
class CLASS_DECLSPEC INetworkInterfaceInfoProvider
{
public:
INetworkInterfaceInfoProvider(void);
~INetworkInterfaceInfoProvider(void);
int32_t GetBestRouteTo(char* destIp,uint16_t port,ip_t *ip);
int32_t GetBestRouteTo(GenericIPAddress* ip);
private:
INet* snet;
};
}
#endif
when i want to use it in my console application i got following linker error
*note: the library of above code has been linked to my console application.
CLASS_DECLSPEC is dll import/export definition*
error LNK2019: unresolved external symbol "__declspec(dllimport)
public: int __thiscall
IRNetwork::INetworkInterfaceInfoProvider::GetBestRouteTo(char
,unsigned short,char ()[65])" (_imp?GetBestRouteTo#INetworkInterfaceInfoProvider#IRNetwork##QAEHPADGPAY0EB#D#Z)
referenced in function "void __cdecl test_adapters(void)"
(?test_adapters##YAXXZ) testDhcpv4.obj testDhcpv4
what is wrong here?
Hmm. From the error I would say importing looks good. So maybe there was an error while exporting. Assuming you are using Visual Studio, you can use dumpbin to check if your dll is exporting correctly:
Open the Visual Studio Command Prompt (available from the windows start menu) and type
dumpbin /EXPORTS yourlib.dll
Then you should see our export, something like (dump from one of my dlls):
...
170 A9 00108120 ??1AbstractParam#param#core#megamol##UAE#XZ = ??1BoolParam#param#core#megamol##UAE#XZ (public: virtual __thiscall megamol::core::param::BoolParam::~BoolParam(void))
...
If the function your are calling is not listed, you should doublecheck if your dllexport is set correctly while building your dll.
If the function is listed, but looks different, you should check for the calling conventions to be the same for your application and your dll.
If the function is listed and the name looks identical to what the error message says, doublecheck if you are linking the import library of the dll correctly.
Also check if the runtime-configuration is the same for your application and your dll (e.g. Multi-Threaded-Dll or Multi-Threaded-Debug-Dll).

_DllMain#12 already defined

I try to build subproject ExplorerPlugin from mDNSResponder-107.6.tar.gz archive but
receive next link error:
uafxcwd.lib(dllmodul.obj) : error LNK2005: _DllMain#12 already defined
how to solve it?
I had exactly the same problem and this fixed it:
https://stackoverflow.com/a/19930430/625227
Enter this code in the .cpp file where your DLLMain function is
extern "C" { int _afxForceUSRDLL; }
Looks like you are using MFC. It already has a DllMain entrypoint, required to initialize MFC properly. Check this KB article for recommended workarounds. Hard to otherwise provide a better answer, you didn't provide a link and it looks to me like this is Apple code, very un-mfc-ish.

undefined symbols error in c++, while the header file exists

Sorry if I'm asking a dumb question, but I've been stuck on this one for quite some time now. So, I'm trying to compile a program using cmake, that calls functions from a videosource.cpp file, with its corresponding videosource.h file.
The compiler finds the file, but when linking makes this error:
Undefined symbols:
"VideoSourceFactory::construct()", referenced from:
_main in main.cpp.o
However, in the videosource.h, the function is defined, as:
class VideoSourceFactory {
public:
VideoSourceFactory();
...}
Does anyone have an idea what can be causing this kind of errors to happen??
Thanks in advance!
videosource.cpp file must be added to the files list, together with main.cpp.