Boost Python: "Mixing a dll boost library with a static runtime is a really bad idea..."

I am currently trying to create a python binding for a large C++ library. After some searching, I have decided to use boost/python.

I am running into a compiler error:
C:\Users\mathh\lib\boost_1_80_0\boost/config/auto_link.hpp(435): fatal error C1189: #error:  "Mixing a dll boost library with a static runtime is a really bad idea..."


After some searching, I saw someone used #define BOOST_PYTHON_STATIC_LIB to bypass this error, but when I do this, I get an error from the linker about failing to find python310.lib. I know where this file is, I think I just need to point to it from the linker options, but I don't know if using a static library is a good idea here. To be honest, I'm not sure what the differences are.

This is the first time I've used boost. It's the first time I've tried to create a python native binding. And I haven't messed with DLL files in quite awhile, and I was never very good at them to begin with.

I'm using the visual studio command line compiler "cl". I have all the include paths set up, and am trying to compile with the /LD option.

Any advice?
Current code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#define BOOST_PYTHON_DYNAMIC_LIB

#include <exception>
#include <boost/python.hpp>
#include "udc.h"
#include "MSD.h"

using namespace std;
using namespace udc;
using namespace boost::python;

BOOST_PYTHON_MODULE(example_msd) {
 // -------------------- udc.h --------------------
	scope().attr("E") = E;
	scope().attr("PI") = PI;
	
	def("sq", sq);
	def("cube", cube);
}  // end BOOST_PYTHON_MODULE(msd)


cmd output:

C:\Users\mathh\GitHub\Molecular-Spintronics-Research-Project\MSD Research Project - Latest Development Version>cl /LD /I %BOOST_INCLUDE% /I %PYTHON_INCLUDE% /EHsc src/example-python-binding.cpp 
Microsoft (R) C/C++ Optimizing Compiler Version 19.29.30136 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.

example-python-binding.cpp
C:\Users\mathh\lib\boost_1_80_0\boost/config/auto_link.hpp(435): fatal error C1189: #error:  "Mixing a dll boost library with a static runtime is a really bad idea..."
Topic archived. No new replies allowed.