而在Windows编译Felzenszwalb VOC Matlab的Mex32链接错误 [英] Matlab Mex32 link error while compiling Felzenszwalb VOC on Windows

查看:621
本文介绍了而在Windows编译Felzenszwalb VOC Matlab的Mex32链接错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编译C文件( VOC释放库的一部分)与Matlab和我得到下面的错误。
我似乎无法来解决它。谁能告诉我是什么原因导致这个错误,我能做些什么呢?

    MEX -O features.cc
    编写库features.mexw32
    C:\\用户\\ SAFAA \\应用程序数据\\本地\\ TEMP \\ mex_ty〜1 \\ features.obj的.text:未定义引用'_round
    C:\\ PROGRA〜1 \\ MATLAB \\ R2009A \\ BIN \\ MEX.PL:错误:features.mexw32的链接失败。


解决方案

如果你有更包含错误信息的,我相信这将有
已经有了答案,只是一个供参考。它看起来像你编译的文件
从一些非matlab源,这是很好的,但你很可能将不得不
提供有关它的更多信息。看来该features.cc文件是
引用一个符号圆形这就是为什么你得到错误。你需要
提供库的功能,​​或从源代码编译它。如果你这样做
一个帮助MEX ,它应该能够为您提供有关库链接信息
命令 -L 的路径和 -l <​​/ code>的库。我似乎记得
为标榜此功能并不完全正常工作,并且需要您在使用
-lC:/path/to/library/libfile.lib ,或什么的。首先,我会建议
编译从MATLAB帮助 yprime 的例子。这将确保你
正确有你的编译器的设置,这听起来你做likel。此外,采取
看yprime.c文件和 mexFunction 。你可能想确保
编译器将接受 .CC 文件作为C文件。它可能跨preT它作为一个C ++
文件,它会导致你更多的麻烦。你可以重命名 yprime.c 文件
yprime.cc 只是为了验证这一想法。

修改
感谢您提供code。这应该是蛋糕我的朋友,完整的蛋糕。 : - )

这是我的错误,我得到当我尝试使用编译:

 微软的Visual C ++ 2008例preSS&GT;&GT; MEX -v -g features.c
这是墨西哥,版权所有1984年至2007年MathWorks公司 - &GT;缺省选项文件名在C:\\ Documents和Settings \\ wynkocl \\应用程序\\ DATA \\ MathWorks公司\\ MATLAB \\ R2009b中
-------------------------------------------------- --------------
- &GT;选项​​文件= C:\\ Documents和Settings \\ wynkocl \\应用数据\\ MathWorks公司\\ MATLAB \\ R2009b中的\\ mexopts.bat
      MATLAB = C:\\ MATLAB \\ R2009b中的1〜
- &GT;编译器CL =
- &GT;编译器标志:
         COMPFLAGS = / C / Zp8 / GR / W3 / EHS / D_CRT_SECURE_NO_DE preCATE / D_SCL_SECURE_NO_DE preCATE / D_SECURE_SCL = 0 / DMATLAB_MEX_FILE / NOLOGO / MD
         OPTIMFLAGS = / O2 / Oy- / DNDEBUG
         了DebugFlags = / Z7
         参数=
         名称开关= / FO
- &GT; pre联命令=
- &GT;链接器=链接
- &GT;链接指令:
         LINKFLAGS = / DLL /导出:mexFunction / LIBPATH:C:\\ MATLAB \\ R2009b中〜1 \\ EXTERN \\ LIB \\ WIN32 \\微软libmx.lib libmex.lib libmat.lib / MACHINE:X86 KERNEL32.LIB USER32.LIB GDI32。 LIB winspool.lib comdlg32.lib advapi32.lib SHELL32.LIB ole32.lib oleaut32.lib UUID.LIB odbc32.lib odbccp32.lib / NOLOGO /增量:NO / IMPLIB:C:\\ DOCUME〜1 \\ WYNKOCL \\ LOCALS〜1 \\ TEMP \\ MEX_7L〜1 \\ templib.x/MAP:\"features.mexw32.map
         LINKDEBUGFLAGS = / DEBUG /PDB:\"features.mexw32.pdb
         LINKFLAGSPOST =
         名称指令= /out:\"features.mexw32
         文件链接指令=
         库。链接指令=
         RSP文件指示= @
- &GT;资源编译器= RC / FOmexversion.res
- &GT;资源链接=
-------------------------------------------------- --------------
- &GT; CL / C / Zp8 / GR / W3 / EHS / D_CRT_SECURE_NO_DE preCATE / D_SCL_SECURE_NO_DE preCATE / D_SECURE_SCL = 0 / DMATLAB_MEX_FILE / NOLOGO / MD / FOC:\\ DOCUME〜1 \\ WYNKOCL \\ LOCALS〜1 \\ TEMP \\ MEX_7L 〜1 \\ features.obj -IC:\\ MATLAB \\ R2009b中〜1 \\ EXTERN \\包括-IC:\\ MATLAB \\ R2009b中〜1 \\ SIMULINK \\包括/ Z7 -DMX_COMPAT_32 features.cfeatures.c
features.c(27):错误C2059:语法错误:类型
features.c(28):错误C2059:语法错误:类型
features.c(92):警告C4013:'圆'未定义;假设EXTERN返回int  C:\\ MATLAB \\ R2009b中〜1 \\ BIN \\ MEX.PL:错误:的features.c编译失败。

