gpt4 book ai didi

c++ - 在 Matlab 中使用 OS X 编译/混合 imrender 函数时出错

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:50:30 24 4
gpt4 key购买 nike

我正在尝试在 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 文件中的四个地方似乎需要“隐式实例化”(假设可以再次忽略所有警告)。通过快速谷歌搜索,我发现它与文件的“链接”有关,但是已经晚了,明天必须继续搜索。当然,在此之前提供更多帮助将不胜感激!

最佳答案

我无法验证这是否是适合您的解决方案,因为它在我的机器上使用 VS2012 编译得很好,但我的建议是将实例化移到特化的声明和定义下方。编辑 instances.inc 并移动以下行:

// Instantiations
template class QPBO<int32_t>;
template class QPBO<int64_t>;
template class QPBO<float>;
template class QPBO<double>;

到文件底部(在特化下方)。

参见 this answer for an explanation .

关于c++ - 在 Matlab 中使用 OS X 编译/混合 imrender 函数时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29867863/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com