www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Failed to link a 7 month old GTKD project

reply Ki Rill <rill.ki yahoo.com> writes:
I was updating my old D projects. Surprisingly... or not, I found 
one that outputs a linker error. Though, I clearly remember it 
compiled perfectly fine the last time I worked on it. It is a 
GTKD project using DUB.

DUB output:
```
Linking...
Undefined symbols for architecture x86_64:
   "__D3std4file11DirIterator15__fieldPostblitMFNaNbNiNlZv", 
referenced from:
       
__D3std9algorithm9iteration__T6filterS3app7listdirFAyaZ9__lambda2Z__TQBnTSQCt4file11DirIteratorZQCoMFQBcZSQDzQDyQDr__T12FilterResultSQD
QDqFQDlZQDlTQCxZQBi in extension-er.o
       
__D3std9algorithm9iteration__T12FilterResultS3app7listdirFAyaZ9__lambda2TSQCt4file11DirIteratorZQCo6__ctorMFNcQBlZSQEiQEhQEa__TQDtSQD
QDhFQDcZQDcTQCvZQEq in extension-er.o
       
__D3std9algorithm9iteration__T12FilterResultS3app7listdirFAyaZ9__lambda2TSQCt4file11DirIteratorZQCo6__ctorMFNcQBlbZSQEjQEiQEb__TQDuSQD
QDiFQDdZQDdTQCwZQEr in extension-er.o
       
__D3std9algorithm9iteration__T12FilterResultS3app7listdirFAyaZ9__lambda2TSQCt4file11DirIteratorZQCo15__field
ostblitMFNaNbNiNlZv in extension-er.o
       __D32TypeInfo_S3std4file11DirIterator6__initZ in 
extension-er.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to 
see invocation)
Error: linker exited with status 1
```

If I'm not mistaken, this cryptic message tries to tell me that 
something is wrong with the standard library functions: 
`Undefined symbols...` But what's wrong exactly?

Any directions?

Any help solving this issue is greatly appreciated.
Aug 05 2021
parent reply Mathias LANG <geod24 gmail.com> writes:
On Thursday, 5 August 2021 at 10:05:28 UTC, Ki Rill wrote:
 Any directions?

 Any help solving this issue is greatly appreciated.
Pretty hard to know what got wrong without log. First question would be, did you do `dub -f` to make sure you were not linking with stale object file ? Better yet, did you try compiling from a clean checkout ? A link to the code and a CI run that fails in the same way would be best.
Aug 05 2021
parent reply Ki Rill <rill.ki yahoo.com> writes:
On Thursday, 5 August 2021 at 10:15:47 UTC, Mathias LANG wrote:
 Pretty hard to know what got wrong without log. First question 
 would be, did you do `dub -f` to make sure you were not linking 
 with stale object file ? Better yet, did you try compiling from 
 a clean checkout ?
 A link to the code and a CI run that fails in the same way 
 would be best.
Yes, I tried. It didn't help. I have another active GTKD project and it compiles successfully with the same dub.json settings. Here is the link to the [code](https://github.com/rillki/extension-er/blob/main/source/app.d).
Aug 05 2021
parent reply Steven Schveighoffer <schveiguy gmail.com> writes:
On 8/5/21 6:50 AM, Ki Rill wrote:
 On Thursday, 5 August 2021 at 10:15:47 UTC, Mathias LANG wrote:
 Pretty hard to know what got wrong without log. First question would 
 be, did you do `dub -f` to make sure you were not linking with stale 
 object file ? Better yet, did you try compiling from a clean checkout ?
 A link to the code and a CI run that fails in the same way would be best.
Yes, I tried. It didn't help. I have another active GTKD project and it compiles successfully with the same dub.json settings. Here is the link to the [code](https://github.com/rillki/extension-er/blob/main/source/app.d).
I git-cloned and built with dub on ubuntu 20.04. DMD version 2.097.0. Linked, no errors. Not sure if it helps you, but it is a data point. Any time I've had errors like that, I've just removed my ~/.dub directory, and the one in the project and it seems to help clear it up. Note that the linker error you are getting is from Phobos (you can use `ddemangle` command line tool to see the actual symbol name), so it seems like you could be compiling against one version of Phobos, and then linking against another? How do you install your compiler? I recommend [dvm](https://github.com/jacob-carlborg/dvm) if you are using dmd. -Steve
Aug 05 2021
next sibling parent Ki Rill <rill.ki yahoo.com> writes:
On Thursday, 5 August 2021 at 11:43:25 UTC, Steven Schveighoffer 
wrote:
 I git-cloned and built with dub on ubuntu 20.04. DMD version 
 2.097.0. Linked, no errors.

 Not sure if it helps you, but it is a data point.

 Any time I've had errors like that, I've just removed my ~/.dub 
 directory, and the one in the project and it seems to help 
 clear it up.
Unfortunately, removing ~/.dub and .dub in the project's folder did not help.
 Note that the linker error you are getting is from Phobos (you 
 can use `ddemangle` command line tool to see the actual symbol 
 name), so it seems like you could be compiling against one 
 version of Phobos, and then linking against another? How do you 
 install your compiler?
It is indeed from Phobos, it's the listdir function that is the source of the problem here. But I cannot understand why it's the problem. That function does compile on its own. It's when I put it together with GTKD it refuses to compile. Hmm...
 I recommend [dvm](https://github.com/jacob-carlborg/dvm) if you 
 are using dmd.
This is a wonderful thing! How come I didn't hear about it before this day...
Aug 05 2021
prev sibling parent reply Ki Rill <rill.ki yahoo.com> writes:
On Thursday, 5 August 2021 at 11:43:25 UTC, Steven Schveighoffer 
wrote:
 How do you install your compiler?

 -Steve
I installed dmd2.97.x using `brew`.
Aug 05 2021
parent reply Steven Schveighoffer <schveiguy gmail.com> writes:
On 8/5/21 9:57 AM, Ki Rill wrote:
 On Thursday, 5 August 2021 at 11:43:25 UTC, Steven Schveighoffer wrote:
 How do you install your compiler?
I installed dmd2.97.x using `brew`.
I would recommend downloading the binaries from the dlang.org page. I barely ever use homebrew on my mac, which means any time I want to use it, it takes hours to go through updates first! But downloading directly from dlang.org would at least be a sanity check. It might be a homebrew issue. -Steve
Aug 05 2021
parent Ki Rill <rill.ki yahoo.com> writes:
On Thursday, 5 August 2021 at 14:40:58 UTC, Steven Schveighoffer 
wrote:
 On 8/5/21 9:57 AM, Ki Rill wrote:
 On Thursday, 5 August 2021 at 11:43:25 UTC, Steven 
 Schveighoffer wrote:
 How do you install your compiler?
I installed dmd2.97.x using `brew`.
I would recommend downloading the binaries from the dlang.org page. I barely ever use homebrew on my mac, which means any time I want to use it, it takes hours to go through updates first! But downloading directly from dlang.org would at least be a sanity check. It might be a homebrew issue. -Steve
That solved it! It is indeed homebrew. Thank you!
Aug 05 2021