Oscilloscope icon indicating copy to clipboard operation
Oscilloscope copied to clipboard

[Linux] Compilation fails due to non-declared flags

Open DJLevel3 opened this issue 4 years ago • 15 comments

I am compiling the latest version on Linux, and I was having compilation problems that I eventually tracked down to the version of make I was using. I have now downgraded to make 4.2.1, and compilation progresses further but still fails. The errors now seem to be in OsciVideoWriter.cpp. The three errors thrown are:

line 219: error: ‘CODEC_FLAG_GLOBAL_HEADER’ was not declared in this scope; did you mean ‘AV_CODEC_FLAG_GLOBAL_HEADER’?

line 427: error: ‘CODEC_FLAG_GLOBAL_HEADER’ was not declared in this scope; did you mean ‘AV_CODEC_FLAG_GLOBAL_HEADER’?

line 483: error: ‘AVFMT_RAWPICTURE’ was not declared in this scope

I have tried replacing the first two with the suggested replacements, and the errors disappeared, but the one on line 483 I cannot figure out how to fix.

DJLevel3 avatar Jan 26 '22 19:01 DJLevel3

Update: I found another application with this problem and their solution was to add sed -i '1s/^/#define AV_CODEC_FLAG_GLOBAL_HEADER (1 << 22)\n#define CODEC_FLAG_GLOBAL_HEADER AV_CODEC_FLAG_GLOBAL_HEADER\n#define AVFMT_RAWPICTURE 0x0020\n/' "$(OPENCV_BASENAME)/modules/highgui/src/cap_ffmpeg_impl.hpp" to their makefile. May be relevant.

DJLevel3 avatar Jan 26 '22 19:01 DJLevel3

Update 2: Adding these lines to OsciVideoWriter.cpp just below the ifndef seems to have fixed the problems. I'm now having different errors, so I'm leaving this open for now, but I've progressed!

#define CODEC_FLAG_GLOBAL_HEADER AV_CODEC_FLAG_GLOBAL_HEADER #define AVFMT_RAWPICTURE 0x0020

DJLevel3 avatar Jan 26 '22 20:01 DJLevel3

Aaaand, I seem to have fixed all the errors! To summarize what I did:

  • Add #define CODEC_FLAG_GLOBAL_HEADER AV_CODEC_FLAG_GLOBAL_HEADER and #define AVFMT_RAWPICTURE 0x0020 to OsciVideoWriter.hpp
  • Add #include <cstdio> to LaserdockDeviceManager.h

DJLevel3 avatar Jan 26 '22 20:01 DJLevel3

thanks for your findings! i haven't yet tried to build on linux. is this with a custom ffmpeg, or the system ffmpeg?

kritzikratzi avatar Jan 26 '22 20:01 kritzikratzi

I didn't supply any ffmpeg, so I believe it was the system one or the included one if that exists. By the way, the build completed, but audio files are now playing extremely quickly for some reason.

DJLevel3 avatar Jan 26 '22 20:01 DJLevel3

Scratch that, I just relaunched the application and it's working!

DJLevel3 avatar Jan 26 '22 20:01 DJLevel3

happy (and suprised) to hear this works with your ffmpeg version. i'm leaving this bug up open until i've made my own linux build uploaded it.

kritzikratzi avatar Jan 27 '22 10:01 kritzikratzi

I can send you the build I have completed if you have the stuff to test it. Should(tm) be working fine.

DJLevel3 avatar Jan 27 '22 16:01 DJLevel3

Or you can do it on WSL if you have a Windows PC.

DJLevel3 avatar Jan 27 '22 16:01 DJLevel3

I didn't supply any ffmpeg, so I believe it was the system one or the included one if that exists. By the way, the build completed, but audio files are now playing extremely quickly for some reason.

I just realized, I did the recursive clone as instructed in the Linux build instructions, so if ffmpeg is included there then I think it used that one.

DJLevel3 avatar Jan 27 '22 16:01 DJLevel3

only the heaeders are in the repo, but if you didn't take any extra steps there are no binaries.

kritzikratzi avatar Jan 28 '22 07:01 kritzikratzi

As far as I can tell the build doesn't work with ffmpeg 5, it says that AVStream doesn't have the member codec. I am not sure how to change the version of ffmpeg, other programs depend on it so i can't downgrade system-wide, and I am not sure how to make it use a different binary.

alexdaguy avatar Feb 27 '22 09:02 alexdaguy

here are the ffmpeg binaries i'm using: https://github.com/kritzikratzi/ofxAvCodec/releases/tag/0.3 they contain my own tiny patches to ffmpeg, and also the cisco openh264 libraries.

hope it helps. you'll have to google everything else, but LD_LIBRARY_PATH, rpath and patchelf are things you may or may not need :)

kritzikratzi avatar Feb 28 '22 21:02 kritzikratzi

ps. also: i was always against ffmpeg as a system wide dependency don't want to use ffmpeg as a system wide dependency, as i don't have the time to change my code every.

if you feel like biting the bullet please try a PR, i'd be happy to assist a bit :)

kritzikratzi avatar Feb 28 '22 21:02 kritzikratzi

PR in! Turns out I had some stuff totally wrong in how I was fixing it, retried with more accurate fixes and created a PR! There's also a PR out for ofxLiblaserdock and an issue out for ofxNative.

DJLevel3 avatar Aug 29 '22 21:08 DJLevel3