Home > Article > Backend Development > Why does Clang with libc in C 0x mode fail to link Boost::program_options examples?
Background:
When attempting to compile and link a Boost::program_options example using Clang in C 0x mode with libc , the following error occurs:
Undefined symbols for architecture x86_64: // Various undefined symbols related to Boost::program_options
Explanation:
The primary reason for this error is that libc is not binary compatible with GCC's libstdc . Specifically:
Solution:
To resolve this issue, you must rebuild Boost using Clang with libc as the standard library:
clang++ -stdlib=libc++ ...
Reason for Binary Incompatibility:
To prevent accidental mixing and runtime crashes due to binary incompatibility, libc leverages C 11's inline namespace feature to modify the ABI (Application Binary Interface) of std::string while maintaining the same API (Application Programming Interface). This ensures that the linker can differentiate between std::string from libstdc and std::string from libc .
The above is the detailed content of Why does Clang with libc in C 0x mode fail to link Boost::program_options examples?. For more information, please follow other related articles on the PHP Chinese website!