dub icon indicating copy to clipboard operation
dub copied to clipboard

Setting up multiple subpackages

Open alanondra opened this issue 11 months ago • 1 comments

I'm aiming to create a project with multiple sub-packages using Dub. This seems to work for the most part, except in the case of Linux, I need to manually set LD_LIBRARY_PATH in the command line since the compiled executables don't look in the current directory:

D_LIBRARY_PATH="$LD_LIBRARY_PATH:$(pwd)/build" ./build/app

Is there anything I need to change for that to work? Are there any best practices I need to more closely follow? I've pieced this together looking at some other issues here.


dub.json

{
	"name": "example",
	"targetType": "none",
	"dependencies": {
		"example:app": "*"
	},
	"subPackages": [
		"packages/common",
		"packages/app"
	]
}

packages/common/dub.json

{
	"name": "common",
	"targetType": "dynamicLibrary",
	"targetPath": "../../build"
}

packages/app/dub.json

{
	"name": "app",
	"targetType": "executable",
	"targetName": "app",
	"targetPath": "../../build",
	"dependencies": {
		"example:common": "*"
	}
}

alanondra avatar Mar 07 '25 03:03 alanondra

https://github.com/dlang/dub/pull/2718

rikkimax avatar Mar 07 '25 03:03 rikkimax