Creating a C ++ library for a C # project - no functions exported

I am working on a project that requires some image processing. The external interface of the program is C # (because the guys thought it was much easier to make the user interface in it). However, since the parts of image processing require a lot of processor juice, I do this part in C ++.

The idea is to link it to a C # project and simply call the function from the DLL to do part of the image processing and allow the C # environment to subsequently process the data. Now the only problem is that, it seems, I cannot make a DLL. Simply put, the compiler refuses to put any function in the DLL that I am compiling.

Since the project requires some testing during development, I created two projects as a C ++ solution. One for Dll and another console application. The console project contains all the files, and I just include the appropriate header in my DLL project file. I thought that the compiler should take the functions that I marked as exportable and make them a DLL. However, this does not happen.

This is how I defined the function in the header:

extern "C" __declspec(dllexport)  void _stdcall RobotData(BYTE* buf, int** pToNewBackgroundImage, int* pToBackgroundImage,  bool InitFlag, ObjectInformation* robot1, ObjectInformation* robot2,   ObjectInformation* robot3, ObjectInformation* robot4,  ObjectInformation* puck);

extern "C" __declspec(dllexport)  CvPoint _stdcall RefPointFinder(IplImage* imgInput, CvRect &imgROI, 
                         CvScalar &refHSVColorLow, CvScalar &refHSVColorHi );

The following is the implementation in the cpp file:

extern "C" __declspec(dllexport)  CvPoint _stdcall RefPointFinder(IplImage* imgInput, CvRect  &imgROI,&refHSVColorLow, CvScalar &refHSVColorHi ) { \\...
                  return cvPoint((int)( M10/M00) +  imgROI.x, (int)( M01/M00 ) +  imgROI.y) ;}

extern "C" __declspec(dllexport)  void _stdcall RobotData(BYTE* buf, int** pToNewBackgroundImage, int* pToBackgroundImage,  bool InitFlag, ObjectInformation* robot1, ObjectInformation* robot2,   ObjectInformation* robot3, ObjectInformation* robot4,  ObjectInformation* puck) { \\ ...};

And my main file for the DLL project looks like this:

#ifdef _MANAGED
#pragma managed(push, off)
#endif

/// <summary> Include files.  </summary>
#include "..\ImageProcessingDebug\ImageProcessingTest.h"
#include "..\ImageProcessingDebug\ImageProcessing.h"


BOOL APIENTRY DllMain( HMODULE hModule, DWORD  ul_reason_for_call, LPVOID lpReserved)
{
 return TRUE;
}

#ifdef _MANAGED
#pragma managed(pop)
#endif

, . DLL 1.36 , . ? alt text C++ ( C++ DLL), . . , .

? ,

+3
1

, , DLL . , " ", .

DLL cpp __declspec (dllexport). , RefPointFinder() RobotData(). , DLL , , -.

.h DLL . DLL.

0

Source: https://habr.com/ru/post/1737436/


All Articles