Skip to content

Building PYCC for MacOS issues

dimxy edited this page Aug 13, 2020 · 25 revisions

Several issues when building PYCC komodod and pycctx.so lib for MacOS

Used MacOS: Catalyna

Building komodod with Python Engine on MacOS

The ref to Python lib is defined in src/Makefile.am Be careful it defines both version numbers (3.n), you should install the exact version as default. It was initially set by -lpython3.6m but I changed it to 3.7 as 3.6 installation is not directly supported on my MacOS.

To make headers like "Python.h" available for the compiler I added
-L /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/headers to CPPFLAGS var in build-mac.sh

When komodod is built it could not load with an error 'Python3 could not be found'. The otool -L komodod showed that a dylib relative dependency to the python3 was added: @rpath/Python3.framework/Versions/3.7/Python3. To resolve it I added -Wl,-rpath,/Library/Developer/CommandLineTools/Library/Frameworks to CXXFLAGS var in build-mac.sh

Building libpycc.dylib on MacOS

When I built pycc.so running make it ended with a lot of errors like

            "_PyImport_ExecCodeModuleEx", referenced from:
                pyo3::types::module::PyModule::from_code::h5221d5256e3ab9a9 in libpyo3-a79a90d0681fac3f.rlib(pyo3-a79a90d0681fac3f.pyo3.dl3qelwn-cgu.9.rcgu.o)

The solution for Mac was found here: https://github.com/PyO3/pyo3, to create a ~/.cargo/config with params

[target.x86_64-apple-darwin]
rustflags = [
  "-C", "link-arg=-undefined",
  "-C", "link-arg=dynamic_lookup",
]
Clone this wiki locally