构建 MEX 文件时,“=”标记之前应有“;”、“,”或“)”

问题描述 投票:0回答:1

我希望获得帮助安装 Andreas Mueller 的 MATLAB 全局边界概率绑定

我希望我的问题没有在我的安装中根深蒂固,所以我将首先描述眼前的问题,下面的段落指出一些实施尝试。

根据Mueller在自述文件中的指示,我尽力安装了CUDA、ACML和GCC(目前在RHEL 7上工作)。成功构建/安装库

libdamascene.so
后,我在
/etc/ld.so.conf.d/
中包含了一个 txt 文件,其中包含
libdamascene.so
的路径。当我使用
ldconfig -p | grep libdamascene.so
时它就会出现。

当我打开 MATLAB 并尝试构建 MEX 文件(使用 GCC 6.3)时,我得到

Error using mex:
In file included from ../damascene-python-and-matlab-bindings-master/bindings/gpb_mex.c: 3: 0:
../damascene-python-and-matlab-bindings-master/bindings/gpb.h: 10: 143: error: expected ';', ',' or ')' before '=' token
void gpb(const unsigned int* in)image, unsigned int width, unsigned int height, float* border, int*textons, float* orientations, int device_num=0);

我收集到的几个后续错误是因为编译器无法正确读取标头。

我尝试做的一件事是简单地删除

device_num = 0
的声明,并将其显式初始化在
gpb_mex.c
函数调用中。这个结果比较模糊。

Error using mex
/tmp/mex_1295917814264136_135235/gpb_mex.o: In function 'mexFunction':
gpb_mex.c: (.text+0x161): undefined reference to gpb
collect2: error: ld returned 1 exit status.

这个错误让我觉得我的库有问题,这对调试来说更具挑战性。我不会把我尝试过的所有东西(按需提供)来成功构建库,但让我总结一下:

  • 我运行的是 CUDA 9.0,而不是 CUDA 8.0。
  • 我正在运行 AMD Open64 SDK 中的
    gpuacml
    (我只能找到一个)。
  • 我必须将
    gpu_architecture
    主文件中的
    CMakelists.txt
    sm_20
    更改为
    sm_70
  • 我单独安装了 GCC 6.3.0(和 GCC 5.3.0),因此我可以构建该库。

我最大的问题是:你认为这确实是一个错误构建的库的问题还是还缺少其他东西。有什么方法可以检查库

libdamascene.so
是否正常工作? 请让我知道如何澄清我的情况。非常感谢!

编辑:我添加了附加数据。

这是我尝试编译 MEX 文件时的 MATLAB 输出。

