www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - dub does not correctly link on Macbook Pro 2019 (intel)

reply Alexander <poneomenos gmail.com> writes:
Completely new to D, and when trying to setup the toolchain, DMD 
seems to work fine, but dub is running into linker issues.  Below 
is session showing a simple hello world directory initialized 
with dub init, and the issues I am encountering.  Any help would 
be greatly appreciated:

 % tree
``` . ├── dub.json └── source └── app.d 2 directories, 2 files ```
 pacs PACS-2019-MBPRO hellod % cat dub.json
``` { "name": "hellod" } ```
 % cat source/app.d
``` import std.stdio; void main() { writeln("Edit source/app.d to start your project."); } ```
 % dub run
``` Starting Performing "debug" build using dmd for x86_64. Building hellod ~master: building configuration [application] Linking hellod ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers ld: warning: pointer not aligned at address 0x1000681CE ('anon' + 462 from /Users/pacs/.dub/cache/hellod/~master/build/application-debug-g5hl-T2MblAlsFiv_Yxjpw/h ellod.o) ld: warning: pointer not aligned at address 0x1000681E7 ('anon' + 487 from /Users/pacs/.dub/cache/hellod/~master/build/application-debug-g5hl-T2MblAlsFiv_Yxjpw/h ellod.o) ld: warning: pointer not aligned at address 0x1000682E7 ('anon' + 743 from /Users/pacs/.dub/cache/hellod/~master/build/application-debug-g5hl-T2MblAlsFiv_Yxjpw/h ellod.o) ld: warning: pointer not aligned at address 0x10006832F ('anon' + 815 from /Users/pacs/.dub/cache/hellod/~master/build/application-debug-g5hl-T2MblAlsFiv_Yxjpw/h ellod.o) ld: warning: pointer not aligned at address 0x100068385 ('anon' + 901 from /Users/pacs/.dub/cache/hellod/~master/build/application-debug-g5hl-T2MblAlsFiv_Yxjpw/h ellod.o) ld: warning: pointer not aligned at address 0x100068446 ('anon' + 1094 from /Users/pacs/.dub/cache/hellod/~master/build/application-debug-g5hl-T2MblAlsFiv_Yxjpw/ hellod.o) ld: warning: pointer not aligned at address 0x100068462 ('anon' + 1122 from /Users/pacs/.dub/cache/hellod/~master/build/application-debug-g5hl-T2MblAlsFiv_Yxjpw/ hellod.o) ld: unaligned pointer(s) for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) Error: linker exited with status 1 Error dmd failed with exit code 1. ```
 % cd source
% dmd app.d % ls -l ``` total 1688 -rwxr-xr-x 1 pacs staff 842616 Aug 19 16:30 app -rw-r--r-- 1 pacs staff 89 Aug 19 02:46 app.d -rw-r--r-- 1 pacs staff 15496 Aug 19 16:30 app.o ```
 % otool -L app
``` app: /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1319.100.3) ```
 % file app
``` app: Mach-O 64-bit executable x86_64 ```
 % ./app
``` Edit source/app.d to start your project. ```
Aug 19 2023
next sibling parent reply Sergey <kornburn yandex.ru> writes:
On Saturday, 19 August 2023 at 21:35:25 UTC, Alexander wrote:
 Completely new to D, and when trying to setup the toolchain,
Could you please specify the versions of macOS and DMD? Probably DMD is broken for macOS - could you try to use LDC? Maybe this thread is relative to the problem: https://github.com/ldc-developers/ldc/issues/3864
Aug 19 2023
next sibling parent reply Kyle Ingraham <kyle kyleingraham.com> writes:
On Saturday, 19 August 2023 at 22:53:53 UTC, Sergey wrote:
 On Saturday, 19 August 2023 at 21:35:25 UTC, Alexander wrote:
 Completely new to D, and when trying to setup the toolchain,
