Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Linker problem with QtAV
QtWS25 Last Chance

Linker problem with QtAV

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 4 Posters 843 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vlada
    wrote on last edited by
    #1

    Hi,

    I created a media player which uses QtAV for playback. Now I changed my computer and installed the whole toolchain from scratch and I can not compile it anymore. When I try to use QtAV, I get this linker error:

    release/main.o:main.cpp:(.text+0x4fd): undefined reference to `_imp___ZN4QtAV8AVPlayerC1EP7QObject'
    release/main.o:main.cpp:(.text+0x1862): undefined reference to `_imp___ZN4QtAV8AVPlayerD1Ev'
    release/main.o:main.cpp:(.text+0x259f): undefined reference to `_imp___ZN4QtAV8AVPlayerD1Ev'
    collect2.exe: error: ld returned 1 exit status
    mingw32-make[2]: *** [Makefile.Muzika.Release:317: release/Muzika.exe] Error 1
    mingw32-make[1]: *** [Makefile.Muzika:38: release] Error 2
    mingw32-make: *** [Makefile:40: sub-Muzika-pro-make_first-ordered] Error 2
    mingw32-make[2]: Leaving directory 'C:/Moje/QtProjects/build-MuzikaPlayer-Desktop_Qt_5_12_4_MinGW_32_bit-Release'
    mingw32-make[1]: Leaving directory 'C:/Moje/QtProjects/build-MuzikaPlayer-Desktop_Qt_5_12_4_MinGW_32_bit-Release'
    09:46:13: The process "C:\Qt\Tools\mingw730_32\bin\mingw32-make.exe" exited with code 2.
    Error while building/deploying project MuzikaPlayer (kit: Desktop Qt 5.12.4 MinGW 32-bit)
    When executing step "Make"
    

    I tried both 64bit and 32bit versions, reverted from Qt 5.13 to 5.12, reverted from QtAV 1.13 to 1.12. And still I have the same problem. Do you have any idea what might be wrong? The QtAV examples compile and work fine. But my app (and even a minimal example) don't.

    Thank you.

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Changing versions has nothing to do with this. Linker just can't find the definitions of the library's functions.
      Since you said you changed computer make sure that the path to the QtAv library in your .pro file is still valid.
      Please post contents of your .pro so we can take a look.

      1 Reply Last reply
      1
      • V Offline
        V Offline
        vlada
        wrote on last edited by
        #3

        The QtAV libraries are copied in Qt's installation folder. After compilation of QtAV there is a .bat file which does it. It looks like this:

        mkdir C:\Qt\5.12.4\mingw73_32\include\QtAV\
        copy /y C:\Moje\QtProjects\build-QtAV-Desktop_Qt_5_12_4_MinGW_32_bit-Release\lib_win_x86\*Qt*AV*.a* C:\Qt\5.12.4\mingw73_32\lib\
        copy /y C:\Moje\QtProjects\build-QtAV-Desktop_Qt_5_12_4_MinGW_32_bit-Release\lib_win_x86\libQtAV5.a C:\Qt\5.12.4\mingw73_32\lib\libQt5AV.a
        copy /y C:\Moje\QtProjects\build-QtAV-Desktop_Qt_5_12_4_MinGW_32_bit-Release\lib_win_x86\libQtAVd5.a C:\Qt\5.12.4\mingw73_32\lib\libQt5AVd.a
        copy /y C:\Moje\QtProjects\build-QtAV-Desktop_Qt_5_12_4_MinGW_32_bit-Release\tools\install_sdk\mkspecs\features\av.prf C:\Qt\5.12.4\mingw73_32\mkspecs\features\av.prf
        copy /y C:\Moje\QtProjects\build-QtAV-Desktop_Qt_5_12_4_MinGW_32_bit-Release\tools\install_sdk\mkspecs\modules\qt_lib_av*.pri C:\Qt\5.12.4\mingw73_32\mkspecs\modules\
        copy /y C:\Moje\QtProjects\build-QtAV-Desktop_Qt_5_12_4_MinGW_32_bit-Release\bin\Qt*AV*.dll C:\Qt\5.12.4\mingw73_32\bin\
        mkdir C:\Qt\5.12.4\mingw73_32\include\QtAVWidgets\
        copy /y C:\Moje\QtProjects\build-QtAV-Desktop_Qt_5_12_4_MinGW_32_bit-Release\lib_win_x86\*Qt*AV*.a* C:\Qt\5.12.4\mingw73_32\lib\
        copy /y C:\Moje\QtProjects\build-QtAV-Desktop_Qt_5_12_4_MinGW_32_bit-Release\lib_win_x86\libQtAVWidgets5.a C:\Qt\5.12.4\mingw73_32\lib\libQt5AVWidgets.a
        copy /y C:\Moje\QtProjects\build-QtAV-Desktop_Qt_5_12_4_MinGW_32_bit-Release\lib_win_x86\libQtAVWidgetsd5.a C:\Qt\5.12.4\mingw73_32\lib\libQt5AVWidgetsd.a
        copy /y C:\Moje\QtProjects\build-QtAV-Desktop_Qt_5_12_4_MinGW_32_bit-Release\tools\install_sdk\mkspecs\features\avwidgets.prf C:\Qt\5.12.4\mingw73_32\mkspecs\features\avwidgets.prf
        copy /y C:\Moje\QtProjects\build-QtAV-Desktop_Qt_5_12_4_MinGW_32_bit-Release\tools\install_sdk\mkspecs\modules\qt_lib_avwidgets*.pri C:\Qt\5.12.4\mingw73_32\mkspecs\modules\
        copy /y C:\Moje\QtProjects\build-QtAV-Desktop_Qt_5_12_4_MinGW_32_bit-Release\bin\Qt*AV*.dll C:\Qt\5.12.4\mingw73_32\bin\
        copy /y C:\Moje\QtProjects\QtAV\tools\install_sdk\..\..\src\QtAV\*.h C:\Qt\5.12.4\mingw73_32\include\QtAV\
        copy /y C:\Moje\QtProjects\QtAV\tools\install_sdk\..\..\src\QtAV\QtAV C:\Qt\5.12.4\mingw73_32\include\QtAV\
        copy /y C:\Moje\QtProjects\QtAV\tools\install_sdk\..\..\widgets\QtAVWidgets\*.h C:\Qt\5.12.4\mingw73_32\include\QtAVWidgets\
        copy /y C:\Moje\QtProjects\QtAV\tools\install_sdk\..\..\widgets\QtAVWidgets\QtAVWidgets C:\Qt\5.12.4\mingw73_32\include\QtAVWidgets\
        mkdir C:\Qt\5.12.4\mingw73_32\include\QtAV\5.12.4\QtAV\
        xcopy /s /q /y /i C:\Moje\QtProjects\QtAV\tools\install_sdk\..\..\src\QtAV\private C:\Qt\5.12.4\mingw73_32\include\QtAV\private
        xcopy /s /q /y /i C:\Moje\QtProjects\QtAV\tools\install_sdk\..\..\src\QtAV\private C:\Qt\5.12.4\mingw73_32\include\QtAV\5.12.4\QtAV\private
        xcopy /s /q /y /i C:\Moje\QtProjects\build-QtAV-Desktop_Qt_5_12_4_MinGW_32_bit-Release\bin\QtAV C:\Qt\5.12.4\mingw73_32\qml\QtAV
        copy /y C:\Moje\QtProjects\QtAV\tools\install_sdk\..\..\qml\plugins.qmltypes C:\Qt\5.12.4\mingw73_32\qml\QtAV\
        

        Than i my .pro file I just add

        QT += av
        

        It has always worked without any problem. But now the linker can not find the libraries for some reason.

        1 Reply Last reply
        0
        • U Offline
          U Offline
          umod.47
          wrote on last edited by
          #4

          You have to rebuild QtAV with the same toolkit you're using and then install it to your toolkit directory using .bat file.
          It's not just about the compiler, it's a combination of a compiler and Qt libraries.
          QtAV build system is quite nice.

          Look through the compiler command line and flags, search for -l and -L keys, they specify linked library and additional library paths.
          Make sure you've rerun qmake over your project file. I used to forget this and got the same compiler errors.

          Press ESCAPE to enter or ENTER to escape.
          Keyboard not found. Press F1 to continue.
          (c) BIOS

          V 1 Reply Last reply
          1
          • U umod.47

            You have to rebuild QtAV with the same toolkit you're using and then install it to your toolkit directory using .bat file.
            It's not just about the compiler, it's a combination of a compiler and Qt libraries.
            QtAV build system is quite nice.

            Look through the compiler command line and flags, search for -l and -L keys, they specify linked library and additional library paths.
            Make sure you've rerun qmake over your project file. I used to forget this and got the same compiler errors.

            V Offline
            V Offline
            vlada
            wrote on last edited by
            #5

            @umod-47 Yes, I know this. As I said, I've been using QtAV for many years. But now something is broken and I don't know what could it be.

            I'll try to search through the compiler command to see if there is something wrong there.

            1 Reply Last reply
            0
            • V Offline
              V Offline
              vlada
              wrote on last edited by
              #6

              Very interesting. I went one more step back and reverted to Qt 5.11 and suddenly everything works fine.

              So I'm thinking why it works perfectly with Qt 5.11 and fails in Qt 5.12 with the exactly same setup. The one thing I see as the main difference is the switch to new MinGW. But could this really be the problem?

              The compiler command which fails is this:

              g++ -Wl,-s -Wl,-subsystem,windows -mthreads -o release\Muzika.exe @object_script.Muzika.Release  -LC:\Moje\QtProjects\Muzika\3rdparty\taglib\lib\x64 -ltag -LC:\Moje\QtProjects\Muzika\3rdparty\mediainfo\lib\x64 -lmediainfo C:\Qt\5.13.0\mingw73_64\lib\libQt5Quick.a C:\Qt\5.13.0\mingw73_64\lib\libQt5Svg.a C:\Qt\5.13.0\mingw73_64\lib\libQt5Widgets.a C:\Qt\5.13.0\mingw73_64\lib\libQt5Multimedia.a C:\Qt\5.13.0\mingw73_64\lib\libQt5Gui.a C:\Qt\5.13.0\mingw73_64\lib\libQt5Qml.a C:\Qt\5.13.0\mingw73_64\lib\libQt5Network.a C:\Qt\5.13.0\mingw73_64\lib\libQt5Sql.a C:\Qt\5.13.0\mingw73_64\lib\libQt5Xml.a C:\Qt\5.13.0\mingw73_64\lib\libQt5Core.a release\muzika_res.o  -lmingw32 C:\Qt\5.13.0\mingw73_64\lib\libqtmain.a -LC:\openssl\lib -LC:\Utils\postgresql\pgsql\lib -lshell32
              

              If I run it from command line, I get exactly the same error message. Do you have any idea what could I check further and what could be the problem?

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                Hi,

                By new, do you mean just the version or the architecture also ?

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0
                • V Offline
                  V Offline
                  vlada
                  wrote on last edited by
                  #8

                  @SGaist No, I mean just the switch from MinGW 5.3 to MinGW 7.3.

                  With Qt 5.13 and MinGW 7.3 I tried both architectures (32bit and 64bit) with exactly the same result. So the architecture is not the issue.

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    Did you ensure that all the libraries you are using in that project, are built with the same compiler ?

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    0
                    • V Offline
                      V Offline
                      vlada
                      wrote on last edited by
                      #10

                      Yes, at least the QtAV libraries are definitely built with the same compiler, because I also build them in QtCreator with the same toolchain.

                      I found the solution here in QtAV discussion forum. According to the findings also from other people something has changed between Qt 5.11 and Qt 5.12, which breaks the functionality.

                      Now my application compiles but crashes immediately because some other libraries are missing. With Qt 5.11 the 3rd party libraries (in my case TagLib and MediaInfo) are automatically copied to release directory, but this also doesn't work with Qt 5.12+ anymore. I can fix this easily by copying the DLLs to the folder manually. But I mention it, because I think the two problems might be related.

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved