How to compiler dlang code on Apple M1?

j my.email at gmail.com
Sun Dec 18 05:16:20 UTC 2022


On Saturday, 3 December 2022 at 18:59:58 UTC, zoujiaqing wrote:
> ```
> dub build --compiler=ldc2 --arch=arm64-apple-macos
>     Starting Performing "debug" build using ldc2 for aarch64, 
> arm_hardfloat.
>     Building taggedalgebraic 0.11.22: building configuration 
> [library]
>     Building eventcore 0.9.20+commit.4.g6744ae7: building 
> configuration [cfrunloop]
>     Building server ~master: building configuration 
> [application]
>      Linking server
> ld: warning: ignoring file 
> ../../../.dub/packages/taggedalgebraic-0.11.22/taggedalgebraic/.dub/build/library-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.30.0-60F6D8BEA34F8F5E792A98EA27B02D2235262A4E0795062F91FA90871411535D/libtaggedalgebraic.a, building for macOS-x86_64 but attempting to link with file built for unknown-arm64
> ld: warning: ignoring file 
> /opt/homebrew/Cellar/ldc/1.30.0_1/lib/libdruntime-ldc.a, 
> building for macOS-x86_64 but attempting to link with file 
> built for macOS-arm64
> ld: warning: ignoring file 
> .dub/build/application-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.30.0-7AC1A4B8AFD7D9F59DB01E667A3DCF19DD437F41E741F5937BDCF58FAE6AA922/server.o, building for macOS-x86_64 but attempting to link with file built for unknown-arm64
> ld: warning: ignoring file 
> ../../eventcore/.dub/build/cfrunloop-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.30.0-ED6AFABD5E24BB6BCED6FD74F2DE88CF39B648360CE187983206459095D4677D/libeventcore.a, building for macOS-x86_64 but attempting to link with file built for unknown-arm64
> ld: warning: ignoring file 
> /opt/homebrew/Cellar/ldc/1.30.0_1/lib/libphobos2-ldc.a, 
> building for macOS-x86_64 but attempting to link with file 
> built for macOS-arm64
> Undefined symbols for architecture x86_64:
>   "_main", referenced from:
>      implicit entry/start for main executable
> ld: symbol(s) not found for architecture x86_64
> clang: error: linker command failed with exit code 1 (use -v to 
> see invocation)
> Error: /usr/bin/cc failed with status: 1
> Error ldc2 failed with exit code 1.
> ```



Always look for the first error in the stacktrace. Are you using 
Linux or Windows? Use Windows. Don't use Linux. There is a 
missing symbol error from ld linker after entry start. In this 
case the software doesn't seem to be installed correctly. Then if 
you slightly further up it clearly states
> building for macOS-x86_64 but attempting
> to link with file built for unknown-arm64

followed by
> ld: warning: ignoring file

There. You see that? Your problem seems to be that you do not 
have the macOS-x86_64 software required. It tried to do its best 
to build despite you not having the correct libraries before 
giving up because it failed to find the first symbol from the 
entry point.


More information about the Digitalmars-d-learn mailing list