Visual Studio 2012 で C++/CLI を使用してプロジェクトを作成しました。GUI は C++ Builder XE2 で作成されており、生成された DLL を VS C++ 2012 からインポートしたいのですが、正しくインポートできませんでした。
HINSTANCE load = LoadLibrary(library);
if (!load)
ShowMessage("Error importing the library");
残念ながら、LoadLibrary 関数を使用した後にコードを実行すると、変数 load が NULL になります。何か助けはありますか?
Visual Studio によって生成された DLL を Borland DLL 形式に変換するには、C++ Builder のいくつかのユーティリティを使用する必要があることを理解しました。
編集:
#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