Macos'ld:scholdutection x86_64的符号(s)
我尝试在MacOS中使用Boost/Python安装C ++代码。 CMAKE步骤很好。这是我用于配置的方法。
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
我收到以下错误:
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
不确定此问题是否与Boost/Python有关。我在CENOS上安装了相同的代码,没有任何问题。但是,在MacOS上安装它时只是问题。谁能帮我解决这个问题?以下是我使用过的cmakelist.txt文件的一部分:
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")
谢谢大家的帮助。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论