Opened 8 months ago

Last modified 8 months ago

#69522 assigned enhancement

mpv: Add libmpv

Reported by: gabrielzschmitz (Gabriel dos Santos Schmitz) Owned by: Ionic (Mihai Moldovan)
Priority: Normal Milestone:
Component: ports Version: 2.9.1
Keywords: Cc: i0ntempest
Port: mpv

Description (last modified by jmroot (Joshua Root))

Can't really include the mpv library at any .c file (even adding the +libmpv variant)! Here's a real exemple:

$ sudo make install
cc -std=c99 -Wall -Wextra -pedantic -Wunused-result -Wno-unused-variable -Os -D_POSIX_C_SOURCE -DTOMATONOISE=\"/usr/local/bin/tomatonoise\" -DLOGPREFIX=\".local/share/tomato\" -DLOGFILE=\".local/share/tomato/tomato.log\" -DTMPFILE=\".local/share/tomato/tmp.log\" -DTIMERFILE=\".local/share/tomato/time.log\" -DNOTEPADFILE=\".local/share/tomato/notepad.log\" -I/usr/local/include -L/usr/local/lib  tomatonoise.c  `pkg-config --libs ncursesw mpv` -o tomatonoise
tomatonoise.c:1:10: fatal error: 'mpv/client.h' file not found
#include <mpv/client.h>
         ^~~~~~~~~~~~~~
1 error generated.
make: *** [tomatonoise] Error 1
Error: Process completed with exit code 2.

Change History (6)

comment:1 Changed 8 months ago by jmroot (Joshua Root)

Cc: i0ntempest added
Description: modified (diff)
Keywords: libmpv library removed
Owner: set to Ionic
Priority: HighNormal
Status: newassigned

comment:2 Changed 8 months ago by ryandesign (Ryan Carsten Schmidt)

Summary: Problem to have acces to the libmpv in MacOsmpv: Add libmpv
Type: defectenhancement

As far as I can tell, the mpv port installs the mpv program, not a library. So this ticket is a request to add the libmpv library to the mpv port, or to create a libmpv subport. The Portfile currently specifies -Dlibmpv=false so presumably the library could be built by changing that to -Dlibmpv=true but I haven't tried it.

I see that your Makefile has used the flags -I/usr/local/include -L/usr/local/lib. MacPorts doesn't install things in /usr/local; it installs them in /opt/local. If the mpv port installed a library, which it doesn't, you'd need to change those flags to -I/opt/local/include -L/opt/local/lib to find it. You'd need to consult your Makefile for information on how to do that. Or I see that the Makefile tries to use pkg-config to find libmpv; that may be enough, assuming the revised mpv or libmpv port installs a working .pc file.

comment:3 Changed 8 months ago by i0ntempest

If +libmpv variant is specified then /opt/local/lib/libmpv.2.dylib and /opt/local/include/mpv/client.h will be present. So yea most likely you do not have the correct include flags as Ryan said.

comment:4 Changed 8 months ago by ryandesign (Ryan Carsten Schmidt)

Oh, I didn't notice that there is a +libmpv variant.

A variant is not a good way to provide a library because other ports cannot depend on it. Either enable the library always, or better yet make it a subport.

comment:5 in reply to:  3 Changed 8 months ago by ryandesign (Ryan Carsten Schmidt)

Replying to i0ntempest:

If +libmpv variant is specified then /opt/local/lib/libmpv.2.dylib and /opt/local/include/mpv/client.h will be present. So yea most likely you do not have the correct include flags as Ryan said.

I've checked and mpv +libmpv does install mpv.pc which should be sufficient for adding the right flags.

Gabriel, re-checking the command you used, you only used pkg-config --libs ncursesw mpv which will give you the correct library (-L and -l) flags but not the correct compiler (-I) flags. To get those, you also need pkg-config --cflags ncursesw mpv, or get both at once with pkg-config --cflags --libs ncursesw mpv.

Your Makefile seems to be doing both compilation and linking at once, so you need both sets of flags. Normally compilation and linking are done separately, so you'd give the compiler flags when compiling and the library flags when linking.

comment:6 in reply to:  4 Changed 8 months ago by i0ntempest

Replying to ryandesign:

A variant is not a good way to provide a library because other ports cannot depend on it. Either enable the library always, or better yet make it a subport.

Good point, though mpv has so many variants that adding a subport just for the library is kind of hard. I don't know if there's a way to build the library only, worst case I might need to manually delete some stuff after destroot.

Note: See TracTickets for help on using tickets.