【发布时间】:2015-04-25 16:36:53
【问题描述】:
我正在尝试在 Matlab 中使用 Oliver Woodford 的 imrender_v2.4.zip (http://www.robots.ox.ac.uk/~ojw/software.htm) 中的特定函数,特别是 vgg_qpbo 函数。
相关文件应该识别出一个mex文件不存在并编译一个。
但是,在运行 startup.m 并尝试类似
>> vgg_qpbo(1,1,1)
我明白了
Warning: Missing MEX-file: vgg_qpbo. Will attempt to compile and run.
> In vgg_mexcompile_script at 25
In vgg_qpbo at 84
mex -O -I"/Users/.../imrender/vgg" "-Iqpbo/" "vgg_qpbo.cxx" "qpbo/QPBO.cpp" "qpbo/QPBO_maxflow.cpp" "qpbo/QPBO_extra.cpp" "qpbo/QPBO_postprocessing.cpp"
Building with 'Xcode Clang++'.
In file included from /Users/.../imrender/vgg/vgg_qpbo.cxx:11:
In file included from qpbo/QPBO.h:116:
qpbo/block.h:124:56: warning: conversion from string literal to 'char *' is deprecated [-Wc++11-compat-deprecated-writable-strings]
if (!next) { if (error_function) (*error_function)("Not enough memory!"); exit(1); }
^
qpbo/block.h:223:56: warning: conversion from string literal to 'char *' is deprecated [-Wc++11-compat-deprecated-writable-strings]
if (!first) { if (error_function) (*error_function)("Not enough memory!"); exit(1); }
^
2 warnings generated.
ERROR while compiling vgg_qpbo
Error using vgg_mexcompile_script (line 30)
Unable to compile vgg_qpbo.
Error in vgg_qpbo (line 84)
vgg_mexcompile_script; % Compilation happens in this script
我一直在试图找出问题所在。 主要嫌疑人是我正在运行的 Mac OS X (Yosemite 10.2),因为它可以在我的主管使用的 Linux 版本上编译(不知道是哪个,但我可以找出你认为它是否相关)。它不是我的电脑独有的,因为我们在另一台 Mac 上尝试过,结果完全相同。
我相信这些警告是可以忽略的,因为它们只是警告(我不精通 C++,但我认为这是一个相对较新的警告,但不应该影响编译本身)。
我还尝试找出错误发生在脚本中的哪个位置,但混合部分肯定开始了,而且我觉得更进一步。
我之前在这台计算机上混合过其他脚本,例如我可以运行
>> mex -setup
一帆风顺。
那么有人知道问题可能是什么吗?感谢您的宝贵时间!
顺便说一下,我正在运行 Matlab R2014B。
编辑
所以我按照 lilbill39 的建议,在调用 mexing 的行(vgg_mexcompile 中的第 74 行)放置了一个断点,然后运行
eval(cmd)
从命令行。
这导致了 36 个新警告、23 个注释和 4 个错误。
错误都是相似的,但在不同的行:
qpbo/instances.inc:19:29: error: explicit specialization of 'get_type_information' after instantiation
inline void QPBO<int32_t>::get_type_information(char*& type_name, char*& type_format)
在这 4 个错误中的每一个之后,都会出现相同类型的注释:
/Users/.../imrender/vgg/qpbo/QPBO.cpp:277:3: note: implicit
instantiation first required here
get_type_information(type_name, type_format);
^
还有另一种注释(总共 29 个):
qpbo/instances.inc:15:16: note: in instantiation of member function 'QPBO<float>::Save' requested here
template class QPBO<float>;
^
箭头内有不同的类。
大部分警告都是一样的
conversion from string literal to 'char *' is deprecated
-警告和以前一样。而有些是那种类型
format specifies type 'int' but the argument has type 'long long'
使用混合数字格式。
因此,QPBO.cpp 文件中的四个位置似乎需要“隐式实例化”(假设可以再次忽略所有警告)。通过快速的谷歌搜索,我发现它与文件的“链接”有关,但是已经很晚了,明天必须继续搜索。在此之前的更多帮助当然将不胜感激!
【问题讨论】:
-
这反而表明您的编译器选项设置为(或默认为)C++11 标准 - 鉴于它是较旧的代码(以及各种标准对 C++ 语言的更改量),您几乎当然想把它编译成旧的东西。对于这一部分,至少,更具体的问题是如何让 mex 配置要编译为 C++98 的任何编译器。
-
尝试在
vgg_mexcompile.m的第 74 行放置一个断点,这对eval(cmd);起作用。当调试器到达该点时,在 MATLAB 命令提示符处运行eval(cmd)并查看真正的错误是什么。vgg_mexcompile似乎正在吞下try...catch的错误 -
好的,谢谢cmets!我会等待一段时间来尝试设置一个较旧的编译器,但如果它似乎是以后唯一的出路,我会回到这个问题上。我将调试编译的结果添加到问题中,顺便提一下!
-
您至少需要在实例化之前声明"显式特化。您是否修改或放错了标题?
-
不,我没有修改任何东西。