Comment #16 on issue 449 by Link error while using clang++ with -stdlib=libc++ flag in OSX

I must say sorry for the mistake I made. I didn't notice that -stdlib=libc++ argument acts as a switch to decide whether libc++ to be used at linking time. It means, if using our previous configuration command line, -lc++ is useless while linking, because -lstdc++ will be passed to linker since -stdlib=libc++ is not specified.

So, I think configuration command line should be ./configure CC=clang CXX=clang++ CXXFLAGS='-stdlib=libc++' LDFLAGS='-stdlib=libc++'.

But, it still failed while linking. I checked the linker command line:
/bin/sh ../libtool --tag=CXX --mode=link clang++ -D_THREAD_SAFE -Wall -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare -stdlib=libc++ -version-info 8:0:0 -export-dynamic -no-undefined -stdlib=libc++ -o -rpath /usr/local/lib atomicops_internals_x86_gcc.lo atomicops_internals_x86_msvc.lo common.lo once.lo stringprintf.lo extension_set.lo generated_message_util.lo message_lite.lo repeated_field.lo wire_format_lite.lo coded_stream.lo zero_copy_stream.lo zero_copy_stream_impl_lite.lo strutil.lo substitute.lo structurally_valid.lo descriptor.lo descriptor.pb.lo descriptor_database.lo dynamic_message.lo extension_set_heavy.lo generated_message_reflection.lo message.lo reflection_ops.lo service.lo text_format.lo unknown_field_set.lo wire_format.lo gzip_stream.lo printer.lo tokenizer.lo zero_copy_stream_impl.lo importer.lo parser.lo -lz libtool: link: clang++ -dynamiclib -o .libs/libprotobuf.8.dylib .libs/atomicops_internals_x86_gcc.o .libs/atomicops_internals_x86_msvc.o .libs/common.o .libs/once.o .libs/stringprintf.o .libs/extension_set.o .libs/generated_message_util.o .libs/message_lite.o .libs/repeated_field.o .libs/wire_format_lite.o .libs/coded_stream.o .libs/zero_copy_stream.o .libs/zero_copy_stream_impl_lite.o .libs/strutil.o .libs/substitute.o .libs/structurally_valid.o .libs/descriptor.o .libs/descriptor.pb.o .libs/descriptor_database.o .libs/dynamic_message.o .libs/extension_set_heavy.o .libs/generated_message_reflection.o .libs/message.o .libs/reflection_ops.o .libs/service.o .libs/text_format.o .libs/unknown_field_set.o .libs/wire_format.o .libs/gzip_stream.o .libs/printer.o .libs/tokenizer.o .libs/zero_copy_stream_impl.o .libs/importer.o .libs/parser.o -lz -install_name /usr/local/lib/libprotobuf.8.dylib -compatibility_version 9 -current_version 9.0 -Wl,-single_module

2 files were linked, and libprotobuf.8.dylib. For, CXXFLAGS and LDFLAGS were both passed to clang++. But the 2 flags were missing while linking libprotobuf.8.dylib. Then I tried to add -stdlib=libc++ manually, everything was ok.

$ otool -L .libs/libprotobuf.8.dylib
/usr/local/lib/libprotobuf.8.dylib (compatibility version 9.0.0, current version 9.0.0) /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5) /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 65.1.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)

I guess that might be caused by configure script or autoconf or something else to generate Makefile.
So is that a problem?

You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:

You received this message because you are subscribed to the Google Groups "Protocol 
Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
To post to this group, send email to
Visit this group at
For more options, visit

Reply via email to