jturney / ambit

C++ library for the implementation of tensor product calculations through a clean, concise user interface.
GNU Lesser General Public License v3.0
21 stars 9 forks source link

python module and boost >=1.60 #16

Closed loriab closed 8 years ago

loriab commented 8 years ago

Boost 1.56 and 1.59 seem fine, but when I build the python module agains 1.60 or 1.61, get error:

[100%] Linking CXX shared library pyambit.so
cd /Users/loriab/anaconda/conda-bld/work/build/src/python && /Users/loriab/anaconda/envs/_build/bin/cmake -E cmake_link_script CMakeFiles/pyambit.dir/link.txt --verbose=1
/Users/loriab/anaconda/envs/_build/bin/g++  -DRESTRICT=__restrict__ -Xlinker -dynamic -fPIC -std=c++11 -fopenmp -O3 -DNDEBUG -Wno-unused -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -mmacosx-version-min=10.6 -dynamiclib -Wl,-headerpad_max_install_names   -arch x86_64 -o pyambit.so -install_name @rpath/pyambit.so CMakeFiles/pyambit.dir/bindings.cc.o /Users/loriab/anaconda/envs/_build/lib/libpython2.7.dylib ../libambit.dylib /usr/lib/liblapack.dylib /usr/lib/libblas.dylib /Users/loriab/anaconda/envs/_build/lib/libboost_filesystem.dylib /Users/loriab/anaconda/envs/_build/lib/libboost_system.dylib /Users/loriab/anaconda/envs/_build/lib/libboost_python.dylib /Users/loriab/anaconda/envs/_build/lib/libpython2.7.dylib /usr/lib/liblapack.dylib /usr/lib/libblas.dylib /Users/loriab/anaconda/envs/_build/lib/libboost_filesystem.dylib /Users/loriab/anaconda/envs/_build/lib/libboost_system.dylib /Users/loriab/anaconda/envs/_build/lib/libboost_python.dylib -L/Users/loriab/anaconda/envs/_build/lib -lhdf5 -lhdf5_hl -lhdf5 -lhdf5_hl -lpthread -lz -ldl -lm /Users/loriab/anaconda/envs/_build/lib/libhdf5.dylib /Users/loriab/anaconda/envs/_build/lib/libz.dylib /usr/lib/libdl.dylib /usr/lib/libm.dylib -Wl,-rpath,/Users/loriab/anaconda/conda-bld/work/build/src 
Undefined symbols for architecture x86_64:
  "boost::python::objects::function_object(boost::python::objects::py_function const&, std::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 (*)(_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::pair<boost::python::detail::keyword const*, boost::python::detail::keyword const*> const&, mpl_::int_<0>) [clone .isra.1771] in bindings.cc.o
      void boost::python::detail::name_space_def<void (*)(ambit::Tensor&, __sFILE*, bool, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&), boost::python::default_call_policies, boost::python::class_<ambit::Tensor, boost::python::detail::not_specified, boost::python::detail::not_specified, boost::python::detail::not_specified> >(boost::python::class_<ambit::Tensor, boost::python::detail::not_specified, boost::python::detail::not_specified, boost::python::detail::not_specified>&, char const*, void (*)(ambit::Tensor&, __sFILE*, bool, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&), std::pair<boost::python::detail::keyword const*, boost::python::detail::keyword const*> const&, boost::python::default_call_policies const&, char const*, boost::python::objects::class_base*) [clone .isra.1672] [clone .constprop.3017] in bindings.cc.o
      init_module_pyambit()     in bindings.cc.o
      boost::python::class_<ambit::Tensor, boost::python::detail::not_specified, boost::python::detail::not_specified, boost::python::detail::not_specified>& boost::python::class_<ambit::Tensor, boost::python::detail::not_specified, boost::python::detail::not_specified, boost::python::detail::not_specified>::def<std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, ambit::Tensor, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, ambit::Tensor> > > (ambit::Tensor::*)(ambit::EigenvalueOrder) const>(char const*, std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, ambit::Tensor, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, ambit::Tensor> > > (ambit::Tensor::*)(ambit::EigenvalueOrder) const) in bindings.cc.o
      boost::python::class_<ambit::Tensor, boost::python::detail::not_specified, boost::python::detail::not_specified, boost::python::detail::not_specified>& boost::python::class_<ambit::Tensor, boost::python::detail::not_specified, boost::python::detail::not_specified, boost::python::detail::not_specified>::def<void (ambit::Tensor::*)()>(char const*, void (ambit::Tensor::*)()) in bindings.cc.o
      boost::python::class_<ambit::Tensor, boost::python::detail::not_specified, boost::python::detail::not_specified, boost::python::detail::not_specified>& boost::python::class_<ambit::Tensor, boost::python::detail::not_specified, boost::python::detail::not_specified, boost::python::detail::not_specified>::def<std::tuple<double, std::vector<unsigned long, std::allocator<unsigned long> > > (ambit::Tensor::*)() const>(char const*, std::tuple<double, std::vector<unsigned long, std::allocator<unsigned long> > > (ambit::Tensor::*)() const) in bindings.cc.o
      void boost::python::indexing_suite<std::vector<ambit::Tensor, std::allocator<ambit::Tensor> >, boost::python::detail::final_vector_derived_policies<std::vector<ambit::Tensor, std::allocator<ambit::Tensor> >, false>, false, false, ambit::Tensor, unsigned long, ambit::Tensor>::visit<boost::python::class_<std::vector<ambit::Tensor, std::allocator<ambit::Tensor> >, boost::python::detail::not_specified, boost::python::detail::not_specified, boost::python::detail::not_specified> >(boost::python::class_<std::vector<ambit::Tensor, std::allocator<ambit::Tensor> >, boost::python::detail::not_specified, boost::python::detail::not_specified, boost::python::detail::not_specified>&) const in bindings.cc.o
      ...
  "boost::python::objects::register_dynamic_id_aux(boost::python::type_info, std::pair<void*, boost::python::type_info> (*)(void*))", referenced from:
      init_module_pyambit()     in bindings.cc.o
      boost::python::class_<std::vector<ambit::Tensor, std::allocator<ambit::Tensor> >, boost::python::detail::not_specified, boost::python::detail::not_specified, boost::python::detail::not_specified>::class_(char const*, char const*) in bindings.cc.o
      boost::python::class_<std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, ambit::Tensor, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, ambit::Tensor> > >, boost::python::detail::not_specified, boost::python::detail::not_specified, boost::python::detail::not_specified>::class_(char const*, char const*) in bindings.cc.o
      boost::python::class_<std::vector<unsigned long, std::allocator<unsigned long> >, boost::python::detail::not_specified, boost::python::detail::not_specified, boost::python::detail::not_specified>::class_(char const*, char const*) in bindings.cc.o
      boost::python::class_<std::pair<unsigned long, unsigned long>, boost::python::detail::not_specified, boost::python::detail::not_specified, boost::python::detail::not_specified>::class_(char const*, char const*) in bindings.cc.o
      boost::python::class_<std::vector<double, std::allocator<double> >, boost::python::detail::not_specified, boost::python::detail::not_specified, boost::python::detail::not_specified>::class_(char const*, char const*) in bindings.cc.o
      boost::python::class_<std::vector<std::vector<unsigned long, std::allocator<unsigned long> >, std::allocator<std::vector<unsigned long, std::allocator<unsigned long> > > >, boost::python::detail::not_specified, boost::python::detail::not_specified, boost::python::detail::not_specified>::class_(char const*, char const*) in bindings.cc.o
      ...
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make[2]: *** [src/python/pyambit.so] Error 1
make[1]: *** [src/python/CMakeFiles/pyambit.dir/all] Error 2
make: *** [all] Error 2
Command failed: /bin/bash -x -e /Users/loriab/linux/psi4meta/conda-recipes/ambit/build.sh
jturney commented 8 years ago

I wonder if this is the issue of std:: vs boost:: version of shared_ptr.

loriab commented 8 years ago

If you make a branch with switching them out or advise me what to switch out, I can test. It's just https://anaconda.org/conda-forge/boost that I'm using.

jturney commented 8 years ago

I think two things to try:

  1. Change include/ambit/common_types.h to include boost/shared_ptr.hpp and change line 25 to be using boost::shared_ptr;.
  2. I noticed that src/python/bindings.cc doesn't explicitly use shared_ptr but for some reason boost/shared_ptr.hpp is include. You could try removing it.
loriab commented 8 years ago

No fix by either suggestion. But what I now suspect is going on is that having built ambit against libstdc++, it is linking correctly against similarly built boosts (the 1.59 I tried) but failing against libc++-built boosts (1.60 & 1.61). Unfortunately, I don't have a single boost version in both libstdc++ and libc++ forms to test with, but I know how to proceed.