imwrite在OpenCV中抛出编译错误

时间:2012-12-06 08:33:27

标签: xcode macos opencv compiler-errors

我一直在使用OpenCV以及imwrite功能,但遗憾的是这不再适用。

我正在使用OpenCV 2.4.3运行以下示例代码:

imwrite("somepath/somefile.png", myMat);

错误:

Undefined symbols for architecture x86_64:
"cv::imwrite(std::string const&, cv::_InputArray const&, std::__debug::vector<int,     std::allocator<int> > const&)", referenced from:
MyProject::this_callback(int, void*) in MyProject.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

错误看起来有点熟悉,但我无法确定错误。

enter image description here

3 个答案:

答案 0 :(得分:4)

是的,我以为你在使用XCode。我有同样的问题。 :)

如果更改项目设置,则:

  • 您使用GNU ++ 11作为C ++语言方言
  • libstdc ++(GNU C ++标准)作为C ++标准库

你的链接问题会消失。

我使用Apple LLVM 4.1。


当我遇到这个问题时,我尝试将一个新目标添加到我认识的一个旧项目中。然后我就把这个目标作为一个源文件程序。

这一定是XCode的“神奇”部分,因为我觉得有一段时间我无法在重启后让同一个项目工作。 :S

答案 1 :(得分:0)

我做了Barnabas所做的事,并且在cvdef.h上也遇到了问题。我变得绝望,所以我所做的只是更改了头文件。

在/usr/local/cvdef.h第205行:

我改变了

include <cstdint>
typedef std::uint32_t uint;

为:

include <tr1/cstdint>
typedef std::tr1::uint32_t uint;

基于this post

我认为opencv开发者应该对64bit的代码应用一些更改。

答案 2 :(得分:0)

使用类似 $.ajax({ type: "POST", url: 'http://127.0.0.1/Service.asmx/HelloWorld', data: {data: 'somethings'}, contentType: "application/json; charset=utf-8", dataType: "json", success: function(data) { var result= data.d; } }); 的内容而不是clang version 3.8.0 (trunk 257459)来编译

供参考,cmd:clang ++ -std = c ++ 11`pkg-config --cflags --libs opencv` code.cpp -o code

相关问题