www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - ldc link error on new machine: undefined reference to

reply mw <mingwu gmail.com> writes:
Hi,

I switched to a different machine to build my project, suddenly I 
got lots of link errors. (It builds fine on the old machine, and 
my software version are the same on both machines LDC - the LLVM 
D compiler (1.32.2))

e.g.:
```
...
/usr/bin/ld: 
/home//.dub/cache/cachetools/0.3.1/build/library-unittest-linux.posix-x86_64-ldc_v1.32.2-71414BF132F687B008642EB263AC23264B21497EA1FEF7D8AFA169EDF7967ADF/libcachetools.a(cachetools.containers.hashmap.o):(.data.rel.ro._D10cachetools10containers7hashmap11KeyNot
ound6__vtblZ+0x48): undefined reference to
`_D6object9Throwable7messageMxFNbNfZAxa'
```

even manually specify
```
         "lflags-ldc": [
                 "-ldruntime-ldc"
         ],
```
does not solve the problem, while the symbol is there:

```
$ nm /project/ldc2/lib/libdruntime-ldc.a | grep 
_D6object9Throwable7messageMxFNbNfZAxa
                  U _D6object9Throwable7messageMxFNbNfZAxa
                  U _D6object9Throwable7messageMxFNbNfZAxa
                  U _D6object9Throwable7messageMxFNbNfZAxa
                  U _D6object9Throwable7messageMxFNbNfZAxa
                  U _D6object9Throwable7messageMxFNbNfZAxa
0000000000000000 T _D6object9Throwable7messageMxFNbNfZAxa
```

Anything else I should check?

Thanks.
Jun 14 2023
parent reply "H. S. Teoh" <hsteoh qfbox.info> writes:
On Thu, Jun 15, 2023 at 12:49:30AM +0000, mw via Digitalmars-d-learn wrote:
 Hi,
 
 I switched to a different machine to build my project, suddenly I got
 lots of link errors. (It builds fine on the old machine, and my
 software version are the same on both machines LDC - the LLVM D
 compiler (1.32.2))
Recently encountered a similar problem, ultimately the cause was that my library paths turned out to be wrongly set, so it was picking up the wrong version of the precompiled libraries. Probably you could check whether the library paths in ldc2.conf are set correctly, and also double-check whether the libraries at those paths are actually the correct ones for your compiler version (you may have installed the wrong libraries in the right paths). Mixing up libraries from different LDC releases tend to show up as link errors of this kind. T -- The computer is only a tool. Unfortunately, so is the user. -- Armaphine, K5
Jun 14 2023
parent mw <mingwu gmail.com> writes:
On Thursday, 15 June 2023 at 01:20:50 UTC, H. S. Teoh wrote:
 On Thu, Jun 15, 2023 at 12:49:30AM +0000, mw via 
 Digitalmars-d-learn wrote:
 Hi,
 
Recently encountered a similar problem, ultimately the cause was that my library paths turned out to be wrongly set, so it was picking up the wrong version of the precompiled libraries. Probably you could check whether the library paths in ldc2.conf are set correctly, and also double-check whether the libraries at those paths are actually the correct ones for your compiler version (you may have installed the wrong libraries in the right paths). Mixing up libraries from different LDC releases tend to show up as link errors of this kind.
Thanks for the tip, indeed it was caused by `ld` picking up the wrong lib (in a different sys path): ``` $ locate libdruntime-ldc (... my local LDC install) /usr/lib/x86_64-linux-gnu/libdruntime-ldc-debug-shared.so /usr/lib/x86_64-linux-gnu/libdruntime-ldc-debug-shared.so.2.0.98 /usr/lib/x86_64-linux-gnu/libdruntime-ldc-debug-shared.so.98 /usr/lib/x86_64-linux-gnu/libdruntime-ldc-debug.a /usr/lib/x86_64-linux-gnu/libdruntime-ldc-shared.so /usr/lib/x86_64-linux-gnu/libdruntime-ldc-shared.so.2.0.98 /usr/lib/x86_64-linux-gnu/libdruntime-ldc-shared.so.98 /usr/lib/x86_64-linux-gnu/libdruntime-ldc.a ``` while I'm using my local installed LDC. After removing the system installation, it worked.
Jun 14 2023