boostorg / python

Boost.org python module
http://boostorg.github.io/python
Boost Software License 1.0
468 stars 201 forks source link

Unexpected exit when use Visual Studio 2022 #389

Open linjiahao962889027 opened 2 years ago

linjiahao962889027 commented 2 years ago

I installed boost Python on Windows using vcpkg. And I successfully compiled my DLL file, but I don't know why Python always exits automatically after import the dll. This is my code (dllmain.cpp):

// dllmain.cpp : 定义 DLL 应用程序的入口点。
#include "pch.h"

#include <iostream>
#include <string>
#define BOOST_PYTHON_STATIC_LIB
#include <boost/python.hpp>

using namespace boost::python;

void test() {
    std::cout << "Test" << std::endl;
}

BOOST_PYTHON_MODULE(Dll1)
{
    boost::python::def("test", test);
}

屏幕截图 2022-07-04 164552 屏幕截图 2022-07-04 164750 This is my Visual Studio 2022 Config: 屏幕截图 2022-07-04 164905 屏幕截图 2022-07-04 164926 屏幕截图 2022-07-04 164952