mex -v GCC='/usr/bin/gcc63' G++='/usr/bin/g++63' gpb_mex.c
Verbose mode is on.
... Looking for compiler 'gcc' ...
... Executing command 'which gcc' ...Yes ('/usr/bin/gcc').
... Executing command 'gcc -print-file-name=libstdc++.so' ...Yes ('/usr/lib/gcc/x86_64-redhat-linux/4.8.5/libstdc++.so').
Found installed compiler 'gcc'.
Options file details
-------------------------------------------------------------------
    Compiler location: /usr/bin/gcc63
    Options file: /home/clusterbomb/.matlab/R2018b/mex_C_glnxa64.xml
    CMDLINE2 : /usr/bin/gcc63 -pthread -Wl,--no-undefined -Wl,-rpath-link,/usr/local/MATLAB/R2018b/bin/glnxa64 -shared  -O -Wl,--version-script,"/usr/local/MATLAB/R2018b/extern/lib/glnxa64/c_exportsmexfileversion.map" /tmp/mex_1326595352957888_135235/gpb_mex.o /tmp/mex_1326595352957888_135235/c_mexapi_version.o   -L"/usr/local/MATLAB/R2018b/bin/glnxa64" -lmx -lmex -lmat -lm -lstdc++ -o gpb_mex.mexa64
    CC : /usr/bin/gcc63
    DEFINES : -DMATLAB_DEFAULT_RELEASE=R2017b  -DUSE_MEX_CMD   -D_GNU_SOURCE -DMATLAB_MEX_FILE 
    MATLABMEX : -DMATLAB_MEX_FILE 
    CFLAGS : -fexceptions -fPIC -fno-omit-frame-pointer -pthread
    INCLUDE : -I"/usr/local/MATLAB/R2018b/extern/include" -I"/usr/local/MATLAB/R2018b/simulink/include"
    COPTIMFLAGS : -O2 -fwrapv -DNDEBUG
    CDEBUGFLAGS : -g
    LD : /usr/bin/gcc63
    LDFLAGS : -pthread -Wl,--no-undefined -Wl,-rpath-link,/usr/local/MATLAB/R2018b/bin/glnxa64
    LDTYPE : -shared 
    FUNCTIONMAP : "/usr/local/MATLAB/R2018b/extern/lib/glnxa64/mexFunction.map"
    VERSIONMAP : "/usr/local/MATLAB/R2018b/extern/lib/glnxa64/c_exportsmexfileversion.map"
    LINKEXPORT : -Wl,--version-script,"/usr/local/MATLAB/R2018b/extern/lib/glnxa64/mexFunction.map"
    LINKEXPORTVER : -Wl,--version-script,"/usr/local/MATLAB/R2018b/extern/lib/glnxa64/c_exportsmexfileversion.map"
    LINKLIBS : -L"/usr/local/MATLAB/R2018b/bin/glnxa64" -lmx -lmex -lmat -lm -lstdc++
    LDOPTIMFLAGS : -O
    LDDEBUGFLAGS : -g
    MWCPPLIB : "/usr/local/MATLAB/R2018b/sys/os/glnxa64/libstdc++.so.6"
    OBJEXT : .o
    LDEXT : .mexa64
    SETENV : CC="/usr/bin/gcc63"
                CXX="g++"
                CFLAGS="-fexceptions -fPIC -fno-omit-frame-pointer -pthread -DMATLAB_DEFAULT_RELEASE=R2017b  -DUSE_MEX_CMD   -D_GNU_SOURCE -DMATLAB_MEX_FILE "
                CXXFLAGS="-fexceptions -fPIC -fno-omit-frame-pointer -pthread -std=c++11 -DMATLAB_DEFAULT_RELEASE=R2017b  -DUSE_MEX_CMD   -D_GNU_SOURCE -DMATLAB_MEX_FILE "
                COPTIMFLAGS="-O2 -fwrapv -DNDEBUG"
                CXXOPTIMFLAGS="-O2 -fwrapv -DNDEBUG"
                CDEBUGFLAGS="-g"
                CXXDEBUGFLAGS="-g"
                LD="/usr/bin/gcc63"
                LDXX="g++"
                LDFLAGS="-pthread -Wl,--no-undefined -Wl,-rpath-link,/usr/local/MATLAB/R2018b/bin/glnxa64 -shared  -L"/usr/local/MATLAB/R2018b/bin/glnxa64" -lmx -lmex -lmat -lm -lstdc++ -Wl,--version-script,"/usr/local/MATLAB/R2018b/extern/lib/glnxa64/mexFunction.map""
                LDDEBUGFLAGS="-g"
    GCC : /usr/bin/gcc63
    CPPLIBS : /usr/lib/gcc/x86_64-redhat-linux/4.8.5/libstdc++.so
    MATLABROOT : /usr/local/MATLAB/R2018b
    ARCH : glnxa64
    SRC : "/home/clusterbomb/Downloads/GPUGPB/damascene-python-and-matlab-bindings-master/bindings/gpb_mex.c";"/usr/local/MATLAB/R2018b/extern/version/c_mexapi_version.c"
    OBJ : /tmp/mex_1326595352957888_135235/gpb_mex.o;/tmp/mex_1326595352957888_135235/c_mexapi_version.o
    OBJS : /tmp/mex_1326595352957888_135235/gpb_mex.o /tmp/mex_1326595352957888_135235/c_mexapi_version.o 
    SRCROOT : /home/clusterbomb/Downloads/GPUGPB/damascene-python-and-matlab-bindings-master/bindings/gpb_mex
    DEF : /tmp/mex_1326595352957888_135235/gpb_mex.def
    EXP : "gpb_mex.exp"
    LIB : "gpb_mex.lib"
    EXE : gpb_mex.mexa64
    ILK : "gpb_mex.ilk"
    MANIFEST : "gpb_mex.mexa64.manifest"
    TEMPNAME : gpb_mex
    EXEDIR : 
    EXENAME : gpb_mex
    G++ : /usr/bin/g++63
    OPTIM : -O2 -fwrapv -DNDEBUG
    LINKOPTIM : -O
    CMDLINE1_0 : /usr/bin/gcc63 -c -DMATLAB_DEFAULT_RELEASE=R2017b  -DUSE_MEX_CMD   -D_GNU_SOURCE -DMATLAB_MEX_FILE  -I"/usr/local/MATLAB/R2018b/extern/include" -I"/usr/local/MATLAB/R2018b/simulink/include" -fexceptions -fPIC -fno-omit-frame-pointer -pthread -O2 -fwrapv -DNDEBUG "/home/clusterbomb/Downloads/GPUGPB/damascene-python-and-matlab-bindings-master/bindings/gpb_mex.c" -o /tmp/mex_1326595352957888_135235/gpb_mex.o
    CMDLINE1_1 : /usr/bin/gcc63 -c -DMATLAB_DEFAULT_RELEASE=R2017b  -DUSE_MEX_CMD   -D_GNU_SOURCE -DMATLAB_MEX_FILE  -I"/usr/local/MATLAB/R2018b/extern/include" -I"/usr/local/MATLAB/R2018b/simulink/include" -fexceptions -fPIC -fno-omit-frame-pointer -pthread -O2 -fwrapv -DNDEBUG "/usr/local/MATLAB/R2018b/extern/version/c_mexapi_version.c" -o /tmp/mex_1326595352957888_135235/c_mexapi_version.o
