Compiling boost asio 1.50.0 under Xcode 4.3.3 with Clang or GCC and c++11 support

(Below) Is this is known issue, am I missing something, or does the libboost_system.a library need to be compiled differently than the default directions to work with c++11 support?
The following code produces linker errors when the compiler options -std=c++11and libc++ are used:
#include <iostream>
#include

On Jul 3, 2012, at 11:42 AM, Graham Reitz wrote:
(Below) Is this is known issue, am I missing something, or does the libboost_system.a library need to be compiled differently than the default directions to work with c++11 support?
The following code produces linker errors when the compiler options -std=c++11and libc++ are used:
#include <iostream> #include
int main( int argc, char* argv[] ) { return 0; }
Undefined symbols for architecture x86_64: "std::allocator<char>::allocator()", referenced from: (anonymous namespace)::generic_error_category::message(int) const in libboost_system.a(error_code.o) "std::basic_string
::basic_string(char const*, std::allocator<char> const&)", referenced from: (anonymous namespace)::generic_error_category::message(int) const in libboost_system.a(error_code.o) "std::allocator<char>::~allocator()", referenced from: (anonymous namespace)::generic_error_category::message(int) const in libboost_system.a(error_code.o) "std::basic_string ::basic_string()", referenced from: (anonymous namespace)::generic_error_category::message(int) const in libboost_system.a(error_code.o) "std::string::operator=(char const*)", referenced from: (anonymous namespace)::generic_error_category::message(int) const in libboost_system.a(error_code.o) "std::basic_string ::basic_string(std::string const&)", referenced from: (anonymous namespace)::generic_error_category::message(int) const in libboost_system.a(error_code.o) "std::basic_string ::~basic_string()", referenced from: (anonymous namespace)::generic_error_category::message(int) const in libboost_system.a(error_code.o) ___tcf_0 in libboost_system.a(error_code.o) ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
This is just a guess, but it looks like you built the boost lib with -stdlib=libc++, and the above code without -stdlib=libc++. Note that both the compile phase and the link phase needs to know about -stdlib=libc++. Howard

Thanks Howard, The default boost build does not include c++11 support, correct? i.e.
./bootstrap --prefix=./standard_build ./b2 install
Is this the correct build parameters to build boost with c++11 support?
./bootstrap.sh --with-toolset=clang --prefix=./c++11_build cxxflags="-std=c++11 -stdlib=libc++" ./b2 install
Graham On Jul 3, 2012, at 12:05 PM, Howard Hinnant wrote:
On Jul 3, 2012, at 11:42 AM, Graham Reitz wrote:
(Below) Is this is known issue, am I missing something, or does the libboost_system.a library need to be compiled differently than the default directions to work with c++11 support?
The following code produces linker errors when the compiler options -std=c++11and libc++ are used:
#include <iostream> #include
int main( int argc, char* argv[] ) { return 0; }
Undefined symbols for architecture x86_64: "std::allocator<char>::allocator()", referenced from: (anonymous namespace)::generic_error_category::message(int) const in libboost_system.a(error_code.o) "std::basic_string
::basic_string(char const*, std::allocator<char> const&)", referenced from: (anonymous namespace)::generic_error_category::message(int) const in libboost_system.a(error_code.o) "std::allocator<char>::~allocator()", referenced from: (anonymous namespace)::generic_error_category::message(int) const in libboost_system.a(error_code.o) "std::basic_string ::basic_string()", referenced from: (anonymous namespace)::generic_error_category::message(int) const in libboost_system.a(error_code.o) "std::string::operator=(char const*)", referenced from: (anonymous namespace)::generic_error_category::message(int) const in libboost_system.a(error_code.o) "std::basic_string ::basic_string(std::string const&)", referenced from: (anonymous namespace)::generic_error_category::message(int) const in libboost_system.a(error_code.o) "std::basic_string ::~basic_string()", referenced from: (anonymous namespace)::generic_error_category::message(int) const in libboost_system.a(error_code.o) ___tcf_0 in libboost_system.a(error_code.o) ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) This is just a guess, but it looks like you built the boost lib with -stdlib=libc++, and the above code without -stdlib=libc++. Note that both the compile phase and the link phase needs to know about -stdlib=libc++.
Howard
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Graham Reitz
-
Howard Hinnant