我在Visual Studio 2012中使用C ++ / CLI创建了一个项目.GUI是在C ++ Builder XE2中创建的,我想从VS C ++ 2012导入生成的DLL,但我无法正确导入它。
HINSTANCE load = LoadLibrary(library);
if (!load)
ShowMessage("Error importing the library");
不幸的是,当我在使用LoadLibrary函数后运行代码时,变量load为NULL。有什么帮助吗?
我理解我需要使用C ++ Builder中的一些实用程序将Visual Studio生成的DLL转换为Borland DLL格式。
编辑:
#include "stdafx.h"
#include <windows.h>
#include <iostream>
using namespace cv;
using namespace std;
//Function declarations
__declspec(dllexport) void __stdcall TestCV();
//-------------------------------------------------------------------------------------------------
BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved )
{
return TRUE;
}
//-------------------------------------------------------------------------------------------------
void __stdcall TestCV()
{
Mat image;
image = imread("a.PNG", IMREAD_COLOR); // Read the file
if(! image.data ) // Check for invalid input
{
cout << "Could not open or find the image" << std::endl ;
return;
}
namedWindow( "Display window", WINDOW_AUTOSIZE ); // Create a window for display.
imshow( "Display window", image ); // Show our image inside it.
}
//-------------------------------------------------------------------------------------------------
int _tmain(int argc, _TCHAR* argv[])
{....}
有人可以帮助我如何将上述源代码生成的DLL从Visual Studio C ++ / CLI导入C ++ Builder吗?
EDIT2 我做了一个发布版本,我复制了DLL项目以及其他DLL文件(我使用OpenCV)。现在我从C ++ Builder项目中收到以下问题:
Runtime Errror!
Program:
R6033
-Attempt to use MSIL code from this assembly during native code initialization
This indicates a bug in your application. It is most likely the result of a calling a MSIL-compiled (/dlr) function from a native consturctor or from a DLLMain