Q: Boost:Python: undefined symbol: _ZN5boost6python15instance_holder8allocateEP7_objectmmm I am trying to use Boost:Python to expose a C++ class and compiling with CMake on an Ubuntu system.
The shared library does build, but when I try to import it into Python, I get the following error
ImportError: [filename]: undefined symbol: _ZN5boost6python15instance_holder8allocateEP7_objectmmm
I have tried the following that I found online to fix similar problems:

*

*Added add_link_options(-lboost_numpy -lpython3.6m -lboost_python3) before linking the libraries

*Added target_link_libraries(DroneAccessLib ${Boost_LIBRARIES} ${PYTHON_LIBRARIES}) to targets

*Rebuilt Boost with ./b2 install
Any other ideas / suggestions for getting past this error? I will provide the CMakeLists.txt below.
Because the CMake is building a large project, I will provide just the stuff related to the Boost aspect so it isn't a bunch of irrelevant info.
cmake_minimum_required(VERSION 3.13)
project(combined_drone_calls)

# Set compiler flags + our source files
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fPIC -std=c++11 -pthread -g -O0 -DBoost_NO_BOOST_CMAKE=ON -lboost_numpy -lpython3.6m -lboost_python3")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -Wall -O3" )
set(THREADS_PREFER_PTHREAD_FLAG ON)
set(SRC_FILES ${SRC_FILES} combined_drone_calls.cpp)
set (WORKING_DIR ~/Projects/drone_research_root/flight_algorithm/combined_cam_height)
set("BOOST_ROOT" "/home/boost_1_77_0/")
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
SET(Boost_USE_STATIC_LIBS OFF)

SET(CMAKE_EXE_LINKER_FLAGS  "${CMAKE_EXE_LINKER_FLAGS} ${GCC_COVERAGE_LINK_FLAGS}")

include_directories(include /usr/local/include)
include_directories(include /usr/local/lib)

# Include partner code
include_directories(${WORKING_DIR})

# Find all boost and python libraries
include_directories(/usr/include/python3.6m})
include_directories(/usr/include/aarch64-linux-gnu/python3.6m})
include_directories(/home/caroline/boost_1_77_0/libs/python})
include_directories(/home/caroline/boost_1_77_0)

# Find necessary packages
find_package( PythonLibs 3.6 REQUIRED )
find_package(Boost 1.77 EXACT REQUIRED COMPONENTS python3 system)
find_package (Python3 COMPONENTS Interpreter Development REQUIRED)

if(Boost_FOUND)
    message(STATUS "Boost_INCLUDE_DIRS: ${Boost_INCLUDE_DIRS}")
    message(STATUS "Boost_LIBRARIES: ${Boost_LIBRARIES}")
    message(STATUS "Boost_VERSION: ${Boost_VERSION}")
    include_directories(${Boost_INCLUDE_DIRS} "-I/usr/include/python3.6m/" "/usr/local/include/boost/python")
endif()
if(Python3_FOUND)
    message(STATUS "Python Found: ${Python3_EXECUTABLE}")
    message(STATUS "Python Found: ${Python3_INCLUDE_DIRS}")
    message(STATUS "Python Found: ${Python3_LIBRARIES}")
    message(STATUS "Python Found: ${Python3_LIBRARY_DIRS}")
    include_directories(${Python3_INCLUDE_DIRS})
endif()

# Find OpenCV
find_package(OpenCV 4 REQUIRED)
if (OpenCV_FOUND)
  message("\n${PROJECT_NAME}...")
  message(STATUS "Found OpenCV installed in the system, will use it to display image in AdvancedSensing APIs")
  message(STATUS " - Includes: ${OpenCV_INCLUDE_DIRS}")
  message(STATUS " - Libraries: ${OpenCV_LIBRARIES}")
  add_definitions(-DOPEN_CV_INSTALLED)
else()
  message( STATUS "Did not find OpenCV in the system, image data is inside RecvContainer as raw data")
endif ()

include_directories("/usr/local/include/opencv4")

set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)

PYTHON_ADD_MODULE(DroneAccessLib ../combined_drone_calls.cpp)

add_library(DroneAccess MODULE
  ../combined_drone_calls.cpp
  ${SRC_FILES}
  ${HELPER_FUNCTIONS_DIR}/common/dji_linux_environment.cpp
  ${HELPER_FUNCTIONS_DIR}/common/dji_linux_helpers.cpp
  ${WORKING_DIR}/combined_drone_calls.hpp
  ${WORKING_DIR}/combined_drone_calls.cpp
  )

set_target_properties(${PROJECT_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")

link_directories(/home/caroline/boost_1_77_0/stage/lib)

# Link libraries for boost lib
target_link_libraries(DroneAccess PUBLIC ${Boost_LIBRARIES} ${PYTHON3_LIBRARIES})
target_link_libraries(DroneAccess PUBLIC ${OpenCV_LIBS} djiosdk-core dji-linker ${LIBUSB_1_LIBRARIES} ${FFMPEG_LIBRARIES} advanced-sensing)
target_link_libraries(DroneAccess PUBLIC ${FFMPEG_LIBRARIES} pthread)
target_link_libraries(DroneAccess PUBLIC /home/caroline/Projects/Onboard-SDK/osdk-core/linker/${ARCH}/lib/libdji-linker.a)
target_include_directories(DroneAccess PRIVATE ${OpenCV_INCLUDE_DIRS})
target_include_directories(DroneAccess PRIVATE ${CLOSED_SRC})
target_include_directories(DroneAccess PRIVATE ${Boost_INCLUDE_DIRS})
target_include_directories(DroneAccess PRIVATE ${LIBUSB_1_INCLUDE_DIRS})
target_include_directories(DroneAccess PRIVATE ${FFMPEG_INCLUDE_DIR})
target_include_directories(DroneAccess PRIVATE $<BUILD_INTERFACE:${ADVANCED_SENSING_HEADERS_DIR}>)
target_include_directories(DroneAccess PRIVATE ${PYTHON3_INCLUDE_DIRS})


Update: Edited CMakeLists.txt with a cleaned up version

A: Found the solution!
I was getting this error because the CMake file was not finding the correct Python version. My solution was to change:
find_package(Python3 COMPONENTS Interpreter Development REQUIRED)
to this
find_package(Python 3.6 COMPONENTS Interpreter Development REQUIRED)
and then to change all references to Python3 (_Libs, Dirs, etc) to just Python. This solved my problem.
