VoCore2: Compile on new MacOS SDK issue

Every time when macos update to new version, always broken something, I guess that is an important reason it has very few virus.

When I compile openwrt 18.06.5 in macos, I get new problems.

1. GCC compiler version must greater than 4.8

I have no idea about this issue…it works before, I do not remember I change anything.

Solution:
brew install gcc@9
ln -s /usr/local/bin/gcc-9 /usr/local/bin/gcc
ln -s /usr/local/bin/g++-9 /usr/local/bin/g++
add /usr/local/bin to $PATH(in ~/.profile), set it at higher level than /usr/bin to cover macos default gcc path.

2. variably modified ‘bytes’ at file scope

I think this is because xcode update change the header file…
in standard C language, array size must be const, a fixed number.

This is not allowed(as I remember this way is allowed in C++?):
const int kAuthorizationExternalFormLength = 32;
int array[kAuthorizationExternalFormLength];

But this is OK:
#define kAuthorizationExternalFormLength 32
int array[kAuthorizationExternalFormLength];

Solution:

sudo vi /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Security.framework/Headers/Authorization.h

directly change const to #define. Ugly but works 🙂

3. Emm, after a while, cmake can not compile…
Solution:
rm /usr/local/bin/gcc /usr/local/bin/g++
ln -s /usr/bin/gcc /usr/local/bin/gcc
ln -s /usr/bin/g++ /usr/local/bin/g++

change it back, then works…maybe I should directly patch openwrt Makefile. :’)

Finally I find a better solution
Once 1 passed, we can change it back to gcc 4.2.1 which is macos clang, then everything works normal. so weird.