Missing symbols when compiling an external on Apple M1
I have missing _common_symbols and common_symbols_init symbols when compiling an external on Apple M1. Any idea how to solve that?
Do you include commonsyms.c and added "common_symbols_init();" in your main method?
Is that supposed to be done? The same code was linking without problems when compiled on Intel.
I mean: I was not calling common_symbols_init() in the main method.
I think with the new SDK to support M1 this became a requirement
No, it's not a typo. commonsyms.c is defining the common_symbols_init() that you need to call in your main() method. Only after that, all these symbols are predefined and you can chuck many gensym() from your code, which always does a lookup and therefore eats performance. To include in your code, you have multiple ways:
in your cMakeList:add_library(
${PROJECT_NAME}
MODULE
${PROJECT_SRC}
${MAX_SDK_INCLUDES}/common/commonsyms.c
)
or by including in your source file:#include "common/commonsyms.c"
or manually adding commonsyms.c in your IDE to the targets.
You're lucky to get an error message. On Win, when you forget common_symbols_init(), external compiles fine and crashes at creation time in Max 😩