2013年5月2日 星期四

C#中呼叫C++ DLL(VS2010 + OpenCV2.4)

將C++封裝成DLL檔

  1. 建立win32控制專案,應用程式類型選擇為"DLL"
  2. 加入函式內容CPP檔
  3. 在主程式函式前加上 extern "C" __declspec(dllexport)
    例: 
    extern "C" __declspec(dllexportvoid myFunction(...) {...}
  4. 編譯成功後在Debug(Release)資料夾中生成DLL數個相關檔案
  5. DLL封裝完成