-------------------------------------------------------------------
Building with 'gcc'.
/usr/bin/gcc63 -c -DMATLAB_DEFAULT_RELEASE=R2017b  -DUSE_MEX_CMD   -D_GNU_SOURCE -DMATLAB_MEX_FILE  -I"/usr/local/MATLAB/R2018b/extern/include" -I"/usr/local/MATLAB/R2018b/simulink/include" -fexceptions -fPIC -fno-omit-frame-pointer -pthread -O2 -fwrapv -DNDEBUG "/home/clusterbomb/Downloads/GPUGPB/damascene-python-and-matlab-bindings-master/bindings/gpb_mex.c" -o /tmp/mex_1326595352957888_135235/gpb_mex.o
/usr/bin/gcc63 -c -DMATLAB_DEFAULT_RELEASE=R2017b  -DUSE_MEX_CMD   -D_GNU_SOURCE -DMATLAB_MEX_FILE  -I"/usr/local/MATLAB/R2018b/extern/include" -I"/usr/local/MATLAB/R2018b/simulink/include" -fexceptions -fPIC -fno-omit-frame-pointer -pthread -O2 -fwrapv -DNDEBUG "/usr/local/MATLAB/R2018b/extern/version/c_mexapi_version.c" -o /tmp/mex_1326595352957888_135235/c_mexapi_version.o
/usr/bin/gcc63 -pthread -Wl,--no-undefined -Wl,-rpath-link,/usr/local/MATLAB/R2018b/bin/glnxa64 -shared  -O -Wl,--version-script,"/usr/local/MATLAB/R2018b/extern/lib/glnxa64/c_exportsmexfileversion.map" /tmp/mex_1326595352957888_135235/gpb_mex.o /tmp/mex_1326595352957888_135235/c_mexapi_version.o   -L"/usr/local/MATLAB/R2018b/bin/glnxa64" -lmx -lmex -lmat -lm -lstdc++ -o gpb_mex.mexa64
Error using mex
/tmp/mex_1326595352957888_135235/gpb_mex.o: In function `mexFunction':
gpb_mex.c:(.text+0x161): undefined reference to `gpb'
collect2: error: ld returned 1 exit status