Could you please specify the versions of macOS and DMD? Probably DMD is broken for macOS - could you try to use LDC? Maybe this thread is relative to the problem: https://github.com/ldc-developers/ldc/issues/3864
I think that thread is where I originally found the bandaid I described: https://github.com/ldc-developers/ldc/issues/3864#issuecomment-963304679
Aug 19 2023
parent Alexander <poneomenos gmail.com> writes:
On Sunday, 20 August 2023 at 01:12:56 UTC, Kyle Ingraham wrote:
 On Saturday, 19 August 2023 at 22:53:53 UTC, Sergey wrote:
 On Saturday, 19 August 2023 at 21:35:25 UTC, Alexander wrote:
 Completely new to D, and when trying to setup the toolchain,
Could you please specify the versions of macOS and DMD? Probably DMD is broken for macOS - could you try to use LDC? Maybe this thread is relative to the problem: https://github.com/ldc-developers/ldc/issues/3864
I think that thread is where I originally found the bandaid I described: https://github.com/ldc-developers/ldc/issues/3864#issuecomment-963304679
Setting MACOSX_DEPLOYMENT_TARGET=12 allows dub to work with dmd. It's when I don't have it set, or set to 13 that I get those linker errors. Maybe this would have been obvious to a C or C++ developer, but I do all my professional development on scala and thank you for your help.
Aug 19 2023
prev sibling parent reply Alexander <poneomenos gmail.com> writes:
On Saturday, 19 August 2023 at 22:53:53 UTC, Sergey wrote:
 On Saturday, 19 August 2023 at 21:35:25 UTC, Alexander wrote:
 Completely new to D, and when trying to setup the toolchain,
Could you please specify the versions of macOS and DMD? Probably DMD is broken for macOS - could you try to use LDC? Maybe this thread is relative to the problem: https://github.com/ldc-developers/ldc/issues/3864
Thanks for the advice: I have installed dmd, dub, and now ldc with brew. Versions below:
 % dmd --version
``` DMD64 D Compiler v2.105.0 Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved written by Walter Bright ```
 % dub --version
``` DUB version 1.34.0, built on Aug 1 2023 pacs PACS-2019-MBPRO ~ % sw_vers ProductName: macOS ProductVersion: 13.5 BuildVersion: 22G74 ```
 % ldc2 --version
``` LDC - the LLVM D compiler (1.33.0): based on DMD v2.103.1 and LLVM 15.0.7 built with LDC - the LLVM D compiler (1.28.1) Default target: x86_64-apple-darwin22.6.0 Host CPU: skylake http://dlang.org - http://wiki.dlang.org/LDC Registered Targets: ... ```
 % cat ~/.dub/settings.json
``` { "defaultArchitecture": "x86_64", "defaultCompiler": "ldc2" } ``` (where defaultCompiler had been dmd before).
 % dub run
``` Starting Performing "debug" build using ldc2 for x86_64. Up-to-date hellod ~master: target for configuration [application] is up to date. Finished To force a rebuild of up-to-date targets, run again with --force Running hellod Edit source/app.d to start your project. ``` So, ldc2 seems to work with dub, where dmd did not. The odd thing though is, if you refer to my original post, is that I was able to build successfully by directly invoking dmd.
Aug 19 2023
parent Alexander <poneomenos gmail.com> writes:
On Sunday, 20 August 2023 at 01:32:08 UTC, Alexander wrote:
 On Saturday, 19 August 2023 at 22:53:53 UTC, Sergey wrote:
 [...]
Thanks for the advice: I have installed dmd, dub, and now ldc with brew. Versions below: [...]
Just to add my MacOS version:
 % sw_vers
``` ProductName: macOS ProductVersion: 13.5 BuildVersion: 22G74 ```
Aug 19 2023
prev sibling parent Kyle Ingraham <kyle kyleingraham.com> writes:
On Saturday, 19 August 2023 at 21:35:25 UTC, Alexander wrote:
 Completely new to D, and when trying to setup the toolchain, 
 DMD seems to work fine, but dub is running into linker issues.
On my Intel iMac I have to set `MACOSX_DEPLOYMENT_TARGET`: ``` MACOSX_DEPLOYMENT_TARGET=11 dub run ``` That puts a bandaid on the linker issues. I haven’t yet set aside time to report it as an issue.
Aug 19 2023