'dll loacation Error by running a testcode
I am learning how to use dlls and how to export them. I have created a small program that calls the different components(classes, methods, functions, ect.. ) of my dll file to use them. When I build the project I get no problem, but when I compile the test code I get this error.
Error translation: {The procedure entry point "?Start@K_WrapperTeigha_DXF_DWG@@QAEXXZ" was not found in the DLL "C:\Users\zboussaid\source\repos\WrapperTester\Debug"}.
The image shows that the start method, which is a function in my DLL file, cannot be found in the path where my test code is located. I have tried to configure my properties as shown in this drescription, but as I said, I get this error. I will be very grateful if you can help me
class definition:
extern "C" class KWRAPPERTEIG_API K_WrapperTeigha_DXF_DWG
{
private:
//create Data base
OdDbDatabase* pDb;
//tables
OdDbLinetypeTablePtr w_kOdLinetypeTablePtr;
OdDbLayerTablePtr w_kOdLayerTablePtr;
OdDbTextStyleTablePtr w_kOdTextStyleTablePtr;
OdDbBlockTablePtr w_kOdBlockTablePtr;
OdDbBlockTableRecordPtr w_kOdModelSpaceBlockRecPtr;
//OdDbTextStyleTableRecordPtr pTextStyle;
public:
OdDb::DwgVersion m_OdDwgVersion; // Dwg/Dxf Version
OdDb::SaveType m_OdSaveType; // DWG oder DXF
public:
K_WrapperTeigha_DXF_DWG();
~K_WrapperTeigha_DXF_DWG();
void Start();
}
macros:
#ifdef KWRAPPERTEIG_EXPORTS
#define KWRAPPERTEIG_API __declspec(dllexport)
#ifndef KWRAPPERTEIG__DLL
#define KWRAPPERTEIG__DLL
#endif
#else
#define KWRAPPERTEIG_API __declspec(dllimport)
#endif
Solution 1:[1]
@YujianYao-MSFT & Kiner_shah I really appreciate your help. I have solved the problem. My problem was that I created the dll file on Friday and then got the idea to change the location of creating the dll file and forgot about it. Then on Monday I copied the old file which does not contain my start() method. So the problem was the wrong parameterization of the dll file setting.
Solution 2:[2]
This essentially means that your macro KWRAPPERTEIG_API
was not correctly defined. It should have expanded to __declspec(dllexport)
in order for the class functions to be exported.
extern "C"
is supposed to turn of name mangling of functions, so they can be used by C. That can work, because C understands functions, just not overloaded functions. But C doesn't understand classes or class methods, so that it a bit pointless there. You can see that Start@K_WrapperTeigha_DXF_DWG@@QAEXXZ
is still mangled.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Zac Boussaid |
Solution 2 | MSalters |