OpenCV 2.4.3+与libstdc ++为iOS? [英] OpenCV 2.4.3+ with libstdc++ for iOS?

查看:184
本文介绍了OpenCV 2.4.3+与libstdc ++为iOS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在现有的iOS项目中包含最新版本的OpenCV,并且有链接器错误,因为我的XCode项目设置为使用libstdc ++而不是libc ++ / C ++ 11支持。



我已经看到其他几个人通过启用libc ++修复错误。示例:





但是,我需要使用libstdc ++,因为我有其他第三方库已经编译的旧stdlib(不能更改) 。有没有办法编译OpenCV 2.4.3+没有-stdlib = libc ++?有没有特殊的标志传递给CMake?或者到OpenCV源代码的ios文件夹中的build_framework.py脚本?



或者,是否有任何二进制版本可用?似乎所有可以从OpenCV下载的都假定为libc ++ / C ++ 11.

解决方案

在openCV的源文件中找到这个文件: p>

  ios / cmake / Modules / Platform / iOS.cmake 

更改此行:

 设置(CMAKE_CXX_FLAGS-stdlib = libc ++ -headerpad_max_install_names -fvisibility = hidden -fvisibility-inlines-hidden)

到:

  set(CMAKE_CXX_FLAGS-stdlib = libstdc ++ -headerpad_max_install_names -fvisibility = hidden -fvisibility-inlines-hidden)

使用python脚本编译

  ios / build_framework 


I'm trying to include a recent version of OpenCV into an existing iOS project and am having linker errors because my XCode project is set to use libstdc++ and not libc++ / C++ 11 support.

I have seen several other people who have fixed their errors by enabling libc++. Examples:

However, I NEED to use libstdc++ because I have other 3rd party libraries which are already compiled with the older stdlib (can't be changed). Is there a way to compile OpenCV 2.4.3+ without -stdlib=libc++ ? Are there special flags to pass to CMake? or to the build_framework.py script that comes in the ios folder of the OpenCV source code?

Alternatively, does anyone have a binary version available? It seems all downloadable from OpenCV assume libc++ / C++11.

解决方案

In the source for openCV locate this file:

ios/cmake/Modules/Platform/iOS.cmake

Change this line:

set (CMAKE_CXX_FLAGS "-stdlib=libc++ -headerpad_max_install_names -fvisibility=hidden -fvisibility-inlines-hidden")

to:

set (CMAKE_CXX_FLAGS "-stdlib=libstdc++ -headerpad_max_install_names -fvisibility=hidden -fvisibility-inlines-hidden")

Compile using the python script

ios/build_framework.py

Then you should be good to go

I have just tried this on 2.4.3 source, swapped in the resulting framework on an existing project, changed the C++ standard library for the project to libstdc++ and it runs fine.

这篇关于OpenCV 2.4.3+与libstdc ++为iOS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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