I was writing a cmake project file with multiple dependencies, and when it tried to link boost-filesystem, it threw and undefined symbol error. The curious thing is that if the cmake file for boost was run independently of the larger project cmake file, it would link with any c++11 code just fine.
CMake Project file:
...
add_subdirectory(External/boost)
target_link_libraries(${PROJECT_NAME} boost_filesystem)
...
target_compile_options(${PROJECT_NAME} PUBLIC -stdlib=libc++)
target_compile_options(${PROJECT_NAME} PUBLIC -std=c++1y)
...
CMake boost file:
set(SRCS
libs/filesystem/src/codecvt_error_category.cpp
libs/filesystem/src/operations.cpp
libs/filesystem/src/path.cpp
libs/filesystem/src/path_traits.cpp
libs/filesystem/src/portability.cpp
libs/filesystem/src/unique_path.cpp
libs/filesystem/src/utf8_codecvt_facet.cpp
libs/filesystem/src/windows_file_codecvt.cpp
libs/smart_ptr/src/sp_collector.cpp
libs/smart_ptr/src/sp_debug_hooks.cpp
libs/system/src/error_code.cpp
)
include_directories(boost)
add_library(boost_filesystem STATIC ${SRCS})
target_compile_options(boost_filesystem PRIVATE -stdlib=libc++)
target_compile_options(boost_filesystem PRIVATE -std=c++11)
Part of the error in question:
Undefined symbols for architecture x86_64:
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::find_last_of(char const*, unsigned long, unsigned long) const", referenced from:
ArgsProcess::process(int, char const**) in ArgsProcess.cpp.o
(anonymous namespace)::filename_pos(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned long) in libboost_filesystem.a(path.cpp.o)
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::find_first_of(char const*, unsigned long, unsigned long) const", referenced from: