RethinkDB startup error - rethinkdb

After I fixed some weird HD problems at my server I noticed that all the rethinkdb data had been lost, that wasn't a problem because the data wasn't important, but now when I start the rethinkdb service using sudo /etc/init.d/rethinkdb restart it runs into this error:
2017-06-19T00:58:21.734419185 0.174516s notice: Running rethinkdb 2.3.5~0xenial (GCC 5.3.1)...
2017-06-19T00:58:21.783052748 0.223140s notice: Running on Linux 4.4.0-79-generic i686
2017-06-19T00:58:21.783317738 0.223398s notice: Loading data from directory /var/lib/rethinkdb/instance1/data
2017-06-19T00:58:22.008209401 0.448290s info: Automatically using cache size of 100 MB
2017-06-19T00:58:22.009815969 0.449896s warn: Cache size does not leave much memory for server and query overhead (available memory: 877 MB).
2017-06-19T00:58:22.010366140 0.450446s warn: Cache size is very low and may impact performance.
2017-06-19T00:58:22.042696622 0.482776s notice: Listening for intracluster connections on port 29015
2017-06-19T00:58:22.128827940 0.568909s error: Error in src/btree/reql_specific.cc at line 256:
2017-06-19T00:58:22.129000921 0.569083s error: Unrecognized reql_btree_superblock_t::magic found.
2017-06-19T00:58:22.129123530 0.569204s error: Backtrace:
2017-06-19T00:58:22.703288073 1.143377s error: Mon Jun 19 00:58:22 2017\n\n1 [0x8747198]: backtrace_t::backtrace_t() at ??:?\n2 [0x8747678]: format_backtrace[abi:cxx11](bool) at ??:?\n3 [0x8a208f4]: report_fatal_error(char const*, int, char const*, ...) at ??:?\n4 [0x86deb12]: get_superblock_metainfo(real_superblock_t*, std::vector<std::pair<std::vector<char, std::allocator<char> >, std::vector<char, std::allocator<char> > >, std::allocator<std::pair<std::vector<char, std::allocator<char> >, std::vector<char, std::allocator<char> > > > >*, cluster_version_t*) at ??:?\n5 [0x85df957]: store_metainfo_manager_t::store_metainfo_manager_t(real_superblock_t*) at ??:?\n6 [0x846edc9]: store_t::store_t(hash_region_t<key_range_t> const&, serializer_t*, cache_balancer_t*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, perfmon_collection_t*, rdb_context_t*, io_backender_t*, base_path_t const&, uuid_u, update_sindexes_t) at ??:?\n7 [0x894745b]: real_multistore_ptr_t::real_multistore_ptr_t(uuid_u const&, serializer_filepath_t const&, scoped_ptr_t<real_branch_history_manager_t>&&, base_path_t const&, io_backender_t*, cache_balancer_t*, rdb_context_t*, perfmon_collection_t*, scoped_ptr_t<thread_allocation_t>&&, std::vector<scoped_ptr_t<thread_allocation_t>, std::allocator<scoped_ptr_t<thread_allocation_t> > >&&, std::map<uuid_u, std::pair<real_multistore_ptr_t*, auto_drainer_t::lock_t>, std::less<uuid_u>, std::allocator<std::pair<uuid_u const, std::pair<real_multistore_ptr_t*, auto_drainer_t::lock_t> > > >*)::{lambda(int)#1}::operator()(int) const at ??:?\n8 [0x89487d4]: callable_action_instance_t<pmap_runner_one_arg_t<real_multistore_ptr_t::real_multistore_ptr_t(uuid_u const&, serializer_filepath_t const&, scoped_ptr_t<real_branch_history_manager_t>&&, base_path_t const&, io_backender_t*, cache_balancer_t*, rdb_context_t*, perfmon_collection_t*, scoped_ptr_t<thread_allocation_t>&&, std::vector<scoped_ptr_t<thread_allocation_t>, std::allocator<scoped_ptr_t<thread_allocation_t> > >&&, std::map<uuid_u, std::pair<real_multistore_ptr_t*, auto_drainer_t::lock_t>, std::less<uuid_u>, std::allocator<std::pair<uuid_u const, std::pair<real_multistore_ptr_t*, auto_drainer_t::lock_t> > > >*)::{lambda(int)#1}, long long> >::run_action() at ??:?\n9 [0x864f4bd]: coro_t::run() at ??:?
2017-06-19T00:58:22.703737641 1.143820s error: Exiting.
Also, it works if I start it using the normal command (rethinkdb --bind all), the error only happens with the proccess.

Related

Thread safety of boost::regex_match

ThreadSanitizer gives me an alleged race condition in boost::regex_match. Is this a false positive? I cannot find synchronization primitives that depend on BOOST_HAS_THREADS in the callstacks. All input parameters are on the stack of the respective thread and not shared.
==================
WARNING: ThreadSanitizer: data race (pid=1893)
Write of size 4 at 0x007e19fa8ff0 by thread T36:
#0 boost::re_detail_106700::saved_state::saved_state(unsigned int) include/boost/regex/v4/perl_matcher_non_recursive.hpp:59
#1 boost::re_detail_106700::perl_matcher<char const*, std::allocator<boost::sub_match<char const*> >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::push_recursion_stopper() include/boost/regex/v4/perl_matcher_non_recursive.hpp:288
#2 boost::re_detail_106700::perl_matcher<char const*, std::allocator<boost::sub_match<char const*> >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::match_all_states() include/boost/regex/v4/perl_matcher_non_recursive.hpp:202
#3 boost::re_detail_106700::perl_matcher<char const*, std::allocator<boost::sub_match<char const*> >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::match_prefix() include/boost/regex/v4/perl_matcher_common.hpp:336
#4 boost::re_detail_106700::perl_matcher<char const*, std::allocator<boost::sub_match<char const*> >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::match_imp() include/boost/regex/v4/perl_matcher_common.hpp:220
#5 boost::re_detail_106700::perl_matcher<char const*, std::allocator<boost::sub_match<char const*> >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::match() include/boost/regex/v4/perl_matcher_common.hpp:193
#6 bool boost::regex_match<char const*, std::allocator<boost::sub_match<char const*> >, char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >(char const*, char const*, boost::match_results<char const*, std::allocator<boost::sub_match<char const*> > >&, boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, boost::regex_constants::_match_flags) include/boost/regex/v4/regex_match.hpp:50
#7 bool boost::regex_match<char, std::allocator<boost::sub_match<char const*> >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >(char const*, boost::match_results<char const*, std::allocator<boost::sub_match<char const*> > >&, boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, boost::regex_constants::_match_flags) /var/lib/jenkins/workspace/nightly-jnd-navigation__tsd-nav-rsi-viwi-dev/system/ext-boost-dev/dist/17-89ad-bc06/usr/include/boost/regex/v4/regex_match.hpp:73 (tsd.nav.mainapp.mib3+0x3dd0610)
<...>
Previous write of size 4 at 0x007e19fa8ff0 by thread T105:
[failed to restore the stack]
Location is heap block of size 4096 at 0x007e19fa8000 allocated by thread T105:
#0 operator new(unsigned long) <null> (libtsan.so.0+0x79f54)
#1 boost::re_detail_106700::save_state_init::save_state_init(boost::re_detail_106700::saved_state**, boost::re_detail_106700::saved_state**) include/boost/regex/v4/perl_matcher_non_recursive.hpp:107
#2 boost::re_detail_106700::perl_matcher<char const*, std::allocator<boost::sub_match<char const*> >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::match_imp() include/boost/regex/v4/perl_matcher_common.hpp:202
#3 boost::re_detail_106700::perl_matcher<char const*, std::allocator<boost::sub_match<char const*> >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::match() include/boost/regex/v4/perl_matcher_common.hpp:193
#4 bool boost::regex_match<char const*, std::allocator<boost::sub_match<char const*> >, char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >(char const*, char const*, boost::match_results<char const*, std::allocator<boost::sub_match<char const*> > >&, boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, boost::regex_constants::_match_flags) include/boost/regex/v4/regex_match.hpp:50
#5 bool boost::regex_match<char, std::allocator<boost::sub_match<char const*> >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >(char const*, boost::match_results<char const*, std::allocator<boost::sub_match<char const*> > >&, boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, boost::regex_constants::_match_flags) include/boost/regex/v4/regex_match.hpp:73
<...>
Regards
I think the documentation is pretty definitive:
Thread Safety
The Boost.Regex library is thread safe when Boost is: you can verify
that Boost is in thread safe mode by checking to see if
BOOST_HAS_THREADS is defined: this macro is set automatically by the
config system when threading support is turned on in your compiler.
Class basic_regex and its typedefs regex and wregex are thread safe,
in that compiled regular expressions can safely be shared between
threads. The matching algorithms regex_match, regex_search, and
regex_replace are all re-entrant and thread safe. Class match_results
is now thread safe, in that the results of a match can be safely
copied from one thread to another (for example one thread may find
matches and push match_results instances onto a queue, while another
thread pops them off the other end), otherwise use a separate instance
of match_results per thread.
The POSIX API functions are all re-entrant and thread safe, regular
expressions compiled with regcomp can also be shared between threads.
The class RegEx is only thread safe if each thread gets its own RegEx
instance (apartment threading) - this is a consequence of RegEx
handling both compiling and matching regular expressions.
Finally note that changing the global locale invalidates all compiled
regular expressions, therefore calling set_locale from one thread
while another uses regular expressions will produce unpredictable
results.
There is also a requirement that there is only one thread executing
prior to the start of main().
So, you need to make sure:
you are not sharing the match_results object (your description doesn't say, because that's not an input argument depending on your definition)
the regex is pre-compiled:
[are] thread safe,
in that compiled regular expressions can safely be shared between
threads

undefined reference to `(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)' when using tensorflow_cc.so

I am working on linking Tensorflow2 shared libraries (*.so) files into my C++ program. The libtensorflow_cc and libtensorflow_framework.so use bazel-3.7.2 and gcc7.3 and is linked to another library I have ‘libmyproj.so’. I want to link this libmyproj.so to my main program which are built with the same gcc7.3. I have tried using the -D_GLIBCXX_USE_CXX11_ABI=0 flag for ABI compatibility (from https://www.tensorflow.org/install/source and Converting std::__cxx11::string to std::string) but without any success. I am stuck at the following error:
undefined reference to ml_model::ml_model(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)' undefined reference to ml_model::preprocess_data(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<float, std::allocator<float> >, int&, int&, std::vector<int, std::allocator<int> >&)' undefined reference to ml_model::get_predictions(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > int, std::vector<int, std::allocator<int> >)'
in function std::__cxx11::basic_string<char, std::char_traits,
std::allocator >* tensorflow::internal::MakeCheckOpString<long,
int>(long const&, int const&, char const*)': undefined reference to tensorflow::internal::CheckOpMessageBuilder::NewString[abi:cxx11]()'
Any suggestions on why this is happening?
Check if the libstdc++ version is correct。 Your problem may be the tensorflow_cc.so compiler with higher libstdc++ version, but your build env libstdc++ is lower, so some symbols will not be found.
Get libstdc++ version:
bash$ /sbin/ldconfig -p | grep stdc++
libstdc++.so.6 (libc6,x86_64) => /lib/x86_64-linux-gnu/libstdc++.so.6
bash$ ls -l /lib/x86_64-linux-gnu/libstdc++.so.6
lrwxrwxrwx 1 root root 19 Jan 10 2021 /lib/x86_64-linux-gnu/libstdc++.so.6 -> libstdc++.so.6.0.28
The symlink points to a versioned file, in this case 6.0.28.
Update libstdc++; how to do this exactly depends on your distro, but instructions should not be hard to find in Google.

get "libcephfs.so:undefined reference to 'blablabla' " error during compiler. How to do solve this problem?

I have a cephfs and i'm writing a client code in c language using libcephfs.h library for it.
Note: installed libcephfs-dev and libcephfs2, but did not work on any version(12.2.12 or 12.2.4) I am using ubuntu 18.04.3.
#include "/usr/include/cephfs/libcephfs.h"
#include <stdlib.h>
#include <stdio.h>
int main (int argc, const char* argv[]){
struct ceph_mount_info *cmount;
const char id[] = "client.admin";
int err = ceph_create(&cmount, id);
printf("%d", err);
return 0;
}
$ g++ -o example example.c -lcephfs
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libcephfs.so: undefined reference to `AdminSocket::unregister_command(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libcephfs.so: undefined reference to `ceph_clock_now()'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libcephfs.so: undefined reference to `AdminSocket::register_command(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, AdminSocketHook*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libcephfs.so: undefined reference to `PerfCountersBuilder::add_u64_counter(int, char const*, char const*, char const*, int)'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libcephfs.so: undefined reference to `md_config_t::set_val(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const*, bool, std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >*)'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libcephfs.so: undefined reference to `CrushWrapper::get_full_location_ordered(int, std::vector<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >&)'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libcephfs.so: undefined reference to `PerfCounters::tinc(int, utime_t, unsigned int)'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libcephfs.so: undefined reference to `md_config_t::parse_env()'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libcephfs.so: undefined reference to `md_config_t::parse_argv(std::vector<char const*, std::allocator<char const*> >&)'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libcephfs.so: undefined reference to `ceph::Formatter::create(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libcephfs.so: undefined reference to `PerfCounters::tinc(int, std::chrono::duration<unsigned long, std::ratio<1l, 1000000000l> >, unsigned int)'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libcephfs.so: undefined reference to `FSMap::parse_role(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, mds_role_t*, std::ostream&) const'
collect2: error: ld returned 1 exit status
#define _LARGEFILE_SOURCE
#define _LARGEFILE64_SOURCE
#define _FILE_OFFSET_BITS 64
#include <cephfs/libcephfs.h>
#include <stdlib.h>
#include <stdio.h>
int main (int argc, const char* argv[]){
struct ceph_mount_info *cmount;
const char id[] = "client.admin";
int err = ceph_create(&cmount, id);
printf("%d", err);
return 0;
}
This code compiles for me on Ubuntu 18.04 with the GCC 7 compiler.
The command I used to compile is :
g++ -o example example.c -lcephfs
In fact, even your source compiles on my system with the added #defines that I have used.
It worked ! Before upgrading my ubuntu version(from 16.04 to 18.04), i have installed librados. Now, i reinstall librados and libcephfs. It worked successfully.

Link errors on MacOS High Sierra: "Undefined symbols for architecture x86_64" std::__1

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 :)

Boost.Python - undefined symbols error even though the lib files are linked

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

Resources