这是头文件

gpb.h
(编辑删除
device_num=0
):

void gpb(const unsigned int* in_image,unsigned int width,unsigned int height, float* border, int* textons, float* orientations, int device_num);

这是

gpb_mex.c
文件,并在最后一行更改了声明的
device_num

#include <mex.h>
#include "gpb.h"

void mexFunction(int nOut, mxArray *pOut[],
         int nIn, const mxArray *pIn[])
{
  mwSize width, height;
  float* borders;
  float* orientations;
  int* textons;
  unsigned int *in_image;
  mwSize dims[3];
  mwSize orientation_dims[3];

  if((nIn != 1) || (nOut != 3))
    mexErrMsgTxt("Usage: border,textons,orientations = gpb(image)");
  if (!mxIsClass(pIn[0],"uint8") || mxGetNumberOfDimensions(pIn[0]) != 3) {
        mexErrMsgTxt("Usage: th argument must be a unsigned int matrix");
    }
  const mwSize *indims= mxGetDimensions(pIn[0]);
  if (indims[0]!=4)
      mexErrMsgTxt("Image needs to be of shape 4 x widht x height");
  width = indims[2];
  height = indims[1];
  mexPrintf("width %d, height %d\n",width,height);
  mexPrintf("Element-size: %d, sizeof(int): %d, sizeof(char) %d\n",mxGetElementSize(pIn[0]),sizeof(int),sizeof(unsigned char));
  dims[0]=width; dims[1]=height; //for rgb0
  mexPrintf("width: %d height: %d\n",width, height);
  pOut[0]=mxCreateNumericMatrix(height,width,mxSINGLE_CLASS,mxREAL);
  pOut[1]=mxCreateNumericMatrix(height,width,mxINT32_CLASS,mxREAL);
  orientation_dims[0]=width; orientation_dims[1]=height; orientation_dims[2]=8;
  pOut[2]=mxCreateNumericArray(3,orientation_dims,mxSINGLE_CLASS,mxREAL);

  borders=(float*) mxGetPr(pOut[0]);
  textons=(int*) mxGetPr(pOut[1]);
  orientations=(float*) mxGetPr(pOut[2]);

  in_image = (unsigned int*) mxGetData(pIn[0]);
  gpb(in_image,height,width,borders,textons,orientations, 0); 
}

很高兴根据需要提供更多源代码,但其余部分将直接从 amueller 的存储库中删除(上面的链接)。

编辑2:

使用 -L 导致权限错误,我通过 linux 终端中的

sudo chmod 755 libdamascene.so
解决了该问题。

所以好消息是 matlab 能够找到 libdamascene,证明它在许可被拒绝后继续前进。不幸的是,编译器仍然在苦苦挣扎。

