dub icon indicating copy to clipboard operation
dub copied to clipboard

Support for library search paths

Open rtbo opened this issue 7 years ago • 4 comments

These are linker specific settings:

    "lflags-posix": [ "-L/a/path" ],
    "lflags-windows": [ "/LIBPATH:A:/Path" ],

The specificity could be abstracted away by Dub. Specified paths have few chances to be the same, so the support would be of seldom use today, but #1448 can boost the need for this feature.

rtbo avatar Apr 17 '18 21:04 rtbo

I'm not sure what exactly you are suggesting ? Abstracting away lflags between Windows and POSIX is near impossible, as there is no proper mechanism for sharing DLLs on Windows (most libs just ship the DLLs they need). On POSIX, dub supports pkg-config, which seems like the best way to go.

Geod24 avatar Dec 27 '19 02:12 Geod24

Okay, I've had to make things cross platform between Mac, Linux and Windows, and I understand this issue better now. What I ended up going with, to avoid hard-coding too much platform (and machine) specific information into the dub.json is requiring that the library path is in LIB. I can see a case where you want to abstract that, e.g. d2sqlite distribute the binary (https://github.com/biozic/d2sqlite3/tree/master/lib).

Geod24 avatar Apr 04 '20 05:04 Geod24

Related: I had the problem of dub generate visuald not propagating /LIBPATH defined in "lflags" to VS. I discovered that link libraries can actually be supplied including their path. So, instead of

"libs": [ "mylib" ]

you can do

"libs": [ "$PACKAGE_DIR/mylib" ]

which solves that problem.

veelo avatar Jun 18 '20 07:06 veelo

I would suggest also that dub itself supports a command line switch to add library search paths.

It's common that a necessary 3rd party binary library be installed not via the normal package manager of the system, and so people put them in whatever location they like. It doesn't make sense for these kinds of things to have to go into the dub file.

I believe all Posix linkers use the same argument format, but I don't know about windows.

schveiguy avatar May 28 '21 15:05 schveiguy