Thread overview
Request assistance resolving linker error: Undefined symbol(s) for architecture x86_64
Aug 03, 2022
anonymouse
Aug 03, 2022
H. S. Teoh
Aug 03, 2022
anonymouse
Aug 03, 2022
ryuukk_
Aug 03, 2022
anonymouse
August 03, 2022

How do I go about tracking down what's causing the following error:

Undefined symbols for architecture x86_64:
  "__D3std8internal6memory12__ModuleInfoZ", referenced from:
      __D3loxQe12__ModuleInfoZ in dlux.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I'm not explicitly calling anything in std.internal.memory so not sure how to resolve. Thanks.

--anonymouse

August 02, 2022
On Wed, Aug 03, 2022 at 04:28:57AM +0000, anonymouse via Digitalmars-d-learn wrote:
> How do I go about tracking down what's causing the following error:
> 
> ```
> Undefined symbols for architecture x86_64:
>   "__D3std8internal6memory12__ModuleInfoZ", referenced from:
>       __D3loxQe12__ModuleInfoZ in dlux.o
> ld: symbol(s) not found for architecture x86_64
> clang: error: linker command failed with exit code 1 (use -v to see
> invocation)
> ```
> 
> I'm not explicitly calling anything in std.internal.memory so not sure how to resolve. Thanks.
[...]

This is often a sign of version mismatch between libraries and compiler. Did you recently upgrade your compiler?  Did you accidentally install two versions of the standard library and the new compiler is mistakenly picking up the old library?

Maybe try also recompiling your project from clean slate just in case your build process is picking up stale binaries for whatever reason. If you have object files compiled with the old version of the compiler still lying around, and they get picked up when compiling with the new compiler, it would cause link errors like the above.


T

-- 
Winners never quit, quitters never win. But those who never quit AND never win are idiots.
August 03, 2022
On Wednesday, 3 August 2022 at 05:04:08 UTC, H. S. Teoh wrote:
> On Wed, Aug 03, 2022 at 04:28:57AM +0000, anonymouse via Digitalmars-d-learn wrote:
>> How do I go about tracking down what's causing the following error:
>> 
>> ```
>> Undefined symbols for architecture x86_64:
>>   "__D3std8internal6memory12__ModuleInfoZ", referenced from:
>>       __D3loxQe12__ModuleInfoZ in dlux.o
>> ld: symbol(s) not found for architecture x86_64
>> clang: error: linker command failed with exit code 1 (use -v to see
>> invocation)
>> ```
>> 
>> I'm not explicitly calling anything in std.internal.memory so not sure how to resolve. Thanks.
> [...]
>
> This is often a sign of version mismatch between libraries and compiler. Did you recently upgrade your compiler?  Did you accidentally install two versions of the standard library and the new compiler is mistakenly picking up the old library?

Interesting... no I only have one version of DMD installed on this
computer (v2.100.0) and it's never been updated.


> Maybe try also recompiling your project from clean slate just in case your build process is picking up stale binaries for whatever reason. If you have object files compiled with the old version of the compiler still lying around, and they get picked up when compiling with the new compiler, it would cause link errors like the above.

This project aims at learning how compilers work. I'm simply adapting Robert Nystrom's code from his book [Crafting Compiler](http://www.craftinginterpreters.com/scanning.html). The source tree currently looks like this:

```
lox
  |
  + lox.d
  |
  + main.d
  |
  + scanner.d
  |
  + token.d
  |
  + tokentype.d
```

My entire build process comprises issuing the command:
```
dmd -of=dlux lox/*
```

I've tried using -J, -I, and moving main to the current working directory but all these result in the same error.

--anonymouse

August 03, 2022
Does adding ```-m64``` work
August 03, 2022

On Wednesday, 3 August 2022 at 09:39:36 UTC, ryuukk_ wrote:

>

Does adding -m64 work

I'm using macOS so I don't think that applies. But no, it doesn't do anything for me.

Thanks,
--anonymouse