Bug 188621

Summary: Cannot build net/opal when multimedia/ffmpeg is installed
Product: Ports & Packages Reporter: Matthieu Volat <mazhe>
Component: Individual Port(s)Assignee: freebsd-gnome (Nobody) <gnome>
Status: Closed Feedback Timeout    
Severity: Affects Only Me CC: kwm, miwi
Priority: Normal    
Version: Latest   
Hardware: Any   
OS: Any   

Description Matthieu Volat 2014-04-14 18:00:00 UTC
Hi,

When installed on a system where multimedia/ffmpeg is installed, net/opal will (rightly) pull multimedia/ffmpeg0 as a dependency, but will still mix up header files and build will fail :

[CC] rfc2190.cxx
In file included from In file included from rfc2429.cxx:23:
In file included from ./rfc2429.h:26:
./h263-1998.h:118:23: error: unknown type name 'CodecID'; did you mean
      'AVCodecID'?
    virtual bool Init(CodecID codecId);
                      ^~~~~~~
                      AVCodecID
/usr/local/include/libavcodec/avcodec.h:102:6: note: 'AVCodecID' declared here
enum AVCodecID {
     ^
rfc2190.cxx:22:
In file included from h263-1998.cxx:50:
./h263-1998.h:118:23: error: unknown type name 'CodecID'; did you mean
      'AVCodecID'?
    virtual bool Init(CodecID codecId);
                      ^~~~~~~
                      AVCodecID
/usr/local/include/libavcodec/avcodec.h:102:6: note: 'AVCodecID' declared here
enum AVCodecID {
     ^
In file included from ./rfc2190.h:25:
./h263-1998.h:118:23: error: unknown type name 'CodecID'; did you mean
      'AVCodecID'?
    virtual bool Init(CodecID codecId);
                      ^~~~~~~
                      AVCodecID
/usr/local/include/libavcodec/avcodec.h:102:6: note: 'AVCodecID' declared here
enum AVCodecID {
     ^
[CC] .common/dyna.cxx
rfc2190.cxx:181:7: warning: add explicit braces to avoid dangling else
      [-Wdangling-else]
      PTRACE(2, "RFC2190", "Mismatch between encoder length (" << newLe...
      ^
/usr/ports/net/opal/work/opal-3.10.10/include/codec/opalplugin.hpp:91:9: note: 
      expanded from macro 'PTRACE'
      } else (void)0
        ^
In file included from h263-1998.cxx:58:
./../common/dyna.h:91:19: error: unknown type name 'CodecID'; did you mean
      'AVCodecID'?
    FFMPEGLibrary(CodecID codec);
                  ^~~~~~~
rfc2429.cxx:512:9: warning: add explicit braces to avoid dangling else
      [-Wdangling-else]
        PTRACE(6, "H.263-RFC2429", "Header\tRLNUM: " << headerBits.GetBits(4));
        ^
/usr/ports/net/opal/work/opal-3.10.10/include/codec/opalplugin.hpp:91:9: note: 
      expanded from macro 'PTRACE'
      } else (void)0
        ^
                  AVCodecID
/usr/local/include/libavcodec/avcodec.h:102:6: note: 'AVCodecID' declared here
enum AVCodecID {
     ^
In file included from h263-1998.cxx:58:
./../common/dyna.h:96:38: error: ISO C++ forbids forward references to 'enum'
      types
    AVCodec *AvcodecFindEncoder(enum CodecID id);
                                     ^
./../common/dyna.h:120:13: error: field has incomplete type 'CodecID'
    CodecID m_codec;
            ^
./../common/dyna.h:96:38: note: forward declaration of 'CodecID'
    AVCodec *AvcodecFindEncoder(enum CodecID id);
                                     ^
rfc2429.cxx:539:5: warning: add 1 warning and 1 error generated.
explicit braces to avoid dangling else
      [-Wdangling-else]
    PTRACE(6, "H.263-RFC2429", "Header\tTRB: " << headerBits.GetBits (3...
    ^
/usr/ports/net/opal/work/opal-3.10.10/include/codec/opalplugin.hpp:91:9: note: 
      expanded from macro 'PTRACE'
      } else (void)0
        ^
gmake[7]: *** [/usr/ports/net/opal/work/opal-3.10.10/plugins/../lib_FreeBSD_amd64/plugins/h263_ffmpeg/rfc2190.o] Error 1
gmake[7]: *** Waiting for unfinished jobs....
In file included from ../common/dyna.cxx:40:
./common/dyna.h:91:19: error: unknown type name 'CodecID'; did you mean
      'AVCodecID'?
    FFMPEGLibrary(CodecID codec);
                  ^~~~~~~
                  AVCodecID
/usr/local/include/libavcodec/avcodec.h:102:6: note: 'AVCodecID' declared here
enum AVCodecID {
     ^
In file included from ../common/dyna.cxx:40:
./common/dyna.h:96:38: error: ISO C++ forbids forward references to 'enum'
      types
    AVCodec *AvcodecFindEncoder(enum CodecID id);
                                     ^
./common/dyna.h:120:13: error: field has incomplete type 'CodecID'
    CodecID m_codec;
            ^
./common/dyna.h:96:38: note: forward declaration of 'CodecID'
    AVCodec *AvcodecFindEncoder(enum CodecID id);
                                     ^
./common/dyna.cxx:179:38: warning: unused parameter 'avcl' [-Wunused-parameter]
static void logCallbackFFMPEG(void * avcl, int severity, const char* fm...
                                     ^
./common/dyna.cxx:213:16: error: out-of-line definition of 'FFMPEGLibrary' does
      not match any declaration in 'FFMPEGLibrary'
FFMPEGLibrary::FFMPEGLibrary(CodecID codec)
               ^~~~~~~~~~~~~
./common/dyna.cxx:213:38: error: variable has incomplete type 'CodecID'
FFMPEGLibrary::FFMPEGLibrary(CodecID codec)
                                     ^
./common/dyna.h:96:38: note: forward declaration of 'CodecID'
    AVCodec *AvcodecFindEncoder(enum CodecID id);
                                     ^
h263-1998.cxx:206:32: error: out-of-line definition of 'Init' does not match any
      declaration in 'H263_Base_EncoderContext'
bool H263_Base_EncoderContext::Init(CodecID codecId)
                               ^~~~
h263-1998.cxx:206:45: error: variable has incomplete type 'CodecID'
bool H263_Base_EncoderContext::Init(CodecID codecId)
                                            ^
./../common/dyna.h:96:38: note: forward declaration of 'CodecID'
    AVCodec *AvcodecFindEncoder(enum CodecID id);
                                     ^
2 warnings and 1 error generated.
gmake[7]: *** [/usr/ports/net/opal/work/opal-3.10.10/plugins/../lib_FreeBSD_amd64/plugins/h263_ffmpeg/rfc2429.o] Error 1
./common/dyna.cxx:351:57: error: variable has incomplete type 'enum CodecID'
AVCodec *FFMPEGLibrary::AvcodecFindEncoder(enum CodecID id)
                                                        ^
./common/dyna.h:96:38: note: forward declaration of 'CodecID'
    AVCodec *AvcodecFindEncoder(enum CodecID id);
                                     ^
./common/dyna.cxx:351:57: warning: unused parameter 'id' [-Wunused-parameter]
AVCodec *FFMPEGLibrary::AvcodecFindEncoder(enum CodecID id)
                                                        ^
./common/dyna.cxx:356:57: error: variable has incomplete type 'enum CodecID'
AVCodec *FFMPEGLibrary::AvcodecFindDecoder(enum CodecID id)
                                                        ^
./common/dyna.h:96:38: note: forward declaration of 'CodecID'
    AVCodec *AvcodecFindEncoder(enum CodecID id);
                                     ^
./common/dyna.cxx:356:57: warning: unused parameter 'id' [-Wunused-parameter]
AVCodec *FFMPEGLibrary::AvcodecFindDecoder(enum CodecID id)
                                                        ^
h263-1998.cxx:320:27: error: use of undeclared identifier 'CODEC_FLAG_H263P_UMV'
      m_context->flags |= CODEC_FLAG_H263P_UMV; 
                          ^
h263-1998.cxx:322:28: error: use of undeclared identifier 'CODEC_FLAG_H263P_UMV'
      m_context->flags &= ~CODEC_FLAG_H263P_UMV; 
                           ^
3 warnings and 7 errors generated.
gmake[7]: *** [/usr/ports/net/opal/work/opal-3.10.10/plugins/../lib_FreeBSD_amd64/plugins/h263_ffmpeg/dyna.o] Error 1
h263-1998.cxx:363:27: error: use of undeclared identifier
      'CODEC_FLAG_H263P_SLICE_STRUCT'
      m_context->flags |= CODEC_FLAG_H263P_SLICE_STRUCT; 
                          ^
h263-1998.cxx:365:28: error: use of undeclared identifier
      'CODEC_FLAG_H263P_SLICE_STRUCT'
      m_context->flags &= ~CODEC_FLAG_H263P_SLICE_STRUCT; 
                           ^
h263-1998.cxx:373:27: error: use of undeclared identifier 'CODEC_FLAG_H263P_AIV'
      m_context->flags |= CODEC_FLAG_H263P_AIV; 
                          ^
h263-1998.cxx:375:28: error: use of undeclared identifier 'CODEC_FLAG_H263P_AIV'
      m_context->flags &= ~CODEC_FLAG_H263P_AIV; 
                           ^
h263-1998.cxx:455:29: error: use of undeclared identifier 'CODEC_FLAG_H263P_UMV'
  CODEC_TRACER_FLAG(tracer, CODEC_FLAG_H263P_UMV);
                            ^
h263-1998.cxx:454:62: note: expanded from macro 'CODEC_TRACER_FLAG'
    PTRACE(4, m_prefix, #flag " is " << ((m_context->flags & flag) ? "enable...
                                                             ^
/usr/ports/net/opal/work/opal-3.10.10/include/codec/opalplugin.hpp:89:42: note: 
      expanded from macro 'PTRACE'
        std::ostringstream strm; strm << args; \
                                         ^
h263-1998.cxx:456:29: error: use of undeclared identifier 'CODEC_FLAG_OBMC'
  CODEC_TRACER_FLAG(tracer, CODEC_FLAG_OBMC);
                            ^
h263-1998.cxx:454:62: note: expanded from macro 'CODEC_TRACER_FLAG'
    PTRACE(4, m_prefix, #flag " is " << ((m_context->flags & flag) ? "enable...
                                                             ^
/usr/ports/net/opal/work/opal-3.10.10/include/codec/opalplugin.hpp:89:42: note: 
      expanded from macro 'PTRACE'
        std::ostringstream strm; strm << args; \
                                         ^
h263-1998.cxx:458:29: error: use of undeclared identifier
      'CODEC_FLAG_H263P_SLICE_STRUCT'
  CODEC_TRACER_FLAG(tracer, CODEC_FLAG_H263P_SLICE_STRUCT)
                            ^
h263-1998.cxx:454:62: note: expanded from macro 'CODEC_TRACER_FLAG'
    PTRACE(4, m_prefix, #flag " is " << ((m_context->flags & flag) ? "enable...
                                                             ^
/usr/ports/net/opal/work/opal-3.10.10/include/codec/opalplugin.hpp:89:42: note: 
      expanded from macro 'PTRACE'
        std::ostringstream strm; strm << args; \
                                         ^
h263-1998.cxx:460:29: error: use of undeclared identifier 'CODEC_FLAG_H263P_AIV'
  CODEC_TRACER_FLAG(tracer, CODEC_FLAG_H263P_AIV);
                            ^
h263-1998.cxx:454:62: note: expanded from macro 'CODEC_TRACER_FLAG'
    PTRACE(4, m_prefix, #flag " is " << ((m_context->flags & flag) ? "enable...
                                                             ^
/usr/ports/net/opal/work/opal-3.10.10/include/codec/opalplugin.hpp:89:42: note: 
      expanded from macro 'PTRACE'
        std::ostringstream strm; strm << args; \
                                         ^
h263-1998.cxx:524:72: error: use of undeclared identifier 'FF_I_TYPE'
  ...= (flags & PluginCodec_CoderForceIFrame) ? FF_I_TYPE : AV_PICTURE_TYPE_N...
                                                ^
h263-1998.cxx:606:24: error: use of undeclared identifier 'CODEC_FLAG_H263P_UMV'
  m_context->flags &= ~CODEC_FLAG_H263P_UMV;
                       ^
h263-1998.cxx:611:24: error: use of undeclared identifier 'CODEC_FLAG_H263P_AIV'
  m_context->flags &= ~CODEC_FLAG_H263P_AIV;
                       ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
gmake[7]: *** [/usr/ports/net/opal/work/opal-3.10.10/plugins/../lib_FreeBSD_amd64/plugins/h263_ffmpeg/h263-1998.o] Error 1
gmake[7]: Leaving directory `/usr/ports/net/opal/work/opal-3.10.10/plugins/video/H.263-1998'
gmake[6]: *** [all] Error 2
gmake[6]: Leaving directory `/usr/ports/net/opal/work/opal-3.10.10/plugins'
gmake[5]: *** [subdirs] Error 2
gmake[5]: Leaving directory `/usr/ports/net/opal/work/opal-3.10.10'
gmake[4]: *** [opt] Error 2
gmake[4]: Leaving directory `/usr/ports/net/opal/work/opal-3.10.10'
===> Compilation failed unexpectedly.
Try to set MAKE_JOBS_UNSAFE=yes and rebuild before reporting the failure to
the maintainer.
*** Error code 1

Stop.
make[3]: stopped in /usr/ports/net/opal
*** Error code 1

Stop.
make[2]: stopped in /usr/ports/net/opal
*** Error code 1

Stop.
make[1]: stopped in /usr/ports/net-im/ekiga
*** Error code 1

Stop.
make: stopped in /usr/ports/net-im/ekiga

Fix: 

Not trivial: I think the best way would be to patch files including ffmpeg headers to use the ffmpeg0 prefix before libav*.h

Another way would be to ensure -I${LOCALBASE}/include/ffmpeg0 is prepended before any other flag, but given the complexity of the build system, I'm not sure it is feasible...
How-To-Repeat: On a system without net/opal:
1. Install multimedia/ffmpeg
2. Check that opal build will have the FFMPEG and X.264 options
3. make build
Comment 1 Edwin Groothuis freebsd_committer freebsd_triage 2014-04-14 18:00:07 UTC
Responsible Changed
From-To: freebsd-ports-bugs->gnome

Over to maintainer (via the GNATS Auto Assign Tool)
Comment 2 Koop Mast freebsd_committer freebsd_triage 2014-06-02 20:40:49 UTC
Can't reproduce this with the following ffmpeg versions installed. Both ffmpeg and opal have default options.

> pkg info | grep ffmpeg
ffmpeg-2.1.1_4,1               Realtime audio/video encoder/converter and streaming server
ffmpeg0-0.7.16_2,1             Realtime audio/video encoder/converter and streaming server

Do you have any custom options enabled?
Comment 3 Matthieu Volat 2014-06-04 18:13:03 UTC
No specific option, I ran the rmconfig target and try to rebuild opal with strict defaults, with the same result.

I checked then with CFLAGS/CXXFLAGS commented in my make.conf, and the issue disappeared. Then I put
CFLAGS=
CXXFLAGS=
in my make.conf and the issue came back. I narrowed the problem to having a CXXFLAGS definition in /etc/make.conf (CFLAGS can be defined).

I tried to see if commenting the CXXFLAGS expansion in the Makefile would solve the problem, but it did not work. At this point, I'm not sure what is happening...