windows環境下MFC呼叫libtorch

2021-10-08 04:54:47 字數 2549 閱讀 1157

1.新建mfc應用程式,設定為release  x64執行模式,並設定為realease可斷點除錯模式(自行網上查詢),其中sdl檢查設定為否;

2.新增mfc程式所需環境變數:

vc++--包含目錄:

e:\software\opencv_2.4.13.5\opencv\build\include

e:\software\opencv_2.4.13.5\opencv\build\include\opencv

e:\software\opencv_2.4.13.5\opencv\build\include\opencv2

c:\users\lvnengbin\downloads\libtorch-win-shared-with-deps-1.1.0\libtorch\include

c:\users\lvnengbin\downloads\libtorch-win-shared-with-deps-1.1.0\libtorch\include\torch\csrc\api\include

c:\program files\nvidia corporation\nvtool***t\include

c:\program files\nvidia gpu computing toolkit\cuda\v9.2\include

vc++--庫目錄:

e:\software\opencv_2.4.13.5\opencv\build\x64\vc14\lib

c:\users\lvnengbin\downloads\libtorch-win-shared-with-deps-1.1.0\libtorch\lib

c:\program files\nvidia gpu computing toolkit\cuda\v9.2\lib\x64

c:\program files\nvidia corporation\nvtool***t\lib\x64

torch.lib

c10.lib

caffe2.lib

nvtool***t64_1.lib

cudart.lib

c10_cuda.lib

opencv_videostab2413.lib

opencv_ts2413.lib

opencv_superres2413.lib

opencv_stitching2413.lib

opencv_contrib2413.lib

caffe2_gpu.lib

cufft.lib

curand.lib

cudnn.lib

cublas.lib

opencv_nonfree2413.lib

opencv_ocl2413.lib

opencv_gpu2413.lib

opencv_photo2413.lib

opencv_objdetect2413.lib

opencv_legacy2413.lib

opencv_video2413.lib

opencv_ml2413.lib

opencv_calib3d2413.lib

opencv_features2d2413.lib

opencv_highgui2413.lib

opencv_imgproc2413.lib

opencv_flann2413.lib

opencv_core2413.lib

kernel32.lib

user32.lib

gdi32.lib

winspool.lib

shell32.lib

ole32.lib

oleaut32.lib

uuid.lib

comdlg32.lib

advapi32.lib

libprotobuf.lib

程式標頭檔案:

#include "stdafx.h"

// // #include // #include #include "mfclibtorchtest.h"

#include "mfclibtorchtestdlg.h"

#include "afxdialogex.h"

#include#undef unicode //這個一定要加,否則會編譯錯誤

//#include // 引入libtorch標頭檔案

//#include "torch/torch.h"

#include #include #include #include "opencv2/imgproc/imgproc.hpp"

#include #include #include #include #include #include // one-stop header.

using namespace cv;

需要特別注意的是後面的標頭檔案順序很重要。通過測試發現,需要將torch相關標頭檔案放在opencv相關庫檔案後面,就可以編譯通過,可能是因為兩者有部分編譯是重複的吧。

MFC下OpenGL環境搭建

過載mfc中的wm crate訊息響應函式int oncreate lpcreatestruct lpcreatestruct 顯示呼叫init函式,如下 int c3dstereoview oncreate lpcreatestruct lpcreatestruct 在init函式 自定義的 中完...

CVS使用 windows環境下

經驗 1,wincvs中執行checkout動作的單位是 module 即匯入cvs倉庫的專案名稱。import時有設定,要記好。2,cvsroot pserver username password localhost 倉庫名 3,初始化乙個cvs倉庫,並將乙個現有專案匯入到cvs中 1 通過cv...

Windows環境下安裝Apache PHP

3.2 php相關配置。複製 d php5 php.ini recommended 重新命名為 php.ini,該檔案為php的配置檔案。3.3 新增 d php5 和 d php5 ext到系統環境變數。3.4 為了可以使用mysql我們還需要複製以下檔案到 c windows system32目...