johnboiles / obs-mac-virtualcam

ARCHIVED! This plugin is officially a part of OBS as of version 26.1. See note below for info on upgrading. 🎉🎉🎉Creates a virtual webcam device from the output of OBS. Especially useful for streaming smooth, composited video into Zoom, Hangouts, Jitsi etc. Like CatxFish/obs-virtualcam but for macOS.
GNU General Public License v2.0
4.06k stars 160 forks source link

Try to fix the OBS build #229

Closed johnboiles closed 4 years ago

johnboiles commented 4 years ago

The errors look like this:

[ 72%] Linking CXX shared library libobs-scripting.dylib
Undefined symbols for architecture x86_64:
  "__Py_Dealloc", referenced from:
      _py_to_libobs_ in obs-scripting-python.c.o
      _libobs_to_py_ in obs-scripting-python.c.o
      _add_functions_to_py_module in obs-scripting-python.c.o
      _add_to_python_path in obs-scripting-python.c.o
      _load_python_script in obs-scripting-python.c.o
      _obs_python_script_update in obs-scripting-python.c.o
      _obs_python_script_unload in obs-scripting-python.c.o
      ...
ld: symbol(s) not found for architecture x86_64

I noticed in the OBS build instructions there's this python-related cmake flag that I don't think was there before:

cmake -DCMAKE_OSX_DEPLOYMENT_TARGET=10.13 -DDISABLE_PYTHON=ON ..

It'd be more consistent to instead use an environment variable for this (like we do for MACOSX_DEPLOYMENT_TARGET and QTDIR). But I'm not 100% that will work and I want to try out https://github.com/obsproject/obs-studio/pull/3492.

PatTheMav commented 4 years ago

That issue has nothing to do with virtualcam - you need to disable Python support in your cmake command via -DDISABLE_PYTHON=YES or add the following to deps/obs-scripting/obs-scripting-python-import.h:

#if PY_VERSION_HEX >= 0x030800f0
static inline void py3__Py_DECREF(const char *filename, int lineno,
                  PyObject *op)
{
    (void)filename; /* may be unused, shut up -Wunused-parameter */
    (void)lineno;   /* may be unused, shut up -Wunused-parameter */
    _Py_DEC_REFTOTAL;
    if (--op->ob_refcnt != 0) {
#ifdef Py_REF_DEBUG
        if (op->ob_refcnt < 0) {
            _Py_NegativeRefcount(filename, lineno, op);
        }
#endif
    } else {
        _Py_Dealloc(op);
    }
}

#undef Py_DECREF
#define Py_DECREF(op) py3__Py_DECREF(__FILE__, __LINE__, _PyObject_CAST(op))

static inline void py3__Py_XDECREF(PyObject *op)
{
    if (op != NULL) {
        Py_DECREF(op);
    }
}

#undef Py_XDECREF
#define Py_XDECREF(op) py3__Py_XDECREF(_PyObject_CAST(op))
#endif

#if PY_VERSION_HEX >= 0x030900b0
static inline int py3_PyType_HasFeature(PyTypeObject *type,
                    unsigned long feature)
{
    return ((PyType_GetFlags(type) & feature) != 0);
}
#define PyType_HasFeature(t, f) py3_PyType_HasFeature(t, f)
#endif

In the main CI we fixed this by disabling Python entirely, I'm currently investigating side-effects for the above fix to re-enable it by default.

johnboiles commented 4 years ago

you need to disable Python support in your cmake command via -DDISABLE_PYTHON=YES

Yep! That's what this PR does I think (see diff)