mex -v GCC='/usr/bin/gcc63' gpb_mex.c -L</home/clusterbomb/Downloads/GPUGPB/damascene-python-and-matlab-bindings-master/build/libdamascene.so>
Verbose mode is on.
... Looking for compiler 'gcc' ...
... Executing command 'which gcc' ...Yes ('/usr/bin/gcc').
... Executing command 'gcc -print-file-name=libstdc++.so' ...Yes ('/usr/lib/gcc/x86_64-redhat-linux/4.8.5/libstdc++.so').
Found installed compiler 'gcc'.
Options file details
-------------------------------------------------------------------
    Compiler location: /usr/bin/gcc63
    Options file: /home/clusterbomb/.matlab/R2018b/mex_C_glnxa64.xml
    CMDLINE2 : /usr/bin/gcc63 -pthread -Wl,--no-undefined -Wl,-rpath-link,/usr/local/MATLAB/R2018b/bin/glnxa64 -shared  -O -Wl,--version-script,"/usr/local/MATLAB/R2018b/extern/lib/glnxa64/c_exportsmexfileversion.map" /tmp/mex_1363958469865432_171081/gpb_mex.o /tmp/mex_1363958469865432_171081/c_mexapi_version.o   -L</home/clusterbomb/Downloads/GPUGPB/damascene-python-and-matlab-bindings-master/build/libdamascene.so>   -L"/usr/local/MATLAB/R2018b/bin/glnxa64" -lmx -lmex -lmat -lm -lstdc++ -o gpb_mex.mexa64
    CC : /usr/bin/gcc63
    DEFINES : -DMATLAB_DEFAULT_RELEASE=R2017b  -DUSE_MEX_CMD   -D_GNU_SOURCE -DMATLAB_MEX_FILE 
    MATLABMEX : -DMATLAB_MEX_FILE 
    CFLAGS : -fexceptions -fPIC -fno-omit-frame-pointer -pthread
    INCLUDE : -I"/usr/local/MATLAB/R2018b/extern/include" -I"/usr/local/MATLAB/R2018b/simulink/include"
    COPTIMFLAGS : -O2 -fwrapv -DNDEBUG
    CDEBUGFLAGS : -g
    LD : /usr/bin/gcc63
    LDFLAGS : -pthread -Wl,--no-undefined -Wl,-rpath-link,/usr/local/MATLAB/R2018b/bin/glnxa64
    LDTYPE : -shared 
    FUNCTIONMAP : "/usr/local/MATLAB/R2018b/extern/lib/glnxa64/mexFunction.map"
    VERSIONMAP : "/usr/local/MATLAB/R2018b/extern/lib/glnxa64/c_exportsmexfileversion.map"
    LINKEXPORT : -Wl,--version-script,"/usr/local/MATLAB/R2018b/extern/lib/glnxa64/mexFunction.map"
    LINKEXPORTVER : -Wl,--version-script,"/usr/local/MATLAB/R2018b/extern/lib/glnxa64/c_exportsmexfileversion.map"
    LINKLIBS : -L</home/clusterbomb/Downloads/GPUGPB/damascene-python-and-matlab-bindings-master/build/libdamascene.so>   -L"/usr/local/MATLAB/R2018b/bin/glnxa64" -lmx -lmex -lmat -lm -lstdc++
    LDOPTIMFLAGS : -O
    LDDEBUGFLAGS : -g
    MWCPPLIB : "/usr/local/MATLAB/R2018b/sys/os/glnxa64/libstdc++.so.6"
    OBJEXT : .o
    LDEXT : .mexa64
    SETENV : CC="/usr/bin/gcc63"
                CXX="g++"
                CFLAGS="-fexceptions -fPIC -fno-omit-frame-pointer -pthread -DMATLAB_DEFAULT_RELEASE=R2017b  -DUSE_MEX_CMD   -D_GNU_SOURCE -DMATLAB_MEX_FILE "
                CXXFLAGS="-fexceptions -fPIC -fno-omit-frame-pointer -pthread -std=c++11 -DMATLAB_DEFAULT_RELEASE=R2017b  -DUSE_MEX_CMD   -D_GNU_SOURCE -DMATLAB_MEX_FILE "
                COPTIMFLAGS="-O2 -fwrapv -DNDEBUG"
                CXXOPTIMFLAGS="-O2 -fwrapv -DNDEBUG"
                CDEBUGFLAGS="-g"
                CXXDEBUGFLAGS="-g"
                LD="/usr/bin/gcc63"
                LDXX="g++"
                LDFLAGS="-pthread -Wl,--no-undefined -Wl,-rpath-link,/usr/local/MATLAB/R2018b/bin/glnxa64 -shared  -L</home/clusterbomb/Downloads/GPUGPB/damascene-python-and-matlab-bindings-master/build/libdamascene.so>   -L"/usr/local/MATLAB/R2018b/bin/glnxa64" -lmx -lmex -lmat -lm -lstdc++ -Wl,--version-script,"/usr/local/MATLAB/R2018b/extern/lib/glnxa64/mexFunction.map""
                LDDEBUGFLAGS="-g"
    GCC : /usr/bin/gcc63
    CPPLIBS : /usr/lib/gcc/x86_64-redhat-linux/4.8.5/libstdc++.so
    MATLABROOT : /usr/local/MATLAB/R2018b
    ARCH : glnxa64
    SRC : "/home/clusterbomb/Downloads/GPUGPB/damascene-python-and-matlab-bindings-master/bindings/gpb_mex.c";"/usr/local/MATLAB/R2018b/extern/version/c_mexapi_version.c"
    OBJ : /tmp/mex_1363958469865432_171081/gpb_mex.o;/tmp/mex_1363958469865432_171081/c_mexapi_version.o
    OBJS : /tmp/mex_1363958469865432_171081/gpb_mex.o /tmp/mex_1363958469865432_171081/c_mexapi_version.o 
    SRCROOT : /home/clusterbomb/Downloads/GPUGPB/damascene-python-and-matlab-bindings-master/bindings/gpb_mex
    DEF : /tmp/mex_1363958469865432_171081/gpb_mex.def
    EXP : "gpb_mex.exp"
    LIB : "gpb_mex.lib"
    EXE : gpb_mex.mexa64
    ILK : "gpb_mex.ilk"
    MANIFEST : "gpb_mex.mexa64.manifest"
    TEMPNAME : gpb_mex
    EXEDIR : 
    EXENAME : gpb_mex
    OPTIM : -O2 -fwrapv -DNDEBUG
    LINKOPTIM : -O
    CMDLINE1_0 : /usr/bin/gcc63 -c -DMATLAB_DEFAULT_RELEASE=R2017b  -DUSE_MEX_CMD   -D_GNU_SOURCE -DMATLAB_MEX_FILE  -I"/usr/local/MATLAB/R2018b/extern/include" -I"/usr/local/MATLAB/R2018b/simulink/include" -fexceptions -fPIC -fno-omit-frame-pointer -pthread -O2 -fwrapv -DNDEBUG "/home/clusterbomb/Downloads/GPUGPB/damascene-python-and-matlab-bindings-master/bindings/gpb_mex.c" -o /tmp/mex_1363958469865432_171081/gpb_mex.o
    CMDLINE1_1 : /usr/bin/gcc63 -c -DMATLAB_DEFAULT_RELEASE=R2017b  -DUSE_MEX_CMD   -D_GNU_SOURCE -DMATLAB_MEX_FILE  -I"/usr/local/MATLAB/R2018b/extern/include" -I"/usr/local/MATLAB/R2018b/simulink/include" -fexceptions -fPIC -fno-omit-frame-pointer -pthread -O2 -fwrapv -DNDEBUG "/usr/local/MATLAB/R2018b/extern/version/c_mexapi_version.c" -o /tmp/mex_1363958469865432_171081/c_mexapi_version.o
