在ubuntu 16.04

时间:2018-06-02 01:46:32

标签: c++ linux matlab compilation

我需要运行这个项目: https://github.com/JunhoJeon/intrinsic_texture

这个项目是在Windows上构建的,但我想在Ubuntu 16.04上运行这个项目 我安装了matlab 2017
我安装了g ++ / gcc 4.x版本

我的问题是这个项目可以编译(位于mex目录下的cpp文件)并在ubuntu上运行吗?

我尝试的是将路径从Windows表示法更改为linux表示法,如下所示: /mex/compile.m:

mex -I"./ann_x64/include" -L"ann_x64" -l"ANN" -I"./opencv210_x64/include" -L"./opencv210_x64/lib" -l"cv210" -l"cxcore210" getConstraintsMatrix.cpp mexBase.cpp
mex -I"./ann_x64/include" -L"ann_x64" -l"ANN" -I"./opencv210_x64/include" -L"./opencv210_x64/lib" -l"cv210" -l"cxcore210" getContinuousConstraintMatrix.cpp mexBase.cpp
mex -I"./ann_x64/include" -L"ann_x64" -l"ANN" -I"./opencv210_x64/include" -L"./opencv210_x64/lib" -l"cv210" -l"cxcore210" getGridLLEMatrix.cpp mexBase.cpp LLE.cpp
mex -I"./ann_x64/include" -L"ann_x64" -l"ANN" -I"./opencv210_x64/include" -L"./opencv210_x64/lib" -l"cv210" -l"cxcore210" getGridLLEMatrixNormal.cpp mexBase.cpp LLE.cpp
mex -I"./ann_x64/include" -L"ann_x64" -l"ANN" -I"./opencv210_x64/include" -L"./opencv210_x64/lib" -l"cv210" -l"cxcore210" getNormalConstraintMatrix.cpp mexBase.cpp

/mex/LLE.h:

#include <ANN/ANN.h>
#include "mex.h"
#include <opencv/cv.h>
#include <opencv/cxcore.h>
#include <opencv/highgui.h>

/mex/mexBase.h:

#include <vector>
#include "mex.h"
#include <opencv/cv.h>
#include <opencv/cxcore.h>
#include <opencv/highgui.h>

但是我无法编译位于mex目录中的文件。 这是我在Matlab上执行compile.m文件时遇到的错误:

'building by g++'
/media/young/5e7be152-8ed5-483d-a8e8-b3fecfa221dc/text/mycodehtml/cv/JunhoJeon_intrinsic_texture/mex/getConstraintsMatrix.cpp:3:0: warning: "MIN" redefined
 #define MIN(X, Y) (X > Y ? Y : X)

 ^
In file included from ./opencv210_x64/include/opencv/cxcore.h:70:0,
                 from ./opencv210_x64/include/opencv/cv.h:58,
                 from /media/young/5e7be152-8ed5-483d-a8e8-b3fecfa221dc/text/mycodehtml/cv/JunhoJeon_intrinsic_texture/mex/mexBase.h:3,
                 from /media/young/5e7be152-8ed5-483d-a8e8-b3fecfa221dc/text/mycodehtml/cv/JunhoJeon_intrinsic_texture/mex/getConstraintsMatrix.cpp:1:
./opencv210_x64/include/opencv/cxtypes.h:193:0: note: this is the location of the previous definition
 #define MIN(a,b)  ((a) > (b) ? (b) : (a))
 ^
/media/young/5e7be152-8ed5-483d-a8e8-b3fecfa221dc/text/mycodehtml/cv/JunhoJeon_intrinsic_texture/mex/getConstraintsMatrix.cpp:4:0: warning: "MAX" redefined
 #define MAX(X, Y) (X > Y ? X : Y)

 ^
In file included from ./opencv210_x64/include/opencv/cxcore.h:70:0,
                 from ./opencv210_x64/include/opencv/cv.h:58,
                 from /media/young/5e7be152-8ed5-483d-a8e8-b3fecfa221dc/text/mycodehtml/cv/JunhoJeon_intrinsic_texture/mex/mexBase.h:3,
                 from /media/young/5e7be152-8ed5-483d-a8e8-b3fecfa221dc/text/mycodehtml/cv/JunhoJeon_intrinsic_texture/mex/getConstraintsMatrix.cpp:1:
./opencv210_x64/include/opencv/cxtypes.h:197:0: note: this is the location of the previous definition
 #define MAX(a,b)  ((a) < (b) ? (b) : (a))
 ^
/media/young/5e7be152-8ed5-483d-a8e8-b3fecfa221dc/text/mycodehtml/cv/JunhoJeon_intrinsic_texture/mex/getConstraintsMatrix.cpp: In function ‘void mexFunction(int, mxArray**, int, const mxArray**)’:
/media/young/5e7be152-8ed5-483d-a8e8-b3fecfa221dc/text/mycodehtml/cv/JunhoJeon_intrinsic_texture/mex/getConstraintsMatrix.cpp:104:37: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
  pushSparseMatrix(m_refConsMat, "WR");

                                     ^
/media/young/5e7be152-8ed5-483d-a8e8-b3fecfa221dc/text/mycodehtml/cv/JunhoJeon_intrinsic_texture/mex/getConstraintsMatrix.cpp:105:41: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
  pushSparseMatrix(m_shadingConsMat, "WS");

                                         ^

Error: mex
/media/young/5e7be152-8ed5-483d-a8e8-b3fecfa221dc/text/mycodehtml/cv/JunhoJeon_intrinsic_texture/mex/mexBase.cpp: In function
‘void pushSparseMatrix(CvSparseMat*, char*)’:
/media/young/5e7be152-8ed5-483d-a8e8-b3fecfa221dc/text/mycodehtml/cv/JunhoJeon_intrinsic_texture/mex/mexBase.cpp:30:107: error:
‘sprintf_s’ was not declared in this scope
  sprintf_s(buffer,"%s = sparse(consMat(1,:)+1,consMat(2,:)+1,consMat(3,:),%d,%d);", matName, pixCnt,pixCnt);

                                                                                                           ^


Error: compile (line 1)
mex -I"./ann_x64/include" -L"ann_x64" -l"ANN" -I"./opencv210_x64/include" -L"./opencv210_x64/lib" -l"cv210" -l"cxcore210"
getConstraintsMatrix.cpp mexBase.cpp

如何解决错误并编译文件并最终运行此项目?

0 个答案:

没有答案