Results 1 to 11 of 11

Thread: Undefined Reference for 1 of many constructors for QVideoFrame

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2013
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Undefined Reference for 1 of many constructors for QVideoFrame

    I've come across a weird issue while trying to convert an FFMPeg AVFrame to a QT QVideoFrame;

    I'm trying to create the QVideoFrame using this constructor

    Qt Code:
    1. QVideoFrame(int bytes, const QSize &size, int bytesPerLine, PixelFormat format);
    To copy to clipboard, switch view to plain text mode 
    It compiles fine, however at link I receive the issue;

    Qt Code:
    1. ~myfile.cpp:130: undefined reference to `_imp___ZN11QVideoFrameC1EiRK5QSizeiNS_13AVPixelFormatE'
    2. collect2.exe: error: ld returned 1 exit status
    To copy to clipboard, switch view to plain text mode 
    (As it's a linker issue, I'm presuming you won't want code examples).

    I've compiled QT 4.8.5 myself using mingw32 and the other constructors (no params and QImage param) for QVideoFrame that I've tested compile and link correctly. From looking at the QT sources there is nothing that stands out as different for this constructor for it to not be included in the library.

    At this point I'm trying to implement an extension of QAbstractVideoBuffer so I can use that constructor, however that's proving harder than it should be & I'd love to understand why this issue is occurring.

    Thanks

    I'm really stumped with this so I've also got it on StackOverflow at the moment.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Undefined Reference for 1 of many constructors for QVideoFrame

    Does your PRO file contain:
    Qt Code:
    1. QT += multimedia
    To copy to clipboard, switch view to plain text mode 
    and have you run qmake since adding that line?

  3. #3
    Join Date
    Nov 2013
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Undefined Reference for 1 of many constructors for QVideoFrame

    Quote Originally Posted by ChrisW67 View Post
    Does your PRO file contain:
    Qt Code:
    1. QT += multimedia
    To copy to clipboard, switch view to plain text mode 
    and have you run qmake since adding that line?
    Yes, otherwise it wouldn't compile and link when I use the other constructors for QVideoFrame.

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Undefined Reference for 1 of many constructors for QVideoFrame

    People are quite good at stuffing about until something compiles, i.e. by using full paths in #include or settings INCLUDEPATH, and then failing at link because of a lack of understanding. They are also good as giving a description of the problem that is coloured by their assumptions. I like to look for the obvious before looking for the not obvious.

    Your assessment of the QVideoFrame sources certainly imply that the constructor is both public and, by virtue of the class, exported. The message seems consistent with the symbol either not being present or not being exported. There does not seem to be a way for the implementation to have been pre-processed out.

    Is there any chance the linker is picking up a very old Qt4 library? (It's a long shot).

    If your MinGW tool chain has the "nm" command, does the output of:
    Qt Code:
    1. nm -D \path\to\QtMultimedia4.dll
    To copy to clipboard, switch view to plain text mode 
    contain "_ZN11QVideoFrameC1EiRK5QSizeiNS_13AVPixelFormatE" ?
    Edit: Just checked, and there are no symbols visible through nm in my off-the-shelf Qt 4.8.4
    Last edited by ChrisW67; 25th November 2013 at 04:16.

  5. #5
    Join Date
    Nov 2013
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Undefined Reference for 1 of many constructors for QVideoFrame

    Quote Originally Posted by ChrisW67 View Post
    People are quite good at stuffing about until something compiles, i.e. by using full paths in #include or settings INCLUDEPATH, and then failing at link because of a lack of understanding. They are also good as giving a description of the problem that is coloured by their assumptions. I like to look for the obvious before looking for the not obvious.

    Your assessment of the QVideoFrame sources certainly imply that the constructor is both public and, by virtue of the class, exported. The message seems consistent with the symbol either not being present or not being exported. There does not seem to be a way for the implementation to have been pre-processed out.

    Is there any chance the linker is picking up a very old Qt4 library? (It's a long shot).

    If your MinGW tool chain has the "nm" command, does the output of:
    Qt Code:
    1. nm -D \path\to\QtMultimedia4.dll
    To copy to clipboard, switch view to plain text mode 
    contain "_ZN11QVideoFrameC1EiRK5QSizeiNS_13AVPixelFormatE" ?
    Edit: Just checked, and there are no symbols visible through nm in my off-the-shelf Qt 4.8.4
    I also receive no symbols when running that command on my QtMultimedia.dll.

    I'm pretty confident that I am not compiling/linking to the wrong QT, as previously I was developing under Visual Studio until I ran into some ffmpeg incompatibilities, so this is the only copy of Mingw compiled QT I have around.

    With regard to whether the function is not exported;
    Qt Code:
    1. QVideoFrame();
    2. QVideoFrame(QAbstractVideoBuffer *buffer, const QSize &size, PixelFormat format);
    3. QVideoFrame(int bytes, const QSize &size, int bytesPerLine, PixelFormat format); //This one
    4. QVideoFrame(const QImage &image);
    5. QVideoFrame(const QVideoFrame &other);
    6. ~QVideoFrame();
    To copy to clipboard, switch view to plain text mode 
    That is from qvideoframe.h, and the constructor I desire is declared no different to those that work, so I can't see why it would not be exported. Perhaps you know of the necessary configure parameters to make exports visible?/not name mangled?
    Last edited by robadob; 25th November 2013 at 08:25.

  6. #6
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Undefined Reference for 1 of many constructors for QVideoFrame

    QVideoFrame(int bytes, const QSize &size, int bytesPerLine, PixelFormat format);
    Is this how you are creating the object ?
    It mereley says you are declaring a function QVideoFrame with given parameters. May be thats why you are getting the linking error since it cannot find the implementation of the function.

    I guess it should be something like -
    Qt Code:
    1. QVideoFrame vf(bytes, size, bytesPerLine, format);
    To copy to clipboard, switch view to plain text mode 

  7. #7
    Join Date
    Nov 2013
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Undefined Reference for 1 of many constructors for QVideoFrame

    Quote Originally Posted by aamer4yu View Post
    Is this how you are creating the object ?
    It mereley says you are declaring a function QVideoFrame with given parameters. May be thats why you are getting the linking error since it cannot find the implementation of the function.

    I guess it should be something like -
    Qt Code:
    1. QVideoFrame vf(bytes, size, bytesPerLine, format);
    To copy to clipboard, switch view to plain text mode 
    That is just the constructors prototype, i'm actually declaring it with;

    Qt Code:
    1. QVideoFrame* qframe;
    2. QVideoFrame::PixelFormat qpf = parseFormat(pCodecCtx->pix_fmt);
    3. const QSize *framesize = new QSize(pCodecCtx->width, pCodecCtx->height);
    4. qframe = new QVideoFrame (pFrame->pkt_size, *framesize, pFrame->linesize[0], qpf);
    To copy to clipboard, switch view to plain text mode 
    I would have thought if this was incorrect, I would receive a compile error, and changing it to use the other constructors would provide a similar error, whereas those which I've tried work.

    Edit:
    Additionally I've just changed the declaration to the form;
    Qt Code:
    1. QVideoFrame qframe(pFrame->pkt_size, *framesize, pFrame->linesize[0], qpf);
    To copy to clipboard, switch view to plain text mode 
    and I receive exactly the same linker error.

  8. #8
    Join Date
    Nov 2013
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Undefined Reference for 1 of many constructors for QVideoFrame

    I've just tested whether i would be able to use the constructor;
    Qt Code:
    1. QVideoFrame ( QAbstractVideoBuffer * buffer, const QSize & size, PixelFormat format )
    To copy to clipboard, switch view to plain text mode 
    As the constructor i wish to use, makes the `buffer` from the data I pass to it, this then gave me a similar linker error;
    Qt Code:
    1. ~myfile.cpp:146: undefined reference to `_imp___ZN11QVideoFrameC1EP20QAbstractVideoBufferRK5QSizeNS_13AVPixelFormatE'
    2. collect2.exe: error: ld returned 1 exit status
    To copy to clipboard, switch view to plain text mode 

    This is really confusing me now, as the only other constructors (ignoring the copy constructor);
    Qt Code:
    1. QVideoFrame ( const QImage & image )
    2. QVideoFrame ( const QVideoFrame & other )
    To copy to clipboard, switch view to plain text mode 
    Both compile/link without fault and are unsuitable for my usage, is it possible that parts of QVideoFrame have silently failed to compile?
    Checking back through the QVideoFrame class from its inception in qt4.6-4.8 they all have the 4 constructors, so I still see no reason for 2 to be missing :s


    Added after 12 minutes:


    Quote Originally Posted by ChrisW67 View Post
    People are quite good at stuffing about until something compiles, i.e. by using full paths in #include or settings INCLUDEPATH, and then failing at link because of a lack of understanding. They are also good as giving a description of the problem that is coloured by their assumptions. I like to look for the obvious before looking for the not obvious.

    Your assessment of the QVideoFrame sources certainly imply that the constructor is both public and, by virtue of the class, exported. The message seems consistent with the symbol either not being present or not being exported. There does not seem to be a way for the implementation to have been pre-processed out.

    Is there any chance the linker is picking up a very old Qt4 library? (It's a long shot).

    If your MinGW tool chain has the "nm" command, does the output of:
    Qt Code:
    1. nm -D \path\to\QtMultimedia4.dll
    To copy to clipboard, switch view to plain text mode 
    contain "_ZN11QVideoFrameC1EiRK5QSizeiNS_13AVPixelFormatE" ?
    Edit: Just checked, and there are no symbols visible through nm in my off-the-shelf Qt 4.8.4
    Edit2: I played with the params of nm and I found that;
    Qt Code:
    1. nm -a -C auto QtMultimediad4.dll
    To copy to clipboard, switch view to plain text mode 
    returns
    Qt Code:
    1. 64dc943e T QVideoFrame::QVideoFrame(int, QSize const&, int, QVideoFrame::PixelFormat)
    2. 64dc93e8 T QVideoFrame::QVideoFrame(QAbstractVideoBuffer*, QSize const&, QVideoFrame::PixelFormat)
    3. 64dc9534 T QVideoFrame::QVideoFrame(QImage const&)
    4. 64dc9610 T QVideoFrame::QVideoFrame(QVideoFrame const&)
    5. 64dc93b4 T QVideoFrame::QVideoFrame()
    6. 64dc943e T QVideoFrame::QVideoFrame(int, QSize const&, int, QVideoFrame::PixelFormat)
    7. 64dc93e8 T QVideoFrame::QVideoFrame(QAbstractVideoBuffer*, QSize const&, QVideoFrame::PixelFormat)
    8. 64dc9534 T QVideoFrame::QVideoFrame(QImage const&)
    9. 64dc9610 T QVideoFrame::QVideoFrame(QVideoFrame const&)
    10. 64dc93b4 T QVideoFrame::QVideoFrame()
    11. 64dc9654 T QVideoFrame::~QVideoFrame()
    12. 64dc9654 T QVideoFrame::~QVideoFrame()
    To copy to clipboard, switch view to plain text mode 
    and without the name mangling fix parameter;
    Qt Code:
    1. 64dc943e T __ZN11QVideoFrameC1EiRK5QSizeiNS_11PixelFormatE
    2. 64dc93e8 T __ZN11QVideoFrameC1EP20QAbstractVideoBufferRK5QSizeNS_11PixelFormatE
    3. 64dc9534 T __ZN11QVideoFrameC1ERK6QImage
    4. 64dc9610 T __ZN11QVideoFrameC1ERKS_
    5. 64dc93b4 T __ZN11QVideoFrameC1Ev
    6. 64dc943e T __ZN11QVideoFrameC2EiRK5QSizeiNS_11PixelFormatE
    7. 64dc93e8 T __ZN11QVideoFrameC2EP20QAbstractVideoBufferRK5QSizeNS_11PixelFormatE
    8. 64dc9534 T __ZN11QVideoFrameC2ERK6QImage
    9. 64dc9610 T __ZN11QVideoFrameC2ERKS_
    10. 64dc93b4 T __ZN11QVideoFrameC2Ev
    11. 64dc9654 T __ZN11QVideoFrameD1Ev
    12. 64dc9654 T __ZN11QVideoFrameD2Ev
    To copy to clipboard, switch view to plain text mode 
    This seems to show the debug symbols for them exist, despite the -D parameter returning nothing for any qt dll, albeit the name mangled versions being different (presumably due to them being debug symbols).
    Last edited by robadob; 25th November 2013 at 18:09.

  9. #9
    Join Date
    Nov 2013
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Undefined Reference for 1 of many constructors for QVideoFrame

    I decided to take the code into isolation and see if i could make the issue happen, so that I could post something here for people to play with. It compiled/linked fine, so I commented everything out in my own code and it compiled fine. I've now traced it back to my ffmpeg imports causing the issue, if any of these includes are uncommented (other than the last one) the linker issue occurs;

    Qt Code:
    1. extern "C" {
    2. #include <libavcodec/avcodec.h>
    3. #include <libswscale/swscale.h>
    4. #include <libavformat/avformat.h>
    5. #include <libavfilter/avfiltergraph.h>
    6. #include <libavfilter/avcodec.h>
    7. #include <libavfilter/buffersink.h>
    8. #include <libavfilter/buffersrc.h>
    9. #include <libavdevice/avdevice.h>
    10. #include <libavutil/dict.h>
    11. }
    To copy to clipboard, switch view to plain text mode 

    Still not sure why this would be happening though.

  10. #10
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,316
    Thanks
    314
    Thanked 870 Times in 857 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Undefined Reference for 1 of many constructors for QVideoFrame

    Are your ffmpeg libraries compatible with your Qt and app? That is, produced using the same version of the compiler you're using? I do not know if Qt's video support uses ffmpeg, but if it does, and if it uses a different compilation (or compilation flags) that may be the problem. (Although I would still be puzzled why something doesn't show up at compile time, unless one of the ffmpeg headers contains a #pragma that forces a link-time condition).

Similar Threads

  1. Undefined reference
    By eekhoorn12 in forum Qt Programming
    Replies: 2
    Last Post: 6th January 2011, 15:45
  2. undefined reference
    By digidas in forum Newbie
    Replies: 9
    Last Post: 19th May 2010, 13:04
  3. undefined reference
    By jayreddy in forum Qt Programming
    Replies: 1
    Last Post: 20th November 2009, 13:45
  4. Undefined reference to crt
    By derektaprell in forum Installation and Deployment
    Replies: 0
    Last Post: 20th October 2009, 08:34
  5. Undefined reference
    By Salazaar in forum Newbie
    Replies: 12
    Last Post: 23rd May 2007, 10:21

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.