Currently I’m trying to get JUCE to work from Cython. So far, I have a setup.py and a Cython file (shown below) and compiled JUCE as a static library. Compilation of the Cython file goes fine, but the problem starts when I import the created Cython-module, which results in the following error:
ImportError: dlopen(<project root>/testb.cpython-36m-darwin.so, 2): Symbol not found: _CGAffineTransformIdentity Referenced from: <project root>/testb.cpython-36m-darwin.so Expected in: flat namespace in <project root>/testb.cpython-36m-darwin.so
This seems to be due to some missing libraries and I was wondering what the best way would be to resolve this situation (preferably in a mostly portable way). Should I simply install the libraries and if so, which exactly? Or is there a way to compile the JUCE library so that it doesn’t have any other dependencies (perhaps with the Projucer)?
Thanks in advance for your answers.
from setuptools import setup from setuptools.extension import Extension from Cython.Build import cythonize compile_args = ['-g', '-std=c++11', '-stdlib=libc++'] extensions = [Extension('testb', ['src/program/testb.pyx'], extra_compile_args=compile_args, include_dirs = ["JUCE/modules"], libraries=["JuceStaticLibrary"], #the name of my static JUCE library library_dirs=["src/program/JuceLibraryCode"] #where the static library is placed. )] setup( name='My app', ext_modules=cythonize(extensions) )
And my actual Cython file:
# distutils: language = c++
from libcpp.string cimport string cdef extern from "JuceLibraryCode/JuceHeader.h": cdef cppclass AlertWindow: AlertWindow(String, String, AlertIconType, Component*) cdef cppclass Component: Component() cdef cppclass String: String(string) cdef extern from "JuceLibraryCode/JuceHeader.h" namespace "juce::AlertWindow": ctypedef enum AlertIconType: NoIcon QuestionIcon WarningIcon InfoIcon cdef class PyAlertWindow: cdef AlertWindow *thisptr def __cinit__(self): self.thisptr = new AlertWindow(String(""), String(""), AlertIconType(NoIcon), NULL) def __dealloc__(self): del self.thisptr