-------------------------------------------------------------------
Building with 'gcc'.
/usr/bin/gcc63 -c -DMATLAB_DEFAULT_RELEASE=R2017b  -DUSE_MEX_CMD   -D_GNU_SOURCE -DMATLAB_MEX_FILE  -I"/usr/local/MATLAB/R2018b/extern/include" -I"/usr/local/MATLAB/R2018b/simulink/include" -fexceptions -fPIC -fno-omit-frame-pointer -pthread -O2 -fwrapv -DNDEBUG "/home/clusterbomb/Downloads/GPUGPB/damascene-python-and-matlab-bindings-master/bindings/gpb_mex.c" -o /tmp/mex_1363958469865432_171081/gpb_mex.o
/usr/bin/gcc63 -c -DMATLAB_DEFAULT_RELEASE=R2017b  -DUSE_MEX_CMD   -D_GNU_SOURCE -DMATLAB_MEX_FILE  -I"/usr/local/MATLAB/R2018b/extern/include" -I"/usr/local/MATLAB/R2018b/simulink/include" -fexceptions -fPIC -fno-omit-frame-pointer -pthread -O2 -fwrapv -DNDEBUG "/usr/local/MATLAB/R2018b/extern/version/c_mexapi_version.c" -o /tmp/mex_1363958469865432_171081/c_mexapi_version.o
/usr/bin/gcc63 -pthread -Wl,--no-undefined -Wl,-rpath-link,/usr/local/MATLAB/R2018b/bin/glnxa64 -shared  -O -Wl,--version-script,"/usr/local/MATLAB/R2018b/extern/lib/glnxa64/c_exportsmexfileversion.map" /tmp/mex_1363958469865432_171081/gpb_mex.o /tmp/mex_1363958469865432_171081/c_mexapi_version.o   -L</home/clusterbomb/Downloads/GPUGPB/damascene-python-and-matlab-bindings-master/build/libdamascene.so>   -L"/usr/local/MATLAB/R2018b/bin/glnxa64" -lmx -lmex -lmat -lm -lstdc++ -o gpb_mex.mexa64
/tmp/mex_1363958922594243_171081: line 2: -L/usr/local/MATLAB/R2018b/bin/glnxa64: No such file or directory
Error using mex
The command '/usr/bin/gcc63' exited with a return value '1'

