In the project I'm working on, I'm trying to use the curlpp library to make a simple html GET request. I pass the cpp file to clang++ with the following options:
clang++ -std=c++11 -stdlib=libc++ -I /usr/local/Cellar url_test.cpp
I then get these errors:
Undefined symbols for architecture x86_64:
"curlpp::OptionBase::OptionBase(CURLoption)", referenced from:
curlpp::Option<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::Option(CURLoption, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in url_test-541b93.o
"curlpp::OptionBase::~OptionBase()", referenced from:
curlpp::Option<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::Option(CURLoption, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in url_test-541b93.o
curlpp::Option<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::~Option() in url_test-541b93.o
"curlpp::UnsetOption::UnsetOption(char const*)", referenced from:
curlpp::Option<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::updateMeToOption(curlpp::OptionBase const&) in url_test-541b93.o
curlpp::OptionTrait<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, (CURLoption)10002>::updateHandleToMe(curlpp::internal::CurlHandle*) const in url_test-541b93.o
curlpp::Option<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::getValue() const in url_test-541b93.o
"curlpp::RuntimeError::~RuntimeError()", referenced from:
curlpp::UnsetOption::~UnsetOption() in url_test-541b93.o
"curlpp::libcurlRuntimeAssert(char const*, CURLcode)", referenced from:
void curlpp::internal::CurlHandle::option<void*>(CURLoption, void*) in url_test-541b93.o
"curlpp::Easy::perform()", referenced from:
_main in url_test-541b93.o
"curlpp::Easy::Easy()", referenced from:
_main in url_test-541b93.o
"curlpp::Easy::~Easy()", referenced from:
_main in url_test-541b93.o
"curlpp::Cleanup::Cleanup()", referenced from:
_main in url_test-541b93.o
"curlpp::Cleanup::~Cleanup()", referenced from:
_main in url_test-541b93.o
"curlpp::OptionBase::operator<(curlpp::OptionBase const&) const", referenced from:
vtable for curlpp::OptionTrait<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, (CURLoption)10002> in url_test-541b93.o
vtable for curlpp::Option<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > in url_test-541b93.o
"typeinfo for curlpp::LogicError", referenced from:
GCC_except_table0 in url_test-541b93.o
"typeinfo for curlpp::OptionBase", referenced from:
curlpp::Option<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::updateMeToOption(curlpp::OptionBase const&) in url_test-541b93.o
typeinfo for curlpp::Option<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > in url_test-541b93.o
"typeinfo for curlpp::RuntimeError", referenced from:
GCC_except_table0 in url_test-541b93.o
typeinfo for curlpp::UnsetOption in url_test-541b93.o
"_curl_easy_setopt", referenced from:
void curlpp::internal::CurlHandle::option<void*>(CURLoption, void*) in url_test-541b93.o
ld: symbol(s) not found for architecture x86_64
which I think means that the compiler cannot find any of the curlpp libraries.
Here's the code I'm trying to run:
1 #include <string>
2 #include <sstream>
3 #include <iostream>
4 #include <curlpp/cURLpp.hpp>
5 #include <curlpp/Easy.hpp>
6 #include <curlpp/Options.hpp>
7 #include <fstream>
8
9 using namespace curlpp::options;
10
11 int main(int, char **)
12 {
13 try
14 {
15 curlpp::Cleanup testCleanup;
16 curlpp::Easy miRequest;
17 miRequest.setOpt<Url>("http://www.wikipedia.org");
18 miRequest.perform();
19 }
20 catch(curlpp::RuntimeError & e)
21 {
22 std::cout << e.what() << std::endl;
23 }
24 catch(curlpp::LogicError & e)
25 {
26 std::cout << e.what() << std::endl;
27 }
28
29 return 0;
30 }
I'm running macOS Sierra 10.12.4 with Xcode command line tools and homebrew installed. I homebrew'd the curlpp library. I know that someone else was able to compile this project on Ubuntu 16.04 using gcc, so I think the issue is to do with macOS.
I'm quite new to cpp, so any help would be greatly appreciated!
You have to tell the compiler which libraries to link with your executable. In your case, the issue is solved by adding options -lcurlpp -lcurl.
By the way, the path you provide is not correct since headers actually reside in /usr/local/Cellar/curlpp/[insert version here]/include. Anyways, this compiles fine without adding include search path for libraries installed via homebrew since it automatically creates symlinks in /usr/local/include, which is one of default places for a compiler to search.
Your problem is that you are not linking the library you use. Add the library and you should be good.
Related
I followed the instruction on thier github https://github.com/openvinotoolkit/openvino to build it on macOS, done it and when i wrote a small code to check was all clear or not
#include <string>
#include <iostream>
#include <dlfcn.h>
#include <fstream>
#define USE_STATIC_IE
#define _CRT_SECURE_NO_WARNINGS
#include <ie_core.hpp>
using namespace :: std;
int main(){
dlopen("/Users/nk/Documents/HZ/openvino/inference-engine/temp/tbb/lib/libtbb.dylib", RTLD_LAZY);
dlopen("/Users/nk/Documents/HZ/openvino/bin/intel64/Release/lib/libngraph.dylib", RTLD_LAZY);
dlopen("/Users/nk/Documents/HZ/openvino/bin/intel64/Release/lib/libinference_engine_transformations.dylib", RTLD_LAZY);
dlopen("/Users/nk/Documents/HZ/openvino/bin/intel64/Release/lib/libinference_engine_legacy.dylib", RTLD_LAZY);
dlopen("/Users/nk/Documents/HZ/openvino/bin/intel64/Release/lib/libinference_engine.dylib", RTLD_LAZY);
dlopen("/Users/nk/Documents/HZ/openvino/bin/intel64/Release/lib/libinference_engine_lp_transformations.dylib", RTLD_LAZY);
dlopen("/Users/nk/Documents/HZ/openvino/bin/intel64/Release/lib/libMKLDNNPlugin.dylib", RTLD_LAZY);
const std::string pluginsFilePath = "/Users/nk/Documents/HZ/openvino/bin/intel64/Release/lib/plugins.xml";
InferenceEngine::Core ie(pluginsFilePath);
const auto info = ie.GetVersions("CPU");
if(!info.empty())
cout << "Yes";
return 0;
}
when i compile it with command
g++ -std=c++11 -I/Users/nk/Documents/HZ/openvino/inference-engine/include testdll.cpp -o testdll && "/Users/nk/Documents/FelenaSoft/"testdll
it gave me the error
Undefined symbols for architecture x86_64:
"InferenceEngine::Core::Core(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
_main in testdll-788073.o
"InferenceEngine::Core::GetVersions(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const", referenced from:
_main in testdll-788073.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
then i added .a libs and ran this command
g++ -std=c++11 -L/Users/nk/Documents/HZ/openvino/bin/intel64/Release/lib -lmkldnn -lpugixml -linference_engine_s -I/Users/nk/Documents/HZ/openvino/inference-engine/include testdll.cpp -o testdll && "/Users/nk/Documents/FelenaSoft/"testdll
and i got this
Undefined symbols for architecture x86_64:
"ngraph::as_output_vector(std::__1::vector<std::__1::shared_ptr<ngraph::Node>, std::__1::allocator<std::__1::shared_ptr<ngraph::Node> > > const&)", referenced from:
ngraph::Node::generate_adjoints(ngraph::autodiff::Adjoints&, std::__1::vector<std::__1::shared_ptr<ngraph::Node>, std::__1::allocator<std::__1::shared_ptr<ngraph::Node> > > const&) in libinference_engine_s.a(ie_rtti.cpp.o)
"ngraph::Node::match_node(ngraph::pattern::Matcher*, ngraph::Output<ngraph::Node> const&)", referenced from:
vtable for ExecGraphInfoSerialization::ExecutionNode in libinference_engine_s.a(ie_rtti.cpp.o)
"ngraph::Node::match_value(ngraph::pattern::Matcher*, ngraph::Output<ngraph::Node> const&, ngraph::Output<ngraph::Node> const&)", referenced from:
vtable for ExecGraphInfoSerialization::ExecutionNode in libinference_engine_s.a(ie_rtti.cpp.o)
"ngraph::Node::constant_fold(std::__1::vector<ngraph::Output<ngraph::Node>, std::__1::allocator<ngraph::Output<ngraph::Node> > >&, std::__1::vector<ngraph::Output<ngraph::Node>, std::__1::allocator<ngraph::Output<ngraph::Node> > > const&)", referenced from:
vtable for ExecGraphInfoSerialization::ExecutionNode in libinference_engine_s.a(ie_rtti.cpp.o)
"ngraph::Node::set_arguments(std::__1::vector<ngraph::Output<ngraph::Node>, std::__1::allocator<ngraph::Output<ngraph::Node> > > const&)", referenced from:
ExecGraphInfoSerialization::ExecutionNode::clone_with_new_inputs(std::__1::vector<ngraph::Output<ngraph::Node>, std::__1::allocator<ngraph::Output<ngraph::Node> > > const&) const in libinference_engine_s.a(ie_rtti.cpp.o)
"ngraph::Node::set_output_type(unsigned long, ngraph::element::Type const&, ngraph::PartialShape const&)", referenced from:
ExecGraphInfoSerialization::ExecutionNode::clone_with_new_inputs(std::__1::vector<ngraph::Output<ngraph::Node>, std::__1::allocator<ngraph::Output<ngraph::Node> > > const&) const in libinference_engine_s.a(ie_rtti.cpp.o)
"ngraph::Node::m_next_instance_id", referenced from:
std::__1::shared_ptr<ExecGraphInfoSerialization::ExecutionNode> std::__1::shared_ptr<ExecGraphInfoSerialization::ExecutionNode>::make_shared<>() in libinference_engine_s.a(ie_rtti.cpp.o)
"ngraph::Node::validate_and_infer_types()", referenced from:
vtable for ExecGraphInfoSerialization::ExecutionNode in libinference_engine_s.a(ie_rtti.cpp.o)
"ngraph::Node::evaluate(std::__1::vector<std::__1::shared_ptr<ngraph::runtime::HostTensor>, std::__1::allocator<std::__1::shared_ptr<ngraph::runtime::HostTensor> > > const&, std::__1::vector<std::__1::shared_ptr<ngraph::runtime::HostTensor>, std::__1::allocator<std::__1::shared_ptr<ngraph::runtime::HostTensor> > > const&)", referenced from:
vtable for ExecGraphInfoSerialization::ExecutionNode in libinference_engine_s.a(ie_rtti.cpp.o)
"ngraph::Node::~Node()", referenced from:
ExecGraphInfoSerialization::ExecutionNode::~ExecutionNode() in libinference_engine_s.a(ie_rtti.cpp.o)
ExecGraphInfoSerialization::ExecutionNode::~ExecutionNode() in libinference_engine_s.a(ie_rtti.cpp.o)
std::__1::__shared_ptr_emplace<ExecGraphInfoSerialization::ExecutionNode, std::__1::allocator<ExecGraphInfoSerialization::ExecutionNode> >::~__shared_ptr_emplace() in libinference_engine_s.a(ie_rtti.cpp.o)
std::__1::__shared_ptr_emplace<ExecGraphInfoSerialization::ExecutionNode, std::__1::allocator<ExecGraphInfoSerialization::ExecutionNode> >::~__shared_ptr_emplace() in libinference_engine_s.a(ie_rtti.cpp.o)
"ngraph::Node::is_dynamic() const", referenced from:
vtable for ExecGraphInfoSerialization::ExecutionNode in libinference_engine_s.a(ie_rtti.cpp.o)
"ngraph::Node::description() const", referenced from:
vtable for ExecGraphInfoSerialization::ExecutionNode in libinference_engine_s.a(ie_rtti.cpp.o)
"ngraph::Node::is_constant() const", referenced from:
vtable for ExecGraphInfoSerialization::ExecutionNode in libinference_engine_s.a(ie_rtti.cpp.o)
"ngraph::Node::get_arguments() const", referenced from:
vtable for ExecGraphInfoSerialization::ExecutionNode in libinference_engine_s.a(ie_rtti.cpp.o)
"ngraph::Node::get_output_size() const", referenced from:
ExecGraphInfoSerialization::ExecutionNode::clone_with_new_inputs(std::__1::vector<ngraph::Output<ngraph::Node>, std::__1::allocator<ngraph::Output<ngraph::Node> > > const&) const in libinference_engine_s.a(ie_rtti.cpp.o)
"ngraph::Node::write_description(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, unsigned int) const", referenced from:
vtable for ExecGraphInfoSerialization::ExecutionNode in libinference_engine_s.a(ie_rtti.cpp.o)
"ngraph::Node::copy_with_new_args(std::__1::vector<std::__1::shared_ptr<ngraph::Node>, std::__1::allocator<std::__1::shared_ptr<ngraph::Node> > > const&) const", referenced from:
vtable for ExecGraphInfoSerialization::ExecutionNode in libinference_engine_s.a(ie_rtti.cpp.o)
"ngraph::Node::get_output_element_type(unsigned long) const", referenced from:
ExecGraphInfoSerialization::ExecutionNode::clone_with_new_inputs(std::__1::vector<ngraph::Output<ngraph::Node>, std::__1::allocator<ngraph::Output<ngraph::Node> > > const&) const in libinference_engine_s.a(ie_rtti.cpp.o)
"ngraph::Node::get_default_output_index() const", referenced from:
vtable for ExecGraphInfoSerialization::ExecutionNode in libinference_engine_s.a(ie_rtti.cpp.o)
"ngraph::Node::get_output_partial_shape(unsigned long) const", referenced from:
ExecGraphInfoSerialization::ExecutionNode::clone_with_new_inputs(std::__1::vector<ngraph::Output<ngraph::Node>, std::__1::allocator<ngraph::Output<ngraph::Node> > > const&) const in libinference_engine_s.a(ie_rtti.cpp.o)
"ngraph::Node::get_autob() const", referenced from:
vtable for ExecGraphInfoSerialization::ExecutionNode in libinference_engine_s.a(ie_rtti.cpp.o)
"ngraph::Node::is_output() const", referenced from:
vtable for ExecGraphInfoSerialization::ExecutionNode in libinference_engine_s.a(ie_rtti.cpp.o)
"typeinfo for ngraph::Node", referenced from:
typeinfo for ExecGraphInfoSerialization::ExecutionNode in libinference_engine_s.a(ie_rtti.cpp.o)
"vtable for ngraph::Node", referenced from:
std::__1::shared_ptr<ExecGraphInfoSerialization::ExecutionNode> std::__1::shared_ptr<ExecGraphInfoSerialization::ExecutionNode>::make_shared<>() in libinference_engine_s.a(ie_rtti.cpp.o)
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Did anyone had the same problem as me, and did anyone know how to fix it?
First and foremost just need to cross check with you on your toolkit installation. Since you are trying to run a model already, I assume you already set it up properly as in (fyi latest version is 2020.4): https://docs.openvinotoolkit.org/latest/openvino_docs_install_guides_installing_openvino_macos.html
The error that you are getting, the Undefined symbols for architecture x86_64 is an Xcode build failure indicating you missed out something in your inference engine or the way you link the model with certain resources are incorrect or some other reasons. As long as this error persist you won't be able to compile your code. That is why you got the linker command failed with exit code 1.
Most error occurs because the users did not Set the OpenVINO environment variables or Configure the Model Optimizer correctly. This is why it's really important to Run verification scripts to verify installation and compile samples.
Before running any custom model, it is good to have a solid working Openvino environment, hence please help to check whether you could run the default models as in example here https://docs.openvinotoolkit.org/latest/openvino_docs_install_guides_installing_openvino_macos.html
By default, you should already have pre-trained models including open zoo model, Model Optimizer and Inference Engine which are working example to work with if you configured the toolkit correctly. These should already located in your installed toolkit's directory which you don't have to install separately from other resources.
Please take a note that you need:
CMake 3.4 or higher,
Python 3.5 or higher,
Apple Xcode Command Line Tools*,
(Optional) Apple Xcode* IDE (not required for OpenVINO, but useful for development),
And supported MAC OS is macOS 10.14.4*
Again, please help to cross check what you have in your Openvino environment and steps you had used to configure with the official documentation https://docs.openvinotoolkit.org/latest/openvino_docs_install_guides_installing_openvino_macos.html
Thanks!
When I link a dynamic library with CMake, create the make file and then use make, it compiles and builds correctly.
When I link a static library, CMake doesn't complain but when I run make, it throws a linker error at me, even though all I did was replace the .dylib with a .a of the same name.
This is my CMake file linking to a static library:
cmake_minimum_required (VERSION 3.0)
add_executable (TEST main.cpp)
include_directories ("${CMAKE_SOURCE_DIR}/Dependencies/libpqxx/include")
target_link_libraries (TEST "${CMAKE_SOURCE_DIR}/Dependencies/libpqxx/lib/libpqxx.a")
Any ideas?
Output for cmake:
>> cmake .
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/john/Documents/Test/src
Output for make:
>> make
[ 33%] Linking CXX executable TEST
Undefined symbols for architecture x86_64:
"_PQbackendPID", referenced from:
pqxx::connection_base::backendpid() const in libpqxx.a(connection_base.o)
"_PQcancel", referenced from:
pqxx::connection_base::cancel_query() in libpqxx.a(connection_base.o)
"_PQclear", referenced from:
pqxx::internal::clear_result(pg_result const*) in libpqxx.a(result.o)
"_PQclientEncoding", referenced from:
pqxx::connection_base::encoding_code() in libpqxx.a(connection_base.o)
"_PQcmdStatus", referenced from:
pqxx::result::cmd_status() const in libpqxx.a(result.o)
"_PQcmdTuples", referenced from:
pqxx::result::affected_rows() const in libpqxx.a(result.o)
"_PQconnectPoll", referenced from:
pqxx::connect_async::do_completeconnect(pg_conn*) in libpqxx.a(connection.o)
"_PQconnectStart", referenced from:
pqxx::connect_async::do_startconnect(pg_conn*) in libpqxx.a(connection.o)
"_PQconnectdb", referenced from:
pqxx::connectionpolicy::normalconnect(pg_conn*) in libpqxx.a(connection.o)
"_PQconsumeInput", referenced from:
pqxx::connection_base::consume_input() in libpqxx.a(connection_base.o)
"_PQdb", referenced from:
pqxx::connection_base::dbname() in libpqxx.a(connection_base.o)
"_PQencryptPassword", referenced from:
pqxx::encrypt_password(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libpqxx.a(connection_base.o)
"_PQendcopy", referenced from:
pqxx::connection_base::write_copy_line(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libpqxx.a(connection_base.o)
"_PQerrorMessage", referenced from:
pqxx::connection_base::err_msg() const in libpqxx.a(connection_base.o)
pqxx::connectionpolicy::normalconnect(pg_conn*) in libpqxx.a(connection.o)
pqxx::connect_direct::do_startconnect(pg_conn*) in libpqxx.a(connection.o)
pqxx::connect_async::do_startconnect(pg_conn*) in libpqxx.a(connection.o)
pqxx::connect_async::do_completeconnect(pg_conn*) in libpqxx.a(connection.o)
"_PQescapeByteaConn", referenced from:
pqxx::connection_base::esc_raw(unsigned char const*, unsigned long) in libpqxx.a(connection_base.o)
"_PQescapeIdentifier", referenced from:
pqxx::connection_base::quote_name(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libpqxx.a(connection_base.o)
"_PQescapeStringConn", referenced from:
pqxx::connection_base::esc(char const*, unsigned long) in libpqxx.a(connection_base.o)
"_PQexec", referenced from:
pqxx::connection_base::exec(char const*, int) in libpqxx.a(connection_base.o)
pqxx::connection_base::add_receiver(pqxx::notification_receiver*) in libpqxx.a(connection_base.o)
"_PQexecParams", referenced from:
pqxx::connection_base::parameterized_exec(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char const* const*, int const*, int const*, int) in libpqxx.a(connection_base.o)
pqxx::connection_base::exec_params(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, pqxx::internal::params const&) in libpqxx.a(connection_base.o)
"_PQexecPrepared", referenced from:
pqxx::connection_base::prepared_exec(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char const* const*, int const*, int const*, int) in libpqxx.a(connection_base.o)
pqxx::connection_base::exec_prepared(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, pqxx::internal::params const&) in libpqxx.a(connection_base.o)
"_PQfinish", referenced from:
pqxx::connectionpolicy::normalconnect(pg_conn*) in libpqxx.a(connection.o)
pqxx::connectionpolicy::do_disconnect(pg_conn*) in libpqxx.a(connection.o)
"_PQfname", referenced from:
pqxx::result::column_name(unsigned int) const in libpqxx.a(result.o)
"_PQfnumber", referenced from:
pqxx::result::column_number(char const*) const in libpqxx.a(row.o)
"_PQfreeCancel", referenced from:
(anonymous namespace)::cancel_wrapper::~cancel_wrapper() in libpqxx.a(connection_base.o)
"_PQfreemem", referenced from:
pqxx::internal::freepqmem(void const*) in libpqxx.a(util.o)
"_PQftable", referenced from:
pqxx::result::column_table(unsigned int) const in libpqxx.a(result.o)
"_PQftablecol", referenced from:
pqxx::result::table_column(unsigned int) const in libpqxx.a(result.o)
"_PQftype", referenced from:
pqxx::result::column_type(unsigned int) const in libpqxx.a(result.o)
"_PQgetCancel", referenced from:
pqxx::connection_base::cancel_query() in libpqxx.a(connection_base.o)
"_PQgetCopyData", referenced from:
pqxx::connection_base::read_copy_line(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) in libpqxx.a(connection_base.o)
"_PQgetResult", referenced from:
pqxx::connection_base::set_up_state() in libpqxx.a(connection_base.o)
pqxx::connection_base::read_copy_line(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) in libpqxx.a(connection_base.o)
pqxx::connection_base::end_copy_write() in libpqxx.a(connection_base.o)
pqxx::connection_base::get_result() in libpqxx.a(connection_base.o)
"_PQgetisnull", referenced from:
pqxx::result::get_is_null(unsigned long, unsigned int) const in libpqxx.a(result.o)
"_PQgetlength", referenced from:
pqxx::result::get_length(unsigned long, unsigned int) const in libpqxx.a(result.o)
"_PQgetvalue", referenced from:
pqxx::result::GetValue(unsigned long, unsigned int) const in libpqxx.a(result.o)
"_PQhost", referenced from:
pqxx::connection_base::hostname() in libpqxx.a(connection_base.o)
"_PQisBusy", referenced from:
pqxx::connection_base::is_busy() const in libpqxx.a(connection_base.o)
"_PQisthreadsafe", referenced from:
pqxx::describe_thread_safety() in libpqxx.a(util.o)
"_PQnfields", referenced from:
pqxx::result::columns() const in libpqxx.a(result.o)
"_PQnotifies", referenced from:
pqxx::connection_base::get_notifs() in libpqxx.a(connection_base.o)
"_PQntuples", referenced from:
pqxx::result::size() const in libpqxx.a(result.o)
pqxx::result::empty() const in libpqxx.a(result.o)
"_PQoidValue", referenced from:
pqxx::result::inserted_oid() const in libpqxx.a(result.o)
"_PQport", referenced from:
pqxx::connection_base::port() in libpqxx.a(connection_base.o)
"_PQprepare", referenced from:
pqxx::connection_base::register_prepared(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libpqxx.a(connection_base.o)
"_PQprotocolVersion", referenced from:
pqxx::connection_base::protocol_version() const in libpqxx.a(connection_base.o)
"_PQputCopyData", referenced from:
pqxx::connection_base::write_copy_line(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libpqxx.a(connection_base.o)
"_PQputCopyEnd", referenced from:
pqxx::connection_base::end_copy_write() in libpqxx.a(connection_base.o)
"_PQreset", referenced from:
pqxx::connection_base::reset() in libpqxx.a(connection_base.o)
"_PQresultErrorField", referenced from:
pqxx::result::ThrowSQLError(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const in libpqxx.a(result.o)
pqxx::result::errorposition() const in libpqxx.a(result.o)
"_PQresultErrorMessage", referenced from:
pqxx::result::StatusError() const in libpqxx.a(result.o)
"_PQresultStatus", referenced from:
pqxx::result::StatusError() const in libpqxx.a(result.o)
"_PQsendQuery", referenced from:
pqxx::connection_base::set_up_state() in libpqxx.a(connection_base.o)
pqxx::connection_base::start_exec(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libpqxx.a(connection_base.o)
"_PQserverVersion", referenced from:
pqxx::connection_base::read_capabilities() in libpqxx.a(connection_base.o)
"_PQsetErrorVerbosity", referenced from:
pqxx::connection_base::set_verbosity(pqxx::connection_base::error_verbosity) in libpqxx.a(connection_base.o)
"_PQsetNoticeProcessor", referenced from:
pqxx::connection_base::set_up_state() in libpqxx.a(connection_base.o)
pqxx::connection_base::close() in libpqxx.a(connection_base.o)
"_PQsocket", referenced from:
(anonymous namespace)::socket_of(pg_conn const*) in libpqxx.a(connection_base.o)
"_PQstatus", referenced from:
pqxx::connection_base::status() const in libpqxx.a(connection_base.o)
pqxx::connectionpolicy::normalconnect(pg_conn*) in libpqxx.a(connection.o)
pqxx::connect_direct::do_startconnect(pg_conn*) in libpqxx.a(connection.o)
pqxx::connect_async::do_startconnect(pg_conn*) in libpqxx.a(connection.o)
"_PQtrace", referenced from:
pqxx::connection_base::internal_set_trace() in libpqxx.a(connection_base.o)
"_PQunescapeBytea", referenced from:
pqxx::connection_base::unesc_raw(char const*) in libpqxx.a(connection_base.o)
"_PQuntrace", referenced from:
pqxx::connection_base::internal_set_trace() in libpqxx.a(connection_base.o)
"_PQuser", referenced from:
pqxx::connection_base::username() in libpqxx.a(connection_base.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [TEST] Error 1
make[1]: *** [CMakeFiles/TEST.dir/all] Error 2
make: *** [all] Error 2
if you send error messages it'd be better , but try this:
link_directories(${CMAKE_SOURCE_DIR}/Dependencies/libpqxx/lib)
target_link_libraries (TEST pqxx)
I've figured it out. I was just missing some dependencies for the pqxx library. I've added a reference to libpq.a, libssl.a, and libcrypto.a as well as their include/ directories and it ended up working. I guess .dylib files link to dependencies by themselves but you have to manually include them with static libraries?
I have been following many other answers here on StackOverflow and other resources, but I can't get clang to work with boost 1.63 on macOS. Simply installed boost:
./bootstrap.sh --prefix=/usr/local
./b2 cxxflags="-stdlib=libc++" linkflags="-stdlib=libc++"
Now. Im just doing the following:
#include <boost/program_options.hpp>
namespace po = boost::program_options;
int main()
{
// Declare the supported options.
po::options_description desc("Allowed options");
desc.add_options()
("help", "produce help message")
("compression", po::value<int>(), "set compression level")
;
}
This gives me:
clang++ \
-g -Wall -Wextra \
-std=c++14 \
-stdlib=libc++ \
-I /usr/local/include \
-L /usr/local/lib \
./src/main.cpp \
-o ./src/tool.o
Undefined symbols for architecture x86_64:
"boost::program_options::validators::check_first_occurrence(boost::any const&)", referenced from:
void boost::program_options::validate<int, char>(boost::any&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, int*, long) in main-afe96c.o
"boost::program_options::validation_error::get_template(boost::program_options::validation_error::kind_t)", referenced from:
boost::program_options::validation_error::validation_error(boost::program_options::validation_error::kind_t, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int) in main-afe96c.o
"boost::program_options::options_description::add_options()", referenced from:
_main in main-afe96c.o
"boost::program_options::options_description::m_default_line_length", referenced from:
_main in main-afe96c.o
"boost::program_options::options_description::options_description(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned int, unsigned int)", referenced from:
_main in main-afe96c.o
"boost::program_options::invalid_option_value::invalid_option_value(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
void boost::program_options::validate<int, char>(boost::any&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, std::__1::vector<int, std::__1::allocator<int> >*, int) in main-afe96c.o
void boost::program_options::validate<int, char>(boost::any&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, int*, long) in main-afe96c.o
"boost::program_options::error_with_option_name::error_with_option_name(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int)", referenced from:
boost::program_options::validation_error::validation_error(boost::program_options::validation_error::kind_t, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int) in main-afe96c.o
"boost::program_options::options_description_easy_init::operator()(char const*, boost::program_options::value_semantic const*, char const*)", referenced from:
_main in main-afe96c.o
"boost::program_options::options_description_easy_init::operator()(char const*, char const*)", referenced from:
_main in main-afe96c.o
"boost::program_options::arg", referenced from:
boost::program_options::typed_value<std::__1::vector<int, std::__1::allocator<int> >, char>::name() const in main-afe96c.o
"boost::program_options::error_with_option_name::substitute_placeholders(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const", referenced from:
vtable for boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::program_options::validation_error> > in main-afe96c.o
vtable for boost::exception_detail::error_info_injector<boost::program_options::validation_error> in main-afe96c.o
vtable for boost::program_options::validation_error in main-afe96c.o
vtable for boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::program_options::invalid_option_value> > in main-afe96c.o
vtable for boost::exception_detail::error_info_injector<boost::program_options::invalid_option_value> in main-afe96c.o
vtable for boost::program_options::invalid_option_value in main-afe96c.o
"boost::program_options::error_with_option_name::what() const", referenced from:
vtable for boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::program_options::validation_error> > in main-afe96c.o
vtable for boost::exception_detail::error_info_injector<boost::program_options::validation_error> in main-afe96c.o
vtable for boost::program_options::validation_error in main-afe96c.o
vtable for boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::program_options::invalid_option_value> > in main-afe96c.o
vtable for boost::exception_detail::error_info_injector<boost::program_options::invalid_option_value> in main-afe96c.o
vtable for boost::program_options::invalid_option_value in main-afe96c.o
"boost::program_options::value_semantic_codecvt_helper<char>::parse(boost::any&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, bool) const", referenced from:
vtable for boost::program_options::typed_value<std::__1::vector<int, std::__1::allocator<int> >, char> in main-afe96c.o
"typeinfo for boost::program_options::error_with_option_name", referenced from:
typeinfo for boost::program_options::validation_error in main-afe96c.o
"typeinfo for boost::program_options::value_semantic_codecvt_helper<char>", referenced from:
typeinfo for boost::program_options::typed_value<std::__1::vector<int, std::__1::allocator<int> >, char> in main-afe96c.o
"vtable for boost::program_options::error_with_option_name", referenced from:
boost::program_options::error_with_option_name::error_with_option_name(boost::program_options::error_with_option_name const&) in main-afe96c.o
boost::program_options::error_with_option_name::~error_with_option_name() in main-afe96c.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
"vtable for boost::program_options::value_semantic_codecvt_helper<char>", referenced from:
boost::program_options::value_semantic_codecvt_helper<char>::value_semantic_codecvt_helper() in main-afe96c.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [annorna] Error 1
However, adding -l boost_system does not work. What is the solution to get boost going? Is the path wrong? OR do I need some other flag?
I have R 3.0.3 installed with mac ports on OS X 10.9.2. I installed RInside with sudo R CMD INSTALL ~/Downloads/RInside_0.2.11.tgz (similarly Rcpp_0.11.1.tar). I am trying to compile a simple RInside Help World code from http://dirk.eddelbuettel.com/code/rinside.html. I am trying to use
g++ main.cpp -I/Users/robogos/Library/R/3.0/library/RInside/include/ -I/Users/robogos/Library/R/3.0/library/Rcpp/include/ -I/opt/local/Library/Frameworks/R.framework/Versions/3.0/Resources/include/
and I get a long list of errors:
Undefined symbols for architecture x86_64:
"_REprintf", referenced from:
Rcpp::Rstreambuf<false>::xsputn(char const*, long) in main-4b77b4.o
Rcpp::Rstreambuf<false>::overflow(int) in main-4b77b4.o
"_R_BindingIsLocked", referenced from:
Rcpp::Environment_Impl<Rcpp::PreserveStorage>::bindingIsLocked(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const in main-4b77b4.o
"_R_FlushConsole", referenced from:
Rcpp::Rstreambuf<false>::sync() in main-4b77b4.o
Rcpp::Rstreambuf<true>::sync() in main-4b77b4.o
"_R_NilValue", referenced from:
Rcpp::wrap(char const*) in main-4b77b4.o
"_R_UnboundValue", referenced from:
Rcpp::Environment_Impl<Rcpp::PreserveStorage>::exists(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const in main-4b77b4.o
"_Rf_defineVar", referenced from:
Rcpp::Environment_Impl<Rcpp::PreserveStorage>::assign(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, SEXPREC*) const in main-4b77b4.o
"_Rf_findVarInFrame", referenced from:
Rcpp::Environment_Impl<Rcpp::PreserveStorage>::exists(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const in main-4b77b4.o
"_Rf_install", referenced from:
Rcpp::Environment_Impl<Rcpp::PreserveStorage>::assign(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, SEXPREC*) const in main-4b77b4.o
Rcpp::Environment_Impl<Rcpp::PreserveStorage>::exists(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const in main-4b77b4.o
Rcpp::Environment_Impl<Rcpp::PreserveStorage>::bindingIsLocked(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const in main-4b77b4.o
"_Rf_mkString", referenced from:
Rcpp::wrap(char const*) in main-4b77b4.o
"_Rprintf", referenced from:
Rcpp::Rstreambuf<true>::xsputn(char const*, long) in main-4b77b4.o
Rcpp::Rstreambuf<true>::overflow(int) in main-4b77b4.o
"RInside::parseEvalQ(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
_main in main-4b77b4.o
"RInside::RInside(int, char const* const*, bool, bool, bool)", referenced from:
_main in main-4b77b4.o
"RInside::~RInside()", referenced from:
_main in main-4b77b4.o
"RInside::operator[](std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
_main in main-4b77b4.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I have tried what Dirk Eddelbuettel suggested, but now I receive:
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/Library/Frameworks/R.framework/Versions/3.0/Resources/library/stats/libs/stats.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.0/Resources/library/stats/libs/stats.so, 6): Symbol not found: __gfortran_pow_r8_i4
Referenced from: /Library/Frameworks/R.framework/Versions/3.0/Resources/lib/libRlapack.dylib
Expected in: /Applications/MATLAB_R2013a.app/sys/os/maci64//libgfortran.2.dylib
in /Library/Frameworks/R.framework/Versions/3.0/Resources/lib/libRlapack.dylib
During startup - Warning message:
package ‘stats’ in options("defaultPackages") was not found
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/Library/Frameworks/R.framework/Versions/3.0/Resources/library/stats/libs/stats.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.0/Resources/library/stats/libs/stats.so, 6): Symbol not found: __gfortran_pow_r8_i4
Referenced from: /Library/Frameworks/R.framework/Versions/3.0/Resources/lib/libRlapack.dylib
Expected in: /Applications/MATLAB_R2013a.app/sys/os/maci64//libgfortran.2.dylib
in /Library/Frameworks/R.framework/Versions/3.0/Resources/lib/libRlapack.dylib
During startup - Warning message:
package ‘stats’ in options("defaultPackages") was not found
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/Library/Frameworks/R.framework/Versions/3.0/Resources/library/stats/libs/stats.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.0/Resources/library/stats/libs/stats.so, 6): Symbol not found: __gfortran_pow_r8_i4
Referenced from: /Library/Frameworks/R.framework/Versions/3.0/Resources/lib/libRlapack.dylib
Expected in: /Applications/MATLAB_R2013a.app/sys/os/maci64//libgfortran.2.dylib
in /Library/Frameworks/R.framework/Versions/3.0/Resources/lib/libRlapack.dylib
During startup - Warning message:
package ‘stats’ in options("defaultPackages") was not found
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/Library/Frameworks/R.framework/Versions/3.0/Resources/library/stats/libs/stats.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.0/Resources/library/stats/libs/stats.so, 6): Symbol not found: __gfortran_pow_r8_i4
Referenced from: /Library/Frameworks/R.framework/Versions/3.0/Resources/lib/libRlapack.dylib
Expected in: /Applications/MATLAB_R2013a.app/sys/os/maci64//libgfortran.2.dylib
in /Library/Frameworks/R.framework/Versions/3.0/Resources/lib/libRlapack.dylib
During startup - Warning message:
package ‘stats’ in options("defaultPackages") was not found
make: Nothing to be done for `rinside_sample0.cpp'.
I have seen suggestions like !unset DYLD_LIBRARY_PATH;, but I do not know how to do this in my case.
The use pattern is to
cd into the examples/standard/ directory
run make
or run make rinside_sample0 (or any other name) if you want to build just one.
You can add your own files, and make nameofthefile will build an executable.
In short, you can't just call g++ as you did.
Compiling this example code for boost::program_options: http://svn.boost.org/svn/boost/trunk/libs/program_options/example/first.cpp
...on MacOS Lion (10.7.2), using boost-1.48.0 installed with MacPorts:
$ clang++ -v
Apple clang version 3.0 (tags/Apple/clang-211.12) (based on LLVM 3.0svn)
Target: x86_64-apple-darwin11.2.0
Thread model: posix
$ clang++ -std=c++0x --stdlib=libc++ -lc++ -I/opt/local/include -L/opt/local/lib -lboost_program_options first.cpp -o first
Undefined symbols for architecture x86_64:
"boost::program_options::options_description::options_description(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned int, unsigned int)", referenced from:
_main in cc-6QQcwm.o
"boost::program_options::operator<<(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, boost::program_options::options_description const&)", referenced from:
_main in cc-6QQcwm.o
"boost::program_options::abstract_variables_map::operator[](std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const", referenced from:
boost::program_options::variables_map::operator[](std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const in cc-6QQcwm.o
"boost::program_options::detail::cmdline::set_additional_parser(boost::function1<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&>)", referenced from:
boost::program_options::basic_command_line_parser<char>::extra_parser(boost::function1<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&>) in cc-6QQcwm.o
"boost::program_options::detail::cmdline::cmdline(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&)", referenced from:
boost::program_options::basic_command_line_parser<char>::basic_command_line_parser(int, char const* const*) in cc-6QQcwm.o
"boost::program_options::to_internal(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > boost::program_options::to_internal<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) in cc-6QQcwm.o
"boost::program_options::invalid_option_value::invalid_option_value(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
void boost::program_options::validate<int, char>(boost::any&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, int*, long) in cc-6QQcwm.o
"boost::program_options::validation_error::validation_error(boost::program_options::validation_error::kind_t, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const& boost::program_options::validators::get_single_string<char>(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, bool) in cc-6QQcwm.o
"boost::program_options::value_semantic_codecvt_helper<char>::parse(boost::any&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, bool) const", referenced from:
vtable for boost::program_options::typed_value<int, char> in cc-6QQcwm.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The same code compiled/linked with g++4.7 installed with MacPorts:
$ g++-mp-4.7 -std=c++0x -I/opt/local/include -L/opt/local/lib -lboost_program_options -o first first.cpp
... works fine. As does using clang without libc++:
clang++ -std=c++0x -I/opt/local/include -L/opt/local/lib -lboost_program_options first.cpp -o first
What's wrong? Why does boost::program_options and libc++ not work together?
You need to rebuild boost using clang++ -stdlib=libc++.
libc++ is not binary compatible with gcc's libstdc++ (except for some low level stuff such as operator new). For example the std::string in gcc's libstdc++ is refcounted, whereas in libc++ it uses the "short string optimization". If you were to accidentally mix these two strings in the same program (and mistake them for the same data structure), you would inevitably get a run time crash.
This accident is exactly what has occurred in your case.
In order to turn this run time crash into a link time error, libc++ uses a C++11 language feature called inline namespace to change the ABI of std::string without impacting the API of std::string. That is, to you std::string looks the same. But to the linker, std::string is being mangled as if it is in namespace std::__1. Thus the linker knows that std::basic_string and std::__1::basic_string are two different data structures (the former coming from gcc's libstdc++ and the latter coming from libc++).