链接错误编译一个混合的目标C / C ++项目与C ++ 11支持在xcode 4.5.2 [英] Link errors compiling a mixed objective-C/C++ project with C++11 support in xcode 4.5.2

查看:288
本文介绍了链接错误编译一个混合的目标C / C ++项目与C ++ 11支持在xcode 4.5.2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图编译一个工作区的3个项目,支持C ++ 11。这组项目已成功使用LLVM编译器缺省值进行编译和链接。此外,c ++代码以前编译过许多编译器,包括g ++,llvm,msvc,sun,irix等,所以它是非常干净的代码。

I am trying to compile a workspace of 3 projects with C++11 support. This set of projects has successfully compiled and linked using LLVM compiler defaults. In addition, the c++ code has previously compiled on a number of compilers including g++, llvm, msvc, sun, irix etc so it is very clean code.

语言方言部分的工作区构建设置有3个行项:

Under the c++ language dialect section of the workspace build settings there are 3 line items:

c语言方言

c ++语言方言

c ++标准库

c language dialect
c++ language dialect
c++ standard library

使用设置:

c语言方言:编译器默认

c ++语言方言:编译器默认

c ++标准库:libc ++(支持c ++ 11的LLVM c ++标准库)

c language dialect: compiler default
c++ language dialect: compiler default
c++ standard library: libc++ (LLVM c++ standard library with c++11 support)

很多链接错误。一些来自我们自己的函数,一些来自标准函数。下面是标准函数的链接错误示例:

I can successfully compile but get many link errors. Some are from our own functions and some are from standard functions. Here is a sample of link errors to standard functions:

(null):std :: string :: find_last_of(char const *,unsigned long)const从:
(null):std :: string :: size()const,引用自:

(null): "std::string::find_last_of(char const*, unsigned long) const", referenced from: (null): "std::string::size() const", referenced from:

看起来很清楚,错误的标准库,所以我调查了改变上面的各种选项。将方言更改为-std = c ++ 11甚至打破了我的编译。我找不到适合我的组合。

It seemed clear that I was linking to the wrong standard library, so I investigated changing various options above. Changing the dialect to -std=c++11 even broke my compilation. I could not find a combination that worked for me.

你能建议什么错误吗?

:我的动机是这样做的,我想在我的c ++代码中使用接口与objective-c(和那个c ++代码仍然是可移植的)

my motivation for doing this is that I want to use std::thread in my c++ code that interfaces with objective-c (and have that c++ code still be portable)

推荐答案

XCode 4.5.2 / OSX 10.8.2

XCode 4.5.2 / OSX 10.8.2

我一直在得到这些

(null): "std::string::find_last_of(char const*, unsigned long) const", 
 referenced from: (null):    "std::string::size() const", referenced from:

不同版本的openCV图书馆。似乎问题是访问C ++标准库。在这种情况下,工作设置如下:

Variously with different versions of openCV libraries. It seems like the issue is access to the C++ standard library. In this case working settings were as follows:

旧版库:

C Language Dialect GNU99[-std=gnu99]
C++ Language Dialect GNU++11[-std=gnu++11]
C++ Standard Library libstdc++ (GNU C++ standard library)

最近的图书馆版本:

C Language Dialect GNU99[-std=gnu99]
C++ Language Dialect GNU++11[-std=gnu++11]
C++ Standard Library libc++ (LLVM C++ standard library with C++11 support)

将标准库规范切换到其中一个版本会产生这些错误。

Toggling the standard library spec to either version yields those errors.

这篇关于链接错误编译一个混合的目标C / C ++项目与C ++ 11支持在xcode 4.5.2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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