我已经两次和三次检查目录 /usr/local/MATLAB/R2018b/bin/glnxa64 是否存在(确实存在)。我也尝试过

restoredefaultpath
rehash toolboxcache
,但没有成功。当我使用 gcc 5.3.0 或本机 RHEL 7 gcc 时没有变化。感谢您迄今为止的帮助!

c linux matlab mex
1个回答
2
投票

在文件

damascene-python-and-matlab-bindings/bindings/gpb.h
中,以下行导致错误:

void gpb(const unsigned int* in_image,unsigned int width,unsigned int height, float* border, int* textons, float* orientations, int device_num=0);

最后一个参数有一个默认参数,它是 C++ 功能,是无效的 C 语法。删除

=0
,变成:

void gpb(const unsigned int* in_image,unsigned int width,unsigned int height, float* border, int* textons, float* orientations, int device_num);

接下来,当您调用

gpb
时,您不能依赖
device_num
的默认值,因此您需要显式传递此值。在
damascene-python-and-matlab-bindings/bindings/gpb_mex.c
中,该行:

gpb(in_image,height,width,borders,textons,orientations);

需要一个额外的参数

0

gpb(in_image,height,width,borders,textons,orientations,0);

通过这些更改,我希望代码可以使用 C 编译器正常编译。

(我意识到你已经做了这些事情......)

最后,链接器需要找到

gpb
函数。我认为这个位于您构建的
libdamascene.so
库中。您需要告诉
mex
命令链接到这个库中:

mex -v GCC='/usr/bin/gcc63' gpb_mex.c -ldamascene

-l
的参数会在前面加上
lib
,并在后面附加
.a
.so
,以形成库文件的名称。根据此库文件所在的位置,您可能还需要添加
-L<path>
mex
调用的参数,其中
<path>
包含库文件的目录:

mex -v GCC='/usr/bin/gcc63' gpb_mex.c -L/home/clusterbomb/Downloads/GPUGPB/damascene-python-and-matlab-bindings-master/build/libdamascene.so
© www.soinside.com 2019 - 2024. All rights reserved.