www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - How to setup dub project for contributing to a dub package?

reply Ki Rill <rill.ki yahoo.com> writes:
Recently, I tried to set up `dcv` with `dub` to improve a few 
things in the library, but I faced some strange issues.

When doing `dub add dcv`, it works fine. But when I try to add a 
local dcv project folder, or a repository, it fails to link the 
necessary package libraries. Seems like it's only `ffmpeg` 
libraries that are not linked.

What am I missing here?

```
// dub.json

...

"dependencies": {
     "dcv": {
         "repository": "git+https://github.com/rillki/dcv.git",
         "version": "~master"
     }
},

...
```

Output:
```
Undefined symbols for architecture x86_64:
   "_av_free_packet", referenced from:
       
__D3dcv7videoio5input11InputStream13readFrameImplMFNbNiKCQCc4core5image5ImageZb
in libdcv.a(input_2c65_47c.o)
       
__D3dcv7videoio6output12OutputStream__T10writeSliceTS3mir7ndslice5slice__T9mir_sliceTPhVmi2VEQBoQBnQBi14mir_slice_kindi2ZQBvZQDiMFNbNiQDeEQFf4core5
mage11ImageFormatZb in libdcv.a(output_2c76_14e7.o)
       
__D3dcv7videoio6output12OutputStream__T10writeSliceTS3mir7ndslice5slice__T9mir_sliceTPhVmi3VEQBoQBnQBi14mir_slice_kindi2ZQBvZQDiMFNbNiQDeEQFf4core5
mage11ImageFormatZb in libdcv.a(output_2c74_14e8.o)
   "_av_register_all", referenced from:
       __D3dcv7videoio6common9AVStarter6__ctorMFNbNiZCQBsQBrQBmQBi 
in libdcv.a(common_2c56_37c.o)
   "_avcodec_decode_video2", referenced from:

       ETC....

ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to 
see invocation)
Error: linker exited with status 1
Error dmd failed with exit code 1.
```
Jun 23 2023
next sibling parent reply "Richard (Rikki) Andrew Cattermole" <richard cattermole.co.nz> writes:
First things first, dcv is added to the dub-registry, so use this.

https://code.dlang.org/packages/dcv

```json
"dependencies": {
	"dcv": "~>0.3.0"
}
```

For ffmpeg the binding tells you what to add for search paths in the 
lflags directive.

https://github.com/ljubobratovicrelja/ffmpeg-d#adding-to-dub

All I can suggest is make sure you have the right dev packages for 
ffmpeg installed and findable by the linker.
Jun 23 2023
next sibling parent reply Ki Rill <rill.ki yahoo.com> writes:
On Friday, 23 June 2023 at 15:52:44 UTC, Richard (Rikki) Andrew 
Cattermole wrote:
 First things first, dcv is added to the dub-registry, so use 
 this.

 https://code.dlang.org/packages/dcv

 ```json
 "dependencies": {
 	"dcv": "~>0.3.0"
 }
 ```

 For ffmpeg the binding tells you what to add for search paths 
 in the lflags directive.

 https://github.com/ljubobratovicrelja/ffmpeg-d#adding-to-dub

 All I can suggest is make sure you have the right dev packages 
 for ffmpeg installed and findable by the linker.
It works fine if I add it as a `dub` package, but I want to add the repository so I can modify it, then test it on a new project, and make a PR that improves the package. How do people usually set up their projects for such tasks?
Jun 23 2023
parent Steven Schveighoffer <schveiguy gmail.com> writes:
On 6/23/23 8:23 PM, Ki Rill wrote:

 It works fine if I add it as a `dub` package, but I want to add the 
 repository so I can modify it, then test it on a new project, and make a 
 PR that improves the package.
 
 How do people usually set up their projects for such tasks?
1. git clone to a local directory (use your fork, so you can change and submit when you want to do a PR) 2. CD to that directory 3. `dub add-local .` Now it will use the local directory as the equivalent of the latest tag instead of downloading from the repository. You may have to `dub upgrade` your project that depends on it, or temporarily depend on a different version. -Steve
Jun 23 2023
prev sibling parent Ferhat =?UTF-8?B?S3VydHVsbXXFnw==?= <aferust gmail.com> writes:
On Friday, 23 June 2023 at 15:52:44 UTC, Richard (Rikki) Andrew 
Cattermole wrote:
 First things first, dcv is added to the dub-registry, so use 
 this.

 https://code.dlang.org/packages/dcv

 ```json
 "dependencies": {
 	"dcv": "~>0.3.0"
 }
 ```

 For ffmpeg the binding tells you what to add for search paths 
 in the lflags directive.

 https://github.com/ljubobratovicrelja/ffmpeg-d#adding-to-dub

 All I can suggest is make sure you have the right dev packages 
 for ffmpeg installed and findable by the linker.
Just to make things clear, I don't recommend to use DCV from dub registry, it's outdated. I have an opinion that the docs should be updated before creating a new version updating the dub repo. There are so many API changes between the last dub repo version and the master repo. I don't know if I will find time and motivation anytime soon. I doubt someone else will do it too (it is a huge welcome though).
Jun 24 2023
prev sibling parent Ferhat =?UTF-8?B?S3VydHVsbXXFnw==?= <aferust gmail.com> writes:
On Friday, 23 June 2023 at 15:22:33 UTC, Ki Rill wrote:
 Recently, I tried to set up `dcv` with `dub` to improve a few 
 things in the library, but I faced some strange issues.

 [...]
I recommend adding DCV sub packages separately. Don't add the entire thing to your dub dependencies. Just only add what you need. Ffmpeg-d in only needed for DCV videoing. You can add subpacks like: "dependencies": { "dcv:core": ..., "dcv:plot": {"path": "../../"}, "dcv:imageio": {"path": "../../"}, "mir-random": "*" }
Jun 24 2023