Build WebRTC using libc++ (MacOS)

1,615 views
Skip to first unread message

Peter Gusev

unread,
Jul 25, 2014, 5:01:22 PM7/25/14
to discuss...@googlegroups.com
I've checked built libraries in trunk/out/Release with nm utility and it showed that no std::__1::.. namespace is used which says to me that WebRTC was built using libstdc++ but not libc++. However I need WebRTC to be built with libc++ (-stdlib=libc++ flag for clang in MacOS). How one can achieve this?

Thank you in advance,

Tamas Timar

unread,
Nov 19, 2014, 10:02:23 AM11/19/14
to discuss...@googlegroups.com
Is there any progress on this topic?

I've tried to set use_custom_libcxx=1 in GYP in 3.55 branch but it seems it has no effect. In trunk I don't see that option anymore in common.gypi.

(I need it on iOS if there is any difference from Mac in this case.)

Thanks,
Tamas

Dan Winkler

unread,
Feb 11, 2015, 1:14:40 AM2/11/15
to discuss...@googlegroups.com
Has anyone figured out the correct place(s) to change the webrtc static library to use libc++ instead of libstdc++?  Any help would be greatly appreciated.

Dan Winkler

unread,
Feb 11, 2015, 6:09:00 AM2/11/15
to discuss...@googlegroups.com
Has anyone had any luck compiling webrtc native c++ api with libc++?  I am trying to navigate the various pieces of the .gyp project structure to find the magic place.

On Friday, July 25, 2014 at 5:01:22 PM UTC-4, Peter Gusev wrote:

Jon Hjelle

unread,
Feb 11, 2015, 5:31:23 PM2/11/15
to discuss...@googlegroups.com
I’m not certain if this works for Mac builds, but at least for iOS I’ve successfully done this by adding 'use_system_libcxx=1' to GYP_DEFINES.

Hjon
--

---
You received this message because you are subscribed to the Google Groups "discuss-webrtc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrt...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Peter Tseng

unread,
Jun 16, 2015, 2:41:06 AM6/16/15
to discuss...@googlegroups.com
Has anyone gotten this to work on OSX?

Peter Ehrlich

unread,
Jul 11, 2015, 2:40:20 AM7/11/15
to discuss...@googlegroups.com
I'm pretty new to a lot of this stuff, but figure I should post some partial progress for the sake of discussion.  As far as I've been able to tell, it is possible to update the .gyp files for libc++, as per this SO thread.  But, doing so would be difficult as there are a lot of them (and updates to all.gyp apparently don't cascade).

So instead, its possible to edit the .ninja files through scripting trial and error.  I've gotten some milage with this hackery:

1: Generate the output directory with:

> python webrtc/build/gyp_webrtc

2: Edit the .ninja files with some find and replace: 

> find ./out/Release/ -type f -print0 | xargs -0 sed -i -e 's/-std=c\+\+11 -fno-rtti/-std=c\+\+11 -stdlib=libc\+\+ -fno-rtti/g'

This will take every .ninja file which has a line like this:
  cflags_cc = -std=c++11 -fno-rtti -fno-exceptions $
and make it look like this:
  cflags_cc = -std=c++11 -stdlib=libc++ -fno-rtti -fno-exceptions $

Edit Release/build.ninja to use the right clang instead of gcc: 

cc = <base path>/webrtc-checkout/src/chromium/src/third_party/llvm-build/Release+Asserts/bin/clang


3: Build as you normally would:

ninja -v -C out/Release



Now this works, but not entirely.  Instead, some packages still crash with "std::__1::basic_string" "Undefined symbols for architecture x86_64" errors.


http://pastebin.com/jqKtxDCA


It seems that the dependencies google::protobuf, testing::internal::GTestLog, and possibly some others are not being actually built or linked with libc++, or that the correctly built libraries are not being found and used.  Hm.


Thanks for your thoughts,

--Peter

Reply all
Reply to author
Forward
0 new messages