How does cocos2d-x-4 cross-compile? I compiled cocos2d-x-4 on aarch64 ubuntu system unsuccessfully?

  1. On the ARCH64-bit Ubuntu 20.04 system,
    Compilation tools:
    gcc-9-aarch64-linux-gnu
    g+±9-aarch64-linux-gnu
    After compiling the cocos2d-x-4 source code and cross-compiling the libchipmunk 7.0.0 library, the following problems are encountered in the build example:
    Copying lua scripts …

Copying resources for lua-tests …

[ 8%] Built target SYNC_RESOURCE-cpp-tests

copying to /home/firefly/cocos2d-x-4/build/linux-build/bin/lua-tests/Resources/res

Copying resources for HelloCpp …

copying to /home/firefly/cocos2d-x-4/build/linux-build/bin/HelloCpp/Resources

[ 9%] Built target external

copying to /home/firefly/cocos2d-x-4/build/linux-build/bin/lua-tests/Resources/res

[ 9%] Built target SYNC_RESOURCE-HelloCpp

[ 9%] Built target COPY_LUA-lua-tests

[ 9%] Built target SYNC_RESOURCE-lua-tests

[ 78%] Built target cocos2d

[ 78%] Linking CXX executable …/…/…/bin/HelloCpp/HelloCpp

[ 79%] Linking CXX executable …/…/…/bin/cpp-empty-test/cpp-empty-test

[ 86%] Built target luacocos2d

[ 86%] Linking CXX executable …/…/…/bin/lua-empty-test/lua-empty-test

/usr/bin/ld: …/…/…/…/…/external/freetype2/prebuilt/linux/64-bit/libfreetype.a(ftinit.o): Relocations in generic ELF (EM: 62)

/usr/bin/ld: …/…/…/…/…/external/freetype2/prebuilt/linux/64-bit/libfreetype.a(ftinit.o): Relocations in generic ELF (EM: 62)

/usr/bin/ld: …/…/…/…/…/external/freetype2/prebuilt/linux/64-bit/libfreetype.a(ftinit.o): Relocations in generic ELF (EM: 62)

/usr/bin/ld: …/…/…/…/…/external/freetype2/prebuilt/linux/64-bit/libfreetype.a: error adding symbols: file in wrong format

collect2: error: ld returned 1 exit status

make[2]: *** [engine/tests/cpp-empty-test/CMakeFiles/cpp-empty-test.dir/build.make:152: bin/cpp-empty-test/cpp-empty-test] Error 1

make[1]: *** [CMakeFiles/Makefile2:1233: engine/tests/cpp-empty-test/CMakeFiles/cpp-empty-test.dir/all] Error 2

Looks like there is mismatch between arch binary formats of prebuilt libraries and the ones you get after compiling with tools.
The similar issue https://groups.google.com/g/android-ndk/c/iFzaG9pVYtY

PS
As I understand you have built elf for arm64 (according to your build tool) and try to link it with X86_64 ((EM: 62) error)