唉唉......现在我们可以找到问题。首先,C2059错误是做的事实功能最大正在被重新定义,我是pretty确定上,因为这就是我的固定它。那么圆形函数没有原型。嗯,这是奇怪的。嗯,这是因为圆形未在文件math.h 所以你需要的实施像之一在你的文件,像这样的顶部:

  INT轮(双号)
{
  返回(数字&GT; = 0)? (中间体)(数+ 0.5):(INT)(数 - 0.5);
}

现在它编译!作为小费,你也可以在生成获得更详细的调试信息尝试 MEX -v -g 。希望这可以让你对你的方式!

下面是最后的,我在这里得到了什么:


  1. 重新下载VOC的release4.01.tgz

  2. 提取和重新命名所有 .CC 文件的.cpp 文件。

  3. 打开 compile.m 脚本和修改,像这样:

    MEX -v -g resize.cpp
    MEX -v -g dt.cpp
    MEX -v -g features.cpp
    MEX -v -g getdetections.cpp

    根据您的设​​置

    %使用以下情况之一
    %0是最快的,3是最慢的。

    0%),使用SSE多线程卷积
    MEX%-v -g fconvsse.cpp -o fconv

    %1)多线程使用卷积BLAS
    %警告:BLAS版本不与MATLAB工作> = 2010年b
    %和英特尔CPU
    MEX%-O fconvblasMT.cpp -lmwblas -o fconv

    %2)mulththreaded卷积没有BLAS
    MEX%-O fconvMT.cpp -o fconv

    3%),使用卷积BLAS
    MEX -g -v fconvblas.cpp -LC:\\ MATLAB \\ R2009bSP1 \\ EXTERN \\ LIB \\ WIN32 \\微软-lmwblas -output fconv

    4%)基本卷积,可兼容
    MEX%-O fconv.cpp -o fconv


我建议使用选项3停留,pthreads的很可能只是一个小太多,你在这个时间点。 : - )


  1. resize.cpp

添加
    #定义bzero(B,LEN)(memset的((B),'\\ 0',(LEN)),(无效)0)
    INT轮(双号)
    {
      返回(数> = 0)? (中间体)(数+ 0.5):(INT)(数 - 0.5);
    }
在顶部和变化:

  alphainfo OFS [LEN]

  alphainfo * OFS =(alphainfo *)mxMalloc(LEN);

 断言(SY-1&GT; = 0);


    断言(SY1> = 0);
不要忘了 mxFree(OFS); 在函数结束


  1. dt.cpp:将所有 int32_t int32_T

  2. features.cpp
    添加

    INT轮(双号)
    {
      返回(数> = 0)? (中间体)(数+ 0.5):(INT)(数 - 0.5);
    }


  3. 确保你有一个目录 C:\\ MATLAB \\ R2009bSP1 \\ EXTERN \\ LIB \\ WIN32 \\微软,如果不把你的Matlab的释放的extern库目录下有

享受。

I'm compiling a C file (part of voc-release library) with Matlab and I'm getting the error below. I can't seem to solve it. Could anyone tell me what causes this error and what I can do about it?


    mex -O features.cc
    Writing library for features.mexw32 
    c:\users\safaa\appdata\local\temp\mex_ty~1\features.obj .text: undefined reference to '_round' 
    C:\PROGRA~1\MATLAB\R2009A\BIN\MEX.PL: Error: Link of 'features.mexw32' failed.


解决方案

If you had included more of the error message, I believe that this would have already been answered, just an FYI. It looks like you're compiling a file from some non-matlab source, which is fine, but you're likely going to have to give more information about it. It appears that the features.cc file is referencing a symbol round which is why you're getting the error. You'll need to provide the library for the function, or compile it from source. If you do a help mex, it should be able to give you information about the library linker commands -L for the path and -l for the library. I seem to remember that this feature doesn't work exactly as advertised, and requires you to use -lC:/path/to/library/libfile.lib, or whatever. First of all, I would recommend compiling the yprime example from the Matlab help. This will ensure that you have your compiler setup correctly, which it sounds likel you do. Also, take a look at the yprime.c file and the mexFunction. You may want to make sure the compiler will accept a .cc file as a C file. It may interpret it as a C++ file which will cause you more headaches. You could rename the yprime.c file to yprime.cc just to test the idea.

EDIT Thanks for providing the code. This should be cake my friend, complete cake. :-)

This is my error I get when I try to compile using:

Microsoft Visual C++ 2008 Express

