Boost was installed and make by: brew install boost
Added the header path /usr/local/Cellar/boost/1.53.0/include to User Header Search Path
Added the library path /usr/local/Cellar/boost/1.53.0/lib to Library Search Path
main.cpp
#include <fstream>
#include <sstream>
#include <string>
#include "test.cpp"
void test(){
Test instance(true, 'm', 50, 17.89, "fuzhijie");
stringstream binary_sstream;
boost::archive::binary_oarchive binary_oa(binary_sstream);
binary_oa << instance;
}
int main(int argc, const char * argv[])
{
test();
return 0;
}
When I press CTRL+b, the following error message is shown:
Undefined symbols for architecture x86_64:
"boost::archive::basic_binary_oprimitive<boost::archive::binary_oarchive, char, std::__1::char_traits<char> >::init()", referenced from:
boost::archive::binary_oarchive_impl<boost::archive::binary_oarchive, char, std::__1::char_traits<char> >::init(unsigned int) in main.o
"boost::archive::basic_binary_oprimitive<boost::archive::binary_oarchive, char, std::__1::char_traits<char> >::save(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
void boost::archive::save_access::save_primitive<boost::archive::binary_oarchive, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(boost::archive::binary_oarchive&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in main.o
"boost::archive::basic_binary_oprimitive<boost::archive::binary_oarchive, char, std::__1::char_traits<char> >::basic_binary_oprimitive(std::__1::basic_streambuf<char, std::__1::char_traits<char> >&, bool)", referenced from:
boost::archive::binary_oarchive_impl<boost::archive::binary_oarchive, char, std::__1::char_traits<char> >::binary_oarchive_impl(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, unsigned int) in main.o
"boost::archive::basic_binary_oprimitive<boost::archive::binary_oarchive, char, std::__1::char_traits<char> >::~basic_binary_oprimitive()", referenced from:
boost::archive::binary_oarchive_impl<boost::archive::binary_oarchive, char, std::__1::char_traits<char> >::~binary_oarchive_impl() in main.o
boost::archive::binary_oarchive_impl<boost::archive::binary_oarchive, char, std::__1::char_traits<char> >::binary_oarchive_impl(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, unsigned int) in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Does anyone have any suggestions on how to fix this?
The reason is maybe you have compiler gcc5 or gcc6.
And your code has used different compile flag with your boost library.
Detail please read this link
If you can recompile all incompatible libs you use, do it with compiler option
-D_GLIBCXX_USE_CXX11_ABI=1
and then rebuild your project. If still can not link, add change project's makefile compiler option to 0.
-D_GLIBCXX_USE_CXX11_ABI=0
======Update=======
The real solution should be install the new boost libraries (v1.62) for gcc6 or gcc5.
Related
I would like to play a bit with the code of MAD-X (Methodical Accelerator Design; http://madx.web.cern.ch/madx/). I must admit that I am a complete newbie to c, c++, compiling, etc.
I downloaded the sources from the Mad-X git repository (https://github.com/MethodicalAcceleratorDesign/MAD-X) to my MacBook pro (2016, Intel) and in a first step I wanted to compile the code without modifications. To do so, I run
make madx-macosx64-gnu
which runs through the compilation process with some warnings, but the linking fails with numerous errors:
*** Compiling madx_ptc_track_run.f90
*** Compiling madx_ptc_trackcavs.f90
*** Compiling ptc_export_xml.f90
*** Compiling St_pointers.f90
*** Compiling madx_ptc_twiss.f90
*** Compiling user2_photon.f90
*** Compiling madx_ptc_normal.f90
*** Compiling wrap.f90
*** Linking build/madx-macosx64-gnu
Undefined symbols for architecture x86_64:
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::compare(unsigned long, unsigned long, char const*, unsigned long) const", referenced from:
SeqElList::sbend_from_rbend(element const*) in mad_mkthin.o
"std::__1::__vector_base_common<true>::__throw_length_error() const", referenced from:
void 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> > > >::__push_back_slow_path<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 mad_6track_name_mangler.o
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> > > >::vector(unsigned long) in mad_mkthin.o
void std::__1::vector<element*, std::__1::allocator<element*> >::__push_back_slow_path<element* const&>(element* const&) in mad_mkthin.o
void std::__1::vector<OneElementWithSlices*, std::__1::allocator<OneElementWithSlices*> >::__push_back_slow_path<OneElementWithSlices* const&>(OneElementWithSlices* const&) in mad_mkthin.o
void std::__1::vector<sequence*, std::__1::allocator<sequence*> >::__push_back_slow_path<sequence* const&>(sequence* const&) in mad_mkthin.o
"std::__1::__basic_string_common<true>::__throw_length_error() const", referenced from:
_NameMangler_mangle in mad_6track_name_mangler.o
_NameMangler_demangle in mad_6track_name_mangler.o
std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > std::__1::operator+<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&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in mad_6track_name_mangler.o
std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > std::__1::operator+<char, std::__1::char_traits<char>, std::__1::allocator<char> >(char, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in mad_6track_name_mangler.o
slice_sequence(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, sequence*) in mad_mkthin.o
ElementListWithSlices::find_slice(element const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in mad_mkthin.o
SeqElList::sbend_from_rbend(element const*) in mad_mkthin.o
...
"std::__1::locale::use_facet(std::__1::locale::id&) const", referenced from
[...]
can you give me advice how to compile this? E.g., there are a couple of Makefiles, one for MacOS, but I'm not sure how to use them properly.
Based on Ulrich Eckhardt's comments I ran "make -d --trace", which provides a lot of output, but unfortunately nothing more conclusive on "Undefined symbols..."
MANY LINES BEFORE
Pruning file 'Sl_family.o'.
Pruning file 'So_fitting.o'.
Pruning file 'm_real_polymorph.o'.
Pruning file 'k_tpsalie_analysis.o'.
Finished prerequisites of target file 'build/madx64'.
Must remake target 'build/madx64'.
make/linker.rules:28: update target 'build/madx64' due to: mad_elem.o mad_plot.o mad_write.o mad_dict.o mad_elemerr.o mad_str.o mad_survey.o mad_macro.o mad_option.o mad_emit.o mad_name.o mad_beam.o mad_match.o mad_cmdpar.o mad_sdds.o mad_const.o mad_array.o mad_node.o mad_cmdin.o mad_aper.o mad_vec.o mad_track.o mad_gvar.o mad_parse.o mad_ibs.o mad_time.o mad_cmd.o mad_table.o mad_twiss.o mad_main.o mad_6track.o mad_spch.o mad_ptcknobs.o mad_core.o mad_mem.o mad_sxf.o mad_util.o mad_eval.o mad_ptc.o mad_gcst.o mad_stream.o mad_exec.o mad_var.o mad_touschek.o mad_gxx11c.o mad_orbit.o mad_expr.o mad_regex.o mad_api.o mad_dynap.o mad_seq.o mad_inter.o mad_sodd.o mad_match2.o mad_select.o mad_rand.o mad_err.o mad_range.o mad_synrad.o mad_rplot.o mad_mkthin.o mad_6track_name_mangler.o touschek.o wrap.o trrun.o matchjc.o matchlib.o twiss.o madx_ptc_module.o dynap.o emit.o madx_ptc_track_run.o gxx11.o madx_ptc_script.o ibsdb.o madx_ptc_normal.o match.o orbf.o plot.o madx_ptc_trackcavs.o survey.o user2_photon.o madx_ptc_knobs.o matchlib2.o matchsa.o madx_ptc_twiss.o sodd.o madx_ptc_distrib.o util.o resindex.o madx_ptc_setcavs.o madx_ptc_eplacement.o ptc_export_xml.o madx_ptc_intstate.o mad_inif_f.o Sc_euclidean.o cc_dabnew.o b_da_arrays_all.o Spb_fake_gino_sub.o Se_status.o Sb_sagan_pol_arbitrary.o Si_def_element.o Sm_tracking.o Sd_frame.o Sf_def_all_kinds.o Sp_keywords.o Sr_spin.o cb_da_arrays_all.o Sq_orbit_ptc.o St_pointers.o Sg_sagan_wiggler.o d_lielib.o Sma0_beam_beam_ptc.o Sn_mad_like.o c_dabnew_berz.o h_definition.o Ci_tpsa.o Sh_def_kind.o a_scratch_size.o Sra_fitting.o j_tpsalie.o Sa_extend_poly.o Sma_multiparticle.o n_complex_polymorph.o Sk_link_list.o l_complex_taylor.o c_dabnew.o o_tree_element.o i_tpsa.o Sl_family.o So_fitting.o m_real_polymorph.o k_tpsalie_analysis.o
echo "*** Linking build/madx64"
Putting child 0x7f93f354ff60 (build/madx64) PID 34699 on the chain.
Live child 0x7f93f354ff60 (build/madx64) PID 34699
*** Linking build/madx64
Reaping winning child 0x7f93f354ff60 PID 34699
gfortran -m64 -O3 -fmax-stack-var-size=65536 -Wl,-no_compact_unwind -Wl,-no_pie -o build/madx64 build/Darwin64/mad_elem.o build/Darwin64/mad_plot.o build/Darwin64/mad_write.o build/Darwin64/mad_dict.o build/Darwin64/mad_elemerr.o build/Darwin64/mad_str.o build/Darwin64/mad_survey.o build/Darwin64/mad_macro.o build/Darwin64/mad_option.o build/Darwin64/mad_emit.o build/Darwin64/mad_name.o build/Darwin64/mad_beam.o build/Darwin64/mad_match.o build/Darwin64/mad_cmdpar.o build/Darwin64/mad_sdds.o build/Darwin64/mad_const.o build/Darwin64/mad_array.o build/Darwin64/mad_node.o build/Darwin64/mad_cmdin.o build/Darwin64/mad_aper.o build/Darwin64/mad_vec.o build/Darwin64/mad_track.o build/Darwin64/mad_gvar.o build/Darwin64/mad_parse.o build/Darwin64/mad_ibs.o build/Darwin64/mad_time.o build/Darwin64/mad_cmd.o build/Darwin64/mad_table.o build/Darwin64/mad_twiss.o build/Darwin64/mad_main.o build/Darwin64/mad_6track.o build/Darwin64/mad_spch.o build/Darwin64/mad_ptcknobs.o build/Darwin64/mad_core.o build/Darwin64/mad_mem.o build/Darwin64/mad_sxf.o build/Darwin64/mad_util.o build/Darwin64/mad_eval.o build/Darwin64/mad_ptc.o build/Darwin64/mad_gcst.o build/Darwin64/mad_stream.o build/Darwin64/mad_exec.o build/Darwin64/mad_var.o build/Darwin64/mad_touschek.o build/Darwin64/mad_gxx11c.o build/Darwin64/mad_orbit.o build/Darwin64/mad_expr.o build/Darwin64/mad_regex.o build/Darwin64/mad_api.o build/Darwin64/mad_dynap.o build/Darwin64/mad_seq.o build/Darwin64/mad_inter.o build/Darwin64/mad_sodd.o build/Darwin64/mad_match2.o build/Darwin64/mad_select.o build/Darwin64/mad_rand.o build/Darwin64/mad_err.o build/Darwin64/mad_range.o build/Darwin64/mad_synrad.o build/Darwin64/mad_rplot.o build/Darwin64/mad_mkthin.o build/Darwin64/mad_6track_name_mangler.o build/Darwin64/touschek.o build/Darwin64/wrap.o build/Darwin64/trrun.o build/Darwin64/matchjc.o build/Darwin64/matchlib.o build/Darwin64/twiss.o build/Darwin64/madx_ptc_module.o build/Darwin64/dynap.o build/Darwin64/emit.o build/Darwin64/madx_ptc_track_run.o build/Darwin64/gxx11.o build/Darwin64/madx_ptc_script.o build/Darwin64/ibsdb.o build/Darwin64/madx_ptc_normal.o build/Darwin64/match.o build/Darwin64/orbf.o build/Darwin64/plot.o build/Darwin64/madx_ptc_trackcavs.o build/Darwin64/survey.o build/Darwin64/user2_photon.o build/Darwin64/madx_ptc_knobs.o build/Darwin64/matchlib2.o build/Darwin64/matchsa.o build/Darwin64/madx_ptc_twiss.o build/Darwin64/sodd.o build/Darwin64/madx_ptc_distrib.o build/Darwin64/util.o build/Darwin64/resindex.o build/Darwin64/madx_ptc_setcavs.o build/Darwin64/madx_ptc_eplacement.o build/Darwin64/ptc_export_xml.o build/Darwin64/madx_ptc_intstate.o build/Darwin64/mad_inif_f.o build/Darwin64/Sc_euclidean.o build/Darwin64/cc_dabnew.o build/Darwin64/b_da_arrays_all.o build/Darwin64/Spb_fake_gino_sub.o build/Darwin64/Se_status.o build/Darwin64/Sb_sagan_pol_arbitrary.o build/Darwin64/Si_def_element.o build/Darwin64/Sm_tracking.o build/Darwin64/Sd_frame.o build/Darwin64/Sf_def_all_kinds.o build/Darwin64/Sp_keywords.o build/Darwin64/Sr_spin.o build/Darwin64/cb_da_arrays_all.o build/Darwin64/Sq_orbit_ptc.o build/Darwin64/St_pointers.o build/Darwin64/Sg_sagan_wiggler.o build/Darwin64/d_lielib.o build/Darwin64/Sma0_beam_beam_ptc.o build/Darwin64/Sn_mad_like.o build/Darwin64/c_dabnew_berz.o build/Darwin64/h_definition.o build/Darwin64/Ci_tpsa.o build/Darwin64/Sh_def_kind.o build/Darwin64/a_scratch_size.o build/Darwin64/Sra_fitting.o build/Darwin64/j_tpsalie.o build/Darwin64/Sa_extend_poly.o build/Darwin64/Sma_multiparticle.o build/Darwin64/n_complex_polymorph.o build/Darwin64/Sk_link_list.o build/Darwin64/l_complex_taylor.o build/Darwin64/c_dabnew.o build/Darwin64/o_tree_element.o build/Darwin64/i_tpsa.o build/Darwin64/Sl_family.o build/Darwin64/So_fitting.o build/Darwin64/m_real_polymorph.o build/Darwin64/k_tpsalie_analysis.o -L/usr/X11/lib -lX11 -lstdc++ -lm
Live child 0x7f93f354ff60 (build/madx64) PID 34700
Undefined symbols for architecture x86_64:
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::compare(unsigned long, unsigned long, char const*, unsigned long) const", referenced from:
SeqElList::sbend_from_rbend(element const*) in mad_mkthin.o
"std::__1::__vector_base_common<true>::__throw_length_error() 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> > > >::vector(unsigned long) in mad_mkthin.o
void std::__1::vector<element*, std::__1::allocator<element*> >::__push_back_slow_path<element* const&>(element* const&) in mad_mkthin.o
void std::__1::vector<OneElementWithSlices*, std::__1::allocator<OneElementWithSlices*> >::__push_back_slow_path<OneElementWithSlices* const&>(OneElementWithSlices* const&) in mad_mkthin.o
void std::__1::vector<sequence*, std::__1::allocator<sequence*> >::__push_back_slow_path<sequence* const&>(sequence* const&) in mad_mkthin.o
void 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> > > >::__push_back_slow_path<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 mad_6track_name_mangler.o
"std::__1::__basic_string_common<true>::__throw_length_error() const", referenced from:
slice_sequence(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, sequence*) in mad_mkthin.o
ElementListWithSlices::find_slice(element const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in mad_mkthin.o
SeqElList::sbend_from_rbend(element const*) in mad_mkthin.o
my_dump_command(command const*) in mad_mkthin.o
SeqElList::create_thick_slice(element*, int) in mad_mkthin.o
SeqElList::slice_this_node() in mad_mkthin.o
create_bend_dipedge_element(element*, bool) in mad_mkthin.o
[...]
Thanks to David Hammen's comments and the link therein:
Link OSX Homebrew Gfortran against libc++
I was able to resolve this:
I searched for all occurrences of "-lstdc++" in the files and found hits in the following files:
linker.g95 (no need to edit this...)
linker.gfortran: change line 44 from
LDLIBS += $(if $(call eq,$(OSTYPE),Darwin),-lgfortran -lstdc++ -lgcc
-lgcc_eh -lSystem -nodefaultlibs,)
to
LDLIBS += $(if $(call eq,$(OSTYPE),Darwin),-lgfortran -lc++ -lgcc
-lgcc_eh -lSystem -nodefaultlibs,)
Makefile_lib: change lines 57 and 62 (in the if-clause checking for Darwin = MACOS) and replace -lstdc++ with -lc++ too
Works like a fly :)
first,I installed google protobuf-3.3 (protobuf-cpp-3.3.0.tar.gz), use xcode to create a crossplatform game project, the target is ios, add libprotobuf-lite.tbd and libprotobuf.tbd, then create a test.proto file like this:
syntax = "proto3";
message Person {
string name = 1;
}
use protoc to compile it to cpp file: test.pb.h,test.pb.cc
when run the project, I got 13 errors:
Undefined symbols for architecture arm64:
"google::protobuf::Message::SpaceUsedLong() const", referenced from:
vtable for Person in test.pb.o
"google::protobuf::internal::WireFormatLite::VerifyUtf8String(char const*, int, google::protobuf::internal::WireFormatLite::Operation, char const*)", referenced from:
Person::MergePartialFromCodedStream(google::protobuf::io::CodedInputStream*) in test.pb.o
Person::SerializeWithCachedSizes(google::protobuf::io::CodedOutputStream*) const in test.pb.o
Person::InternalSerializeWithCachedSizesToArray(bool, unsigned char*) const in test.pb.o
"google::protobuf::UnknownFieldSet::default_instance()", referenced from:
google::protobuf::internal::InternalMetadataWithArena::default_instance() in test.pb.o
"google::protobuf::io::CodedInputStream::ReadTagFallback(unsigned int)", referenced from:
Person::MergePartialFromCodedStream(google::protobuf::io::CodedInputStream*) in test.pb.o
"google::protobuf::internal::RegisterAllTypes(google::protobuf::Metadata const*, int)", referenced from:
protobuf_test_2eproto::(anonymous namespace)::protobuf_RegisterTypes(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in test.pb.o
...
...
...
I'm trying to compile the Litecoin source (https://github.com/litecoin-project/litecoin.git). Doing this in windows with VmWare OSX 10.9.1(64bit).
I cloned it and in terminal ran:
make -f makefile.osx USE_UPNP=-
It spits out this error:
Undefined symbols for architecture x86_64:
"boost::program_options::to_internal(std::string const&)", referenced from:
boost::program_options::detail::basic_config_file_iterator<char>::getline(std::string&) in util.o
"boost::program_options::detail::common_config_file_iterator::common_config_file_iterator(std::set<std::string, std::less<std::string>, std::allocator<std::string> > const&, bool)", referenced from:
boost::program_options::detail::basic_config_file_iterator<char>::basic_config_file_iterator(std::istream&, std::set<std::string, std::less<std::string>, std::allocator<std::string> > const&, bool) in util.o
"Db::verify(char const*, char const*, std::ostream*, unsigned int)", referenced from:
CDBEnv::Verify(std::string, bool (*)(CDBEnv&, std::string)) in db.o
CDBEnv::Salvage(std::string, bool, std::vector<std::pair<std::vector<unsigned char, std::allocator<unsigned char> >, std::vector<unsigned char, std::allocator<unsigned char> > >, std::allocator<std::pair<std::vector<unsigned char, std::allocator<unsigned char> >, std::vector<unsigned char, std::allocator<unsigned char> > > > >&) in db.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: *** [litecoind] Error 1
I've been googling like crazy but can't seem to find a proper solution.
I'm testing Boost.Python and have run into some issues.
I managed to complete the "Hello World" example without a glitch (http://www.boost.org/doc/libs/1_54_0/libs/python/doc/tutorial/doc/html/index.html) - everything compiled and I was able to use the .so properly in Python.
However, as soon as I introduced classes into my test file (http://www.boost.org/doc/libs/1_54_0/libs/python/doc/tutorial/doc/html/python/exposing.html), the compiler started screaming
Undefined symbols for architecture x86_64:
"boost::python::objects::function_object(boost::python::objects::py_function const&, std::__1::pair<boost::python::detail::keyword const*, boost::python::detail::keyword const*> const&)", referenced from:
boost::python::api::object boost::python::detail::make_function_aux<void (World::*)(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >), boost::python::default_call_policies, boost::mpl::vector3<void, World&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, mpl_::int_<0> >(void (World::*)(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >), boost::python::default_call_policies const&, boost::mpl::vector3<void, World&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > const&, std::__1::pair<boost::python::detail::keyword const*, boost::python::detail::keyword const*> const&, mpl_::int_<0>) in SHLibPy.o
boost::python::api::object boost::python::detail::make_function_aux<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > (World::*)(), boost::python::default_call_policies, boost::mpl::vector2<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, World&>, mpl_::int_<0> >(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > (World::*)(), boost::python::default_call_policies const&, boost::mpl::vector2<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, World&> const&, std::__1::pair<boost::python::detail::keyword const*, boost::python::detail::keyword const*> const&, mpl_::int_<0>) in SHLibPy.o
boost::python::api::object boost::python::detail::make_function_aux<void (*)(_object*), boost::python::default_call_policies, boost::mpl::vector2<void, _object*>, mpl_::int_<0> >(void (*)(_object*), boost::python::default_call_policies const&, boost::mpl::vector2<void, _object*> const&, std::__1::pair<boost::python::detail::keyword const*, boost::python::detail::keyword const*> const&, mpl_::int_<0>) in SHLibPy.o
"boost::python::objects::register_dynamic_id_aux(boost::python::type_info, std::__1::pair<void*, boost::python::type_info> (*)(void*))", referenced from:
void boost::python::objects::register_dynamic_id<World>(World*) in SHLibPy.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
It seems to suggest that the lib files are not linked, but I've included them in XCode
Am I missing something? Thanks very much!
I found out why. Turns out that I'm using the standard library with C++11 support. To fix the issue, I rebuilt boost using brew as follows
brew -v install --with-icu --build-from-source --with-c++11 boost
I am doing a pet project and am using clang++ (specifically MacPorts clang 3.1). So I decided to switch over to libc++ (to use std::array and such) but I was using boost (specifically asio and regex), so I had to recompile boost using libc++. I removed boost which was installed in macports and build boost from source and now is installed in /usr/local/include and /usr/local/lib. Ever since then, I cannot compile. Here are the oddities I am encountering:
When executing:
clang++ -g -std=c++11 -stdlib=libc++ -c main.cpp
I get a weird compile error having to do with the move constructor (there's more to this error, but as you can see it is coming from boost):
/usr/include/c++/v1/string:1952:10: error: overload resolution selected implicitly-deleted copy assignment operator
__r_ = _STD::move(__str.__r_);
^
/usr/include/c++/v1/string:1942:9: note: in instantiation of member function 'std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__move_assign' requested here
__move_assign(__str, true_type());
^
/usr/include/c++/v1/string:1961:5: note: in instantiation of member function 'std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__move_assign' requested here
__move_assign(__str, integral_constant<bool,
^
/usr/local/include/boost/regex/v4/perl_matcher.hpp:207:16: note: in instantiation of member function 'std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::operator=' requested here
s1 = traits_inst.transform(a, a + 1);
However, when I execute (please note the "-I", and it must be in that exact position):
clang++ -I -std=c++11 -stdlib=libc++ -g -c main.cpp
This compiles (but linking fails later on). Why is this? What does -I do without a path? Must -stdlib= be preceded with -I?
Now the fun part:
Even though, everything compiles now, it won't link. When executing:
clang++ main.o FTPClient.o FTPConnection.o -lboost_system -lboost_regex -std=c++11 -stdlib=libc++ -g -o cli
I get the message:
Undefined symbols for architecture x86_64:
"__ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initIPKcEENS_9enable_ifIXsr21__is_forward_iteratorIT_EE5valueEvE4typeESA_SA_", referenced from:
boost::re_detail::cpp_regex_traits_implementation<char>::lookup_collatename(char const*, char const*) const in libboost_regex.a(instances.o)
boost::re_detail::cpp_regex_traits_implementation<char>::lookup_classname_imp(char const*, char const*) const in libboost_regex.a(instances.o)
boost::re_detail::basic_regex_parser<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::fail(boost::regex_constants::error_type, long, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, long) in libboost_regex.a(instances.o)
boost::re_detail::cpp_regex_traits_implementation<char>::lookup_classname(char const*, char const*) const in libboost_regex.a(instances.o)
ld: symbol(s) not found for architecture x86_64
Now I am thinking maybe I a missing some -lboost flag but I am not sure what it is. What could be the reason for this?
Thanks very much!
EDIT: When looking through the logs of installing boost, I noticed this:
..failed clang-darwin.link.dll /usr/local/lib/libboost_filesystem.dylib...
clang-darwin.link.dll /usr/local/lib/libboost_regex.dylib
Undefined symbols for architecture x86_64:
"__ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initIPKcEENS_9enable_ifIXsr21__is_forward_iteratorIT_EE5valueEvE4typeESA_SA_", referenced from:
boost::c_regex_traits<char>::transform(char const*, char const*) in c_regex_traits.o
boost::c_regex_traits<char>::lookup_classname(char const*, char const*) in c_regex_traits.o
boost::c_regex_traits<char>::lookup_collatename(char const*, char const*) in c_regex_traits.o
boost::re_detail::RegExData::update() in cregex.o
boost::RegEx::What(int) const in cregex.o
boost::re_detail::pred2::operator()(boost::match_results<char const*, std::__1::allocator<boost::sub_match<char const*> > > const&) in cregex.o
boost::re_detail::cpp_regex_traits_implementation<char>::lookup_collatename(char const*, char const*) const in instances.o
...
"__ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6__initIPKwEENS_9enable_ifIXsr21__is_forward_iteratorIT_EE5valueEvE4typeESA_SA_", referenced from:
boost::c_regex_traits<wchar_t>::transform(wchar_t const*, wchar_t const*) in wc_regex_traits.o
boost::c_regex_traits<wchar_t>::lookup_classname(wchar_t const*, wchar_t const*) in wc_regex_traits.o
boost::re_detail::cpp_regex_traits_implementation<wchar_t>::lookup_collatename(wchar_t const*, wchar_t const*) const in winstances.o
boost::re_detail::cpp_regex_traits_implementation<wchar_t>::lookup_classname_imp(wchar_t const*, wchar_t const*) const in winstances.o
boost::re_detail::cpp_regex_traits_implementation<wchar_t>::lookup_classname(wchar_t const*, wchar_t const*) const in winstances.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Does this mean boost regex maybe incompatible with -libc++?
EDIT 2: I tried using std::regex, but I get this:
Undefined symbols for architecture x86_64:
"__ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initIPKcEENS_9enable_ifIXsr21__is_forward_iteratorIT_EE5valueEvE4typeESA_SA_", referenced from:
std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > std::__1::regex_traits<char>::__lookup_collatename<char const*>(char const*, char const*, char) const in main.o
unsigned int std::__1::regex_traits<char>::__lookup_classname<char const*>(char const*, char const*, bool, char) const in main.o
ld: symbol(s) not found for architecture x86_64
A helpful, but unsatisfactory answer: libc++ contains std::regex, which you can use instead of boost::regex.