Reputation: 643
I have the following benchmark.cpp file:
#include <boost/python.hpp>
char const* greet()
{
return "hello, world";
}
BOOST_PYTHON_MODULE(benchmark)
{
using namespace boost::python;
def("greet", greet);
}
which is built using CMakeLists.txt containing i.a. the following pieces of code:
cmake_minimum_required(VERSION 3.21)
find_package (Python3 COMPONENTS Interpreter Development REQUIRED)
find_package(Boost COMPONENTS python REQUIRED)
set(BENCHMARK_MODULE benchmark)
add_library(${BENCHMARK_MODULE} MODULE benchmark.cpp)
set_target_properties(${BENCHMARK_MODULE} PROPERTIES PREFIX "" SUFFIX ".pyd")
target_include_directories(${BENCHMARK_MODULE} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(${BENCHMARK_MODULE} PUBLIC ${Boost_INCLUDE_DIR})
target_include_directories(${BENCHMARK_MODULE} SYSTEM PUBLIC ${Python3_INCLUDE_DIRS})
target_link_libraries(${BENCHMARK_MODULE} PUBLIC ${Python3_LIBRARIES})
target_link_libraries(${BENCHMARK_MODULE} PUBLIC ${Boost_LIBRARIES})
I'm building on Windows 10 using MSYS2's MinGW64 and Ninja generator; using Python 3.12.
Dependencies - An open-source modern Dependency Walker gave me the following dependencies for benchmark.pyd:
so in Python code, I've tried to import that module in the following way:
import os
import sys
sys.path.append('C:\\msys64\\mingw64\\bin')
[os.add_dll_directory(path) for path in sys.path if os.path.isdir(path)]
import benchmark
but when I run this code, I get "Process finished with exit code -1073741819 (0xC0000005)" message when importing benchmark module.
What is the reason for such behavior? How to fix it?
Upvotes: 0
Views: 35