>> mex -v -g features.c
This is mex, Copyright 1984-2007 The MathWorks, Inc. 

-> Default options filename found in C:\Documents and Settings\wynkocl\Application\Data\MathWorks\MATLAB\R2009b 
---------------------------------------------------------------- 
->    Options file           = C:\Documents and Settings\wynkocl\Application Data\MathWorks\MATLAB\R2009b\mexopts.bat 
      MATLAB                 = C:\MATLAB\R2009B~1 
->    COMPILER               = cl 
->    Compiler flags: 
         COMPFLAGS           = /c /Zp8 /GR /W3 /EHs /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE /nologo /MD 
         OPTIMFLAGS          = /O2 /Oy- /DNDEBUG 
         DEBUGFLAGS          = /Z7 
         arguments           =  
         Name switch         = /Fo 
->    Pre-linking commands   =  
->    LINKER                 = link 
->    Link directives: 
         LINKFLAGS           = /dll /export:mexFunction /LIBPATH:"C:\MATLAB\R2009B~1\extern\lib\win32\microsoft" libmx.lib libmex.lib libmat.lib /MACHINE:X86 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /incremental:NO /implib:"C:\DOCUME~1\WYNKOCL\LOCALS~1\TEMP\MEX_7L~1\templib.x" /MAP:"features.mexw32.map" 
         LINKDEBUGFLAGS      = /DEBUG /PDB:"features.mexw32.pdb" 
         LINKFLAGSPOST       =  
         Name directive      = /out:"features.mexw32" 
         File link directive =  
         Lib. link directive =  
         Rsp file indicator  = @ 
->    Resource Compiler      = rc /fo "mexversion.res" 
->    Resource Linker        =  
---------------------------------------------------------------- 


--> cl  /c /Zp8 /GR /W3 /EHs /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE /nologo /MD /FoC:\DOCUME~1\WYNKOCL\LOCALS~1\TEMP\MEX_7L~1\features.obj -IC:\MATLAB\R2009B~1\extern\include -IC:\MATLAB\R2009B~1\simulink\include /Z7 -DMX_COMPAT_32 features.c 

features.c 
features.c(27) : error C2059: syntax error : 'type' 
features.c(28) : error C2059: syntax error : 'type' 
features.c(92) : warning C4013: 'round' undefined; assuming extern returning int 

  C:\MATLAB\R2009B~1\BIN\MEX.PL: Error: Compile of 'features.c' failed.

Ahhh...now we can find the issue. First, the C2059 error is do to the fact the the function max is being redefined, I'm pretty sure on that because that's how I fixed it. Then the round function has no prototype. Hmmm, that's odd. Well, that's because round is not in math.h so you'll need to implement one like at the top of your file like so:

int round(double number)
{
  return (number >= 0) ? (int)(number + 0.5) : (int)(number - 0.5);
}

Now it compiles! As a tip, you can also try mex -v -g when you build to get more verbose debugging messages. Hope this gets you on your way!

Here's the last of what I've got here:

  1. Re-download voc-release4.01.tgz
  2. Extract and rename all .cc files .cpp files.
  3. Open the compile.m script and modify like so:

    mex -v -g resize.cpp mex -v -g dt.cpp mex -v -g features.cpp mex -v -g getdetections.cpp

    % use one of the following depending on your setup % 0 is fastest, 3 is slowest

    % 0) multithreaded convolution using SSE % mex -v -g fconvsse.cpp -o fconv

    % 1) multithreaded convolution using blas % WARNING: the blas version does not work with matlab >= 2010b % and Intel CPUs % mex -O fconvblasMT.cpp -lmwblas -o fconv

    % 2) mulththreaded convolution without blas % mex -O fconvMT.cpp -o fconv

    % 3) convolution using blas mex -g -v fconvblas.cpp -LC:\MATLAB\R2009bSP1\extern\lib\win32\microsoft -lmwblas -output fconv

    % 4) basic convolution, very compatible % mex -O fconv.cpp -o fconv

I recommend staying with option 3, pthreads is likely just a little too much for you at this point in time. :-)

  1. resize.cpp

Add #define bzero(b,len) (memset((b), '\0', (len)), (void) 0) int round(double number) { return (number >= 0) ? (int)(number + 0.5) : (int)(number - 0.5); } at the top and change:

alphainfo ofs[len];

to

alphainfo * ofs = (alphainfo *)mxMalloc(len);

and

assert(sy-1 >= 0);

to assert(sy1 >= 0); don't forget to mxFree(ofs); at the end of the function.

  1. dt.cpp: Change all int32_t to int32_T.
  2. features.cpp Add

    int round(double number) { return (number >= 0) ? (int)(number + 0.5) : (int)(number - 0.5); }

  3. Make sure you have a directory C:\MATLAB\R2009bSP1\extern\lib\win32\microsoft, if not put your Matlab release extern library directory there.

Enjoy.

这篇关于而在Windows编译Felzenszwalb VOC Matlab的Mex32链接错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