VS 编程常见错误及解决方法
1.?VS2013?無法打開包括文件:“cv.h"等一些頭文件
解決方法:
cv.h是build\include文件夾下的頭文件,所在文件夾位置是D:\Program Files (x86)\opencv\build\include\opencv,必須將這個路徑添加到OpencvDebugConfiguration.props(見上一篇)中:2.
錯誤一:必須屬性”VSIstallDir”缺失或為空?
解決方式:選擇菜單欄的項目->屬性->配置屬性->常規->平臺集成工具,選擇V90編輯為V100,點擊確定。之后運行就不會再出現必須屬性”VSInstallDir”缺失或為空的錯誤了。?
錯誤二:找不到projectname.exe?
?
解決方式:?
1、選擇菜單欄的項目->屬性->配置屬性->VC目錄->包含目錄->編輯?
?
添加:matlab安裝目錄\extern\include,然后點擊確定?
2、選擇菜單欄的項目->屬性->配置屬性->VC目錄->庫目錄->編輯?
添加:matlab安裝目錄\extern\lib\win64\microsoft?
3、選擇菜單欄的項目->屬性->配置屬性->C++->常規->附加包目錄->編輯,添加:libmx.lib;libeng.lib;libmat.lib; 點擊確定?
4、選擇菜單欄的項目->屬性->配置屬性->鏈接器->輸入->附加依賴項->編輯,添加:libmx.lib;libeng.lib;libmat.lib; 點擊確定?
5、選擇菜單欄的解決方案平臺,選擇win64(倘若沒有這個選項,則選擇配置管理器->選擇平臺->新建->選擇win64->確定即可)?
最后得到運行結果:?
附上測試代碼:
#include "stdafx.h" #include <stdlib.h> #include <stdio.h> #include <string.h> #include "engine.h" #include "matrix.h" #pragma comment(lib,"libeng.lib") #pragma comment(lib,"libmx.lib") int main() { Engine *ep; int i , j ; //show how to open MATLAB engine //for remote ones: //engOpen( ADDRESS OF REMOTE SYSTEM ) ; if (!(ep = engOpen("\0"))){ fprintf(stderr, "\nCan't start MATLAB engine\n"); return EXIT_FAILURE; } //show how to create matrix mxArray *Y = mxCreateDoubleMatrix(1 , 3 , mxREAL) ; //show how to put data in matrix double tmp[3] = {1.0 , 2.0 , 3.0} ; memcpy(mxGetPr(Y) , tmp , sizeof(tmp)) ; //show how to put variables in the Engine engPutVariable(ep , "Y" , Y) ; //show how to execute commands in MATLAB engEvalString(ep, "X = ones(5,1) * Y"); //show how to get variables from the Engine mxArray *X = engGetVariable(ep , "X") ; //show how to manipulate dimensions int dims[10] ; int ndims ; ndims = mxGetNumberOfDimensions(X) ; printf("total number of dimensions is %d\n" , ndims) ; memcpy(dims , mxGetDimensions(X) , ndims * sizeof(int)) ; for ( i = 0 ; i < ndims ; i ++ ){ printf("dimension %d : %d\n" , i , dims[i]) ; } printf("\n") ; //show how the data is stored in the memory double *p = (double*)mxGetData(X) ; for ( i = 0 ; i < dims[0] ; i ++ ){ for ( j = 0 ; j < dims[1] ; j ++ ){ printf("%8.2f" , p[j * dims[0] + i]) ; } printf("\n") ; } //---important, to release resources mxDestroyArray(X) ; mxDestroyArray(Y) ; //show how to hide and unhide MATLAB command window printf("type RETURN to hide the MATLAB command window...\n") ; getchar() ; engSetVisible(ep , false) ; printf("type RETURN to unhide the MATLAB command window...\n") ; getchar() ; engSetVisible(ep , true) ; printf("type RETURN to END this program...\n") ; getchar() ; //remembering to close it is important . //but if you are debugging your programs , //annotate the following line will save you a lot of time , //for you needn't to restart the Engine . engClose(ep) ; //when your work is accomplished , type "exit" in MATLAB command window return EXIT_SUCCESS; }?
轉載于:https://www.cnblogs.com/haoyul/p/5384293.html
總結
以上是生活随笔為你收集整理的VS 编程常见错误及解决方法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: UITableView性能优化与卡顿
- 下一篇: 边工作边刷题:70天一遍leetcode