0

I have tried to install a c++ code with boost/python in MacOS. The cmake step is fine. This is what I used for configuring.

export CC=/usr/local/bin/gcc
export CXX=/usr/local/bin/g++
export CPP=/usr/local/bin/cpp
export LD=/usr/local/bin/gcc
alias c++=/usr/local/bin/c++
alias g++=/usr/local/bin/g++
alias gcc=/usr/local/bin/gcc
alias cpp=/usr/local/bin/cpp
alias ld=/usr/local/bin/gcc
alias cc=/usr/local/bin/gcc

I received the following errors:

typeinfo for boost::python::objects::caller_py_function_impl<boost::python::detail::caller<void (liblibra::libcontext::Context::*)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<int, std::allocator<int> >), boost::python::default_call_policies, boost::mpl::vector4<void, liblibra::libcontext::Context&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<int, std::allocator<int> > > > > in libcontext_stat.a(libcontext.cpp.o)
    ...
    ld: symbol(s) not found for architecture x86_64
    collect2: error: ld returned 1 exit status

Not sure if this issue is related to the Boost/python. I installed the same code on cenos without any issue. But just has issue when install it on macos. Could anyone help me figure this out? Below is part of the CMAKELIST.txt file I have used:

CMAKE_MINIMUM_REQUIRED(VERSION 2.8) 
LIST(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules)

#
#  Python library

FIND_PACKAGE(PythonLibs 3.6 REQUIRED)

IF(PYTHONLIBS_FOUND)   
MESSAGE("Success!")   
INCLUDE_DIRECTORIES("${PYTHON_INCLUDE_DIRS}") 
ENDIF()

MESSAGE("Looking for Boost libraries...") 
SET(Boost_NO_BOOST_CMAKE TRUE) # to fix the problem of finding python37 libs 
SET(Boost_USE_STATIC_LIBS=OFF) 
SET(Boost_USE_MULTITHREADED=OFF) 
SET(Boost_USE_STATIC_RUNTIME=OFF)

FIND_PACKAGE(Boost 1.73.0 REQUIRED)

IF(Boost_FOUND)   
MESSAGE("Success!")   
INCLUDE_DIRECTORIES("${Boost_INCLUDE_DIRS}")    
# Adapt it based on your system   
FIND_PACKAGE(Boost COMPONENTS python36 regex) # it seems that it is important to find sub-packages too!!! 
ELSEIF(NOT Boost_FOUND)   
MESSAGE(FATAL_ERROR "Unable to find correct Boost version. Did you set BOOST_ROOT?") 
ENDIF()

MESSAGE("Found Boost libraries directory: ") 
MESSAGE("${Boost_LIBRARIES}") 
MESSAGE("Found Boost include directory: ") 
MESSAGE("${Boost_INCLUDE_DIRS}")

FIND_PACKAGE(Eigen3) 
IF(EIGEN3_FOUND)   
INCLUDE_DIRECTORIES("${EIGEN3_INCLUDE_DIR}")      
MESSAGE("Found Eigen3 include directory: ")   
MESSAGE("${EIGEN3_INCLUDE_DIR}") 
ELSEIF(NOT EIGEN3_FOUND)   
MESSAGE(FATAL_ERROR "Unable to find Eigen3") 
ENDIF()


SET(EIGEN3_INCLUDE_DIRS "${EIGEN3_INCLUDE_DIR}")

FIND_PACKAGE(Libint2 CONFIG 2.7.1 REQUIRED COMPONENTS shared gss impure_sh onebody_d0_l6 g12_d0_l4 g12_d1_l4 eri_c4_d0_l5 eri_c4_d1_l4)
#gss e5 g5) 
IF(Libint2_FOUND)    
INCLUDE_DIRECTORIES(Libint2::int2 Libint2::cxx Libint2::int2-cxx Libint2::impure_sh Libint2::gss Libint2::onebody_d0_l6 Libint::g12_d0_l4 Libint2::g12_d1_l4 Libint2::shared Libint2::cxx_ho Libint2::c  Libint2::eri_c4_d0_l5  Libint2::eri_c4_d1_l4)      
MESSAGE("${LIBINT2_INCLUDE_DIR}")   
MESSAGE("Found Libint2 include directory: ")   
MESSAGE("${Libint2_INCLUDE_DIRS}")   
MESSAGE("Found Libint2_LIBRARIES: ")   
MESSAGE("${Libint2_LIBRARIES}")   
MESSAGE("Found Libint2_LIBRARY: ")   
MESSAGE("${Libint2_LIBRARY}") 
ELSEIF(NOT Libint2_FOUND)   
MESSAGE(FATAL_ERROR "Unable to find correct libint2") 
ENDIF()


IF(CMAKE_COMPILER_IS_GNUCXX)
# For Linux   
ADD_DEFINITIONS("-Wall -Wl,-z,defs") 
ELSE()   
MESSAGE(FATAL_ERROR "CMakeLists.txt has not been tested/written for your compiler.") 
ENDIF()


#
#  Cmake configuration
MESSAGE("Setting up the CMake configuration...") 
IF(NOT CMAKE_BUILD_TYPE)   
SET(CMAKE_BUILD_TYPE "RELEASE")   
SET(CMAKE_CXX_FLAGS "-fPIC -O2 -fpermissive -w -g -I ${Boost_INCLUDE_DIRS} -fopenmp") 
ENDIF()


#
# Set the libraries
SET( ext_libs ${Boost_LIBRARIES} ${PYTHON_LIBRARIES}) 


#
# Now building the project
MESSAGE("Going into subdirectory src...") ADD_SUBDIRECTORY("src")

Thank you guys for your helps.

Wei Li
  • 1
  • 1
  • Thank you for your suggestions. I have made the changes. @Tsyvarev – Wei Li Jun 26 '22 at 21:12
  • If all your errors has `__cxx11` in them, this could signal about **ABI incompatibility** between your project and libraries it uses. See e.g. [that question](https://stackoverflow.com/questions/33394934/converting-std-cxx11string-to-stdstring). – Tsyvarev Jun 27 '22 at 08:47

0 Answers0