问题描述
我的情况与中讨论的情况非常相似.我要执行此操作的原因是我将OpenCV与CUDA 6.0一起使用,但是CUDA当前与libstdc ++链接.我遵循了建议放置标志-stdlib=libstdc++
的答案,以及我们设置CXX
和CXXFLAGS
的另一种方法,但是正如被评论的那样:Macports似乎不承认这些标志,并且仍然使用libc ++而不是预期的libstdc ++.
My situation is very similar to what's discussed in this thread. The reason I want to do this is that I am using OpenCV with CUDA 6.0, but CUDA is currently linked against libstdc++. I followed the answer that suggested putting the flag -stdlib=libstdc++
as well as the other approach where we set CXX
and CXXFLAGS
but as it was being commented: Macports did not seem to acknowledge the flags and still built with libc++ instead of intended libstdc++.
我想在该话题中发表评论以要求采取后续行动,但不幸的是,我还没有足够的声誉.
I would like to comment on that thread to ask for a follow-up, but unfortunately I do not have enough reputation yet.
有人知道如何让Macports与libstdc ++一起安装OpenCV吗?
Does anyone know how to get Macports to install OpenCV with libstdc++?
我没有回过头来检查下面提供的答案之一是否有效.使用libstdc ++编译OpenCV会导致其他一些主要使用libc ++的非CUDA项目出现问题,因此我不太可能尝试.但是,如果有人可以在下面尝试一个答案并可以给我评论,我会接受一个答案.
Edited 1: I have not gone back to check whether or not one of the answers provided below works. Compiling OpenCV with libstdc++ will cause issues with a few other non-CUDA projects that use libc++ primarily, so it is unlikely I will try. I will, however, accept an answer if someone can try out an answer below and comment to me if it works.
该问题不再适用于我的情况,因为默认情况下CUDA 7.0 RC支持libc ++.我仍然会按照修改版1"接受答案.
Edited 2: This question no longer applies to my situation since CUDA 7.0 RC has libc++ support by default. I will still accept an answer per Edited 1.
推荐答案
在boost的情况下,我能够强迫MacPorts链接libstdc ++,就像这样:
In the case of boost, I was able to force MacPorts to link against libstdc++ like so:
sudo port -s install boost configure.cxx_stdlib="libstdc++" configure.compiler="macports-gcc-4.7"
就是这样!显然,您无需自己传递"-stdlib = libstdc ++". otool -L显示了我希望看到的内容:
And that was it! Apparently there's no need to pass "-stdlib=libstdc++" yourself. otool -L shows what I was hoping to see:
$ otool -L /opt/local/lib/libboost_date_time-mt.dylib
/opt/local/lib/libboost_date_time-mt.dylib:
/opt/local/lib/libboost_date_time-mt.dylib (compatibility version 0.0.0, current version 0.0.0)
/opt/local/lib/libgcc/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.18.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)
/opt/local/lib/libgcc/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
这篇关于OSX 10.9上的Macports-使用libstdc ++编译opencv的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!