I'm using PyBind11 to allow use of Python code within my C++ application. The application links successfully, but on the py::module::import below:
LOGICAL WebServer::
CheckForPort()
{
EPython::Prepare();
auto socket = py::module::import("socket");
auto s = socket.attr("socket")(socket.attr("AF_INET"),socket.attr("SOCK_STREAM"));
if (s == Py_None)
return L_TRUE;
auto rc = s.attr("connect_ex")("localhost",8810);
//
// Returns zero if port in in use
//
return (rc.cast<int>() == 0);
}
I get a run-time error
libc++abi: terminating due to uncaught exception of type pybind11::error_already_set: ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/lib-dynload/math.cpython-311-darwin.so, 0x0002): tried: '/Users/Shared/Develop/IntelApps/WinTD 5/DerivedData/WinTDOSX/Build/Products/Debug/math.cpython-311-darwin.so' (no such file), '/usr/lib/system/introspection/math.cpython-311-darwin.so' (no such file, not in dyld cache), '/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/lib-dynload/math.cpython-311-darwin.so' (code signature in <855730B8-106D-389C-BF65-36A98463EDB5> '/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/lib-dynload/math.cpython-311-darwin.so' not valid for use in process: mapping process and mapped file (non-platform) have different Team IDs),
I have no idea how to fix the code signature error---this is intended for distribution, so that presumably would be a file on the user's computer. I tried to link in the .so file, but that's a rabbit hole as there are a near endless set of further dependencies.