Repository navigation
Minimal Boost Python example not working #437
Description
Activity
The code above looks fine. I suspect the problem stems from the way this is compiled. Can you share the details of your build & execution environment ? I.e., platform, compiler, build commands, etc.
The code above looks fine. I suspect the problem stems from the way this is compiled. Can you share the details of your build & execution environment ? I.e., platform, compiler, build commands, etc.
Thanks for your quick reply!
I'm on Windows 11, using the compiler shipped with Visual Studio 17 2022, toolset v142. Also I use Ninja as the generator. To compile from the build folder activate my conda environment and I just do
ninjaI get boost 1.84 from Conda-forge. My CMakeLists file that finds boost has:
find_package(Python REQUIRED COMPONENTS Development) if(Python_FOUND) include_directories(${Python_INCLUDE_DIRS}) else() message(FATAL_ERROR "Python not found") endif() find_package(Boost REQUIRED COMPONENTS python) if(Boost_FOUND) include_directories(${Boost_INCLUDE_DIRS}) else() message(FATAL_ERROR "Boost not found") endif()I then link boost to the library that requires it. Perhaps I am missing a component of boost or python?
My conda env is created using this:
name: dev-env channels: - conda-forge dependencies: - cmake - boost - ninjaI've tried creating a minimal example here, but it seems to be struggling to build. Any ideas why? robertapplin/boost-example#2
Not sure exact solution but can you try using something other than std::string e.g int, this will likely mean that your code does not find/accept converter for const std::string&. Also why not python 3.11..
It works for an
int. The debugger seems to be able to read the std::string when I hover over the variable after setting a breakpoint. However it segfaults on thestd::coutlineI've also tried with python 3.10, and 3.11 - the same problem happens
this is what I'm using to print
https://github.com/CEXT-Dan/PyRx/blob/fd5b8ad47d3fddb50453277ba63ace1d1f51fb6f/PyRxCore/PyAcEd.cpp#L13-L18
It's not to cout, and I don't remember why I locked the GIL, something for you to try
I'm having trouble getting boost python to work with this minimal example. I've emailed the mailing list but have had no response.
I'm using C++20
This compiles fine, but I get a segmentation fault when I attempt to call the function from python (using 3.10):
The output I get:
Can you tell me what I'm doing wrong? Thanks in advance