Thread overview
Is this dub link flag (-L-lcudart_static) a bug?
4 days ago
mw
15 hours ago
Matheus Catarino
2 hours ago
mw
14 hours ago
monkyyy
4 days ago

Hi,

With

$ dub --version
DUB version 1.39.0, built on Mar 20 2025
$ ldc2 --version
LDC - the LLVM D compiler (1.40.1):

dub.json:

"lflags": [
  ...
  "-L/usr/local/cuda/lib64",
  "-lcudart_static",
  ...
        ],

I got a link error: undefined reference to 'cudaGetDeviceProperties_v2'.

by adding --vverbose dub option, I found the final expanded link cmd is:

.../ldc2/bin/ldc2 ... -L-L/usr/local/cuda/lib64 -L-lcudart_static ...

This "-L-l" format does not look correct?

Then I changed the dub.json to :

"lflags": [
  ...
  /usr/local/cuda/lib64/libcudart_static.a
  ...
        ],

then it links correctly.

I'm just wondering if the dub expansion "-L-l" format is a bug? (but looks like this same expansion works for other libraries?)

Thanks.

15 hours ago

On Monday, 12 May 2025 at 15:03:00 UTC, mw wrote:

>

I got a link error: undefined reference to 'cudaGetDeviceProperties_v2'.

by adding --vverbose dub option, I found the final expanded link cmd is:

.../ldc2/bin/ldc2 ... -L-L/usr/local/cuda/lib64 -L-lcudart_static ...

This "-L-l" format does not look correct?

Then I changed the dub.json to :

"lflags": [
  ...
  /usr/local/cuda/lib64/libcudart_static.a
  ...
        ],

then it links correctly.

I'm just wondering if the dub expansion "-L-l" format is a bug? (but looks like this same expansion works for other libraries?)

Thanks.

In the dub libs:["mylibname_noext"] + lflags:["-L/Path/to/lib"]

In side: -L-L/path -L-lmylibname_noext.

If you need to pass a specific file (.o, .obj, .a, .lib) add in sourceFiles:["..."]

The problem presented shows that this library possibly has other dependencies.

Have you looked into the cuda community? I did a quick search and saw a similar problem involving cuda12.

Unfortunately, I've never tried anything involving cuda. Sorry if this doesn't answer properly.

14 hours ago

On Monday, 12 May 2025 at 15:03:00 UTC, mw wrote:

>

I'm just wondering if the dub expansion "-L-l" format is a bug?

No, its a silly thing of linkers being separate from compilers and blindly copying and pasting of cli arguments

2 hours ago

On Friday, 16 May 2025 at 17:44:01 UTC, Matheus Catarino wrote:

>

The problem presented shows that this library possibly has other dependencies.

That symbol is defined in that library .a file:

$ nm /usr/local/cuda/lib64/libcudart_static.a | grep -w cudaGetDeviceProperties_v2
0000000000042690 T cudaGetDeviceProperties_v2

That's why I'm wondering if it's a dub / linker bug somewhere.