简体   繁体   English

XCode项目是否需要特殊设置才能使用预编译的boost库?

[英]Do XCode projects need special settings to use pre-compiled boost libraries?

I have just installed boost for the first time on my Intel Mac, and it works fine in general, as long as I use only boost's header files. 我刚刚在我的Intel Mac上安装了boost,一般情况下工作正常,只要我只使用boost的头文件。

But when I try to use a lib, in my case the regex lib, my app links and launches fine, but then it soon crashes in a regex related destructor. 但是当我尝试使用lib时,在我的情况下是正则表达式lib,我的应用程序链接并启动很好,但随后它很快崩溃在正则表达式相关的析构函数中。

This even happens with the simple test program that's given on boost.org's unix install page . 这甚至发生在boost.org的unix安装页面上给出的简单测试程序。

I wonder if I need to set special compile/link options (I've used the defaults for a C++ Tool) other than setting the search paths and including the regex lib, of course? 我想知道我是否需要设置特殊的编译/链接选项(我已经使用了C ++工具的默认值),而不是设置搜索路径和包括正则表达式lib,当然?

(BTW, I have verified that the default compiler on my system is indeed gcc 4.01, which is the same my test project in XCode uses) (顺便说一句,我已经验证我的系统上的默认编译器确实是gcc 4.01,这与我在XCode中使用的测试项目相同)

I know this thread is old, but now even with Boost 1.53 this still happens. 我知道这个线程很老,但现在即使使用Boost 1.53,这仍然会发生。 I was answered in an another later thread—cross-linking in case someone finds this one via Google or other search. 我在另一个后来的线程交叉链接中得到了回答,以防有人通过谷歌或其他搜索找到这个。

Recompiling with the C++11 option does the trick. 使用C ++ 11选项重新编译就可以了。 Apparently that is not default with clang. 显然,这不是默认的clang。

Answer to self: 回答自己:

While it's still not clear what causes this problem, there is a workaround: 虽然目前还不清楚导致此问题的原因,但有一种解决方法:

Instead of using the libs that the boost installer process builds, add the source code for the lib (in boost-main-folder/libs/ libname /src/) to your Xcode project instead, having Xcode compile the sources for you. 而不是使用boost安装程序进程构建的库,而是将lib的源代码(在boost-main-folder / libs / libname / src /中)添加到Xcode项目中,让Xcode为您编译源代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM