mpv-player / mpv-build

🔨 Helper scripts to compile mpv on Linux
http://mpv.io
414 stars 108 forks source link

Add extra CFlags and LDFlags to mpv #132

Closed Cqoicebordel closed 1 year ago

Cqoicebordel commented 4 years ago

I'm sure there is an easy solution to my problem, but didn't succeed to finding it, so here I am.

I tried to build ffmpeg with --enable-libnpp, to take advantage of HWA, and everything went fine. I already had --extra-cflags=-I/usr/local/cuda/include and --extra-ldflags=-L/usr/local/cuda/lib64 to take care of CUDA/NVENC/CUVID. So ffmpeg built without any issue.

So, here come the mpv part (for the record, I have --enable-dvdnav --enable-cdda --enable-dvbin --disable-libarchive for mpv). The configure goes fine. The compile too. And, you see it coming, I'm sure, there is an issue during the linking.

[260/261] Linking build/mpv
/usr/bin/ld : cannot find -lnppig
/usr/bin/ld : cannot find -lnppicc
/usr/bin/ld : cannot find -lnppc
/usr/bin/ld : cannot find -lnppidei
collect2: error: ld returned 1 exit status

I tried to add the same --extra-cflags and --extra-ldflags as for ffmpeg => error I tried adding --libdir => error I tried fucking with waf, but didn't succeed.

Finally, I just executed scripts/mpv-build -v, took the array displayed, s/', '/ / it, added the -L ldflag at the right spot, and the linking with cc worked.

So, my questions/features requests are :

  1. Is there a way to cleanly add the CFlags and LDFlags for mpv ?
  2. If not, could it be added ?
  3. And bonus, could it be inherited from the ffmpeg_options ?

Thanks ! :)

ghost commented 4 years ago

I think waf expects CFLAGS as environment variables when invoking was configure.

Cqoicebordel commented 4 years ago

Ah, maybe. I tested only in front of the "./rebuild -j4" command.

No. Doesn't work. Added export CFLAGS="-I/usr/local/cuda/include -L/usr/local/cuda/lib64"; in front of waf configure in scripts/mpv-configure, same error message at linking time.

sfan5 commented 4 years ago

Any -L... flags will need to be in LDFLAGS or they won't have any effect.

Cqoicebordel commented 4 years ago

Thanks ! That worked ! I added export CFLAGS="-I/usr/local/cuda/include";export LDFLAGS="-L/usr/local/cuda/lib64"; before the waf configure, and it worked ! Tried also higher, in ./build, before script/mpv-config worked there also !

Having a way to do this without touching any of the scripts would be ideal though :)

In any case, thanks again !

Dudemanguy commented 1 year ago

Old but you could use meson's arguments (c_args, c_link_args, etc.) if you prefer those over the environment variables.