MediaArea / MediaInfo

Convenient unified display of the most relevant technical and tag data for video and audio files.
https://MediaArea.net/MediaInfo
BSD 2-Clause "Simplified" License
1.32k stars 158 forks source link

How to properly build GUI on Windows? #788

Open DanH-ER opened 8 months ago

DanH-ER commented 8 months ago

When I build the Visual Studio project on Windows the resulting GUI app has the sheets and tree views disabled, is missing the preferences window, and just generally looks different that the official release from the website. So my question is how do I build the same UI that's in the official release? Is there a config or build flag step I'm missing?

The instructions in the readme only describe how to build Mac and Linux, not Windows.

JeromeMartinez commented 8 months ago

We definitely lack of doc about building GUIs, and not something we are focused on especially because we want to change that in a (far...) future. It will change one day, when we have the tile to refactor everything about the GUI (no ETA as it is not a priority of our sponsors).

In practice the official GUI does not currently use WxWidgets (the one you built, and the one we used a long time ago on Windows, now it is used only on Linux and macOS free version) but use the Borland C++ Builder version (you need Embarcadero, Embarcadero C++ Builder, Embarcadero bought Borland C++ Builder) or the UWP version (you'll get the version for the Windows Store).

DanH-ER commented 8 months ago

I downloaded the community edition of Embarcadero and I can build the UI in 32 bit mode but when I try to build the 64 bit version I get errors similar to this...

[ilink64 Error] Error: Unresolved external 'ZenLib::ZtringListListF::ZtringListListF()' referenced from C:\REPOS\MEDIAINFO\PROJECT\BCB\GUI\WIN64\RELEASE\PREFERENCES.O

I built the BCB ZenLib project first, in both 32 and 64 bit, so I'm not sure what is causing this.

Also I can't seem to build MediaInfoLib at all. The 32 bit version throws errors complaining about int128u and the the 64 bit version complains about __uuifof.

Since you guys use this for the official build I assume you don't have these errors. Any tips on what might be causing them?

DanH-ER commented 8 months ago

Never mind I see that the release script uses the 32bit GUI and the DLLs from Visual Studio. I think I see how it works.

cjee21 commented 3 months ago

How to build MediaInfo Windows GUI (VCL/Qt), MediaInfoLib (MSVC) and installer (NSIS) on Windows

Documenting how I managed to build the Windows GUI here to help others and for my future reference. Thanks to https://github.com/MediaArea/MediaInfo/issues/788#issuecomment-1887569305 and https://github.com/MediaArea/MediaInfo/issues/788#issuecomment-1888203511 for giving me an idea.

Contents

How to build official Windows GUI (VCL)

Screenshot 2024-06-24 215020

  1. Install the following required software on a Windows PC:
  2. Create an empty folder. We'll call this MediaInfoDevelopment for this guide.
  3. Clone the following MediaInfo dependencies to MediaInfoDevelopment using Git or GitHub Desktop:
  4. Clone MediaInfo (this repository) to MediaInfoDevelopment.
    • If you intend to contribute to MediaInfo, fork the repository on GitHub first and clone your fork instead.
  5. The MediaInfoDevelopment folder should now have the following folders:
    • MediaInfo
    • MediaInfoLib
    • ZenLib
    • zlib
  6. Build MediaInfo dependencies by opening the following in C++Builder, choosing the 32-bit or 64-bit target platform and selecting Project > Build (Shift+F9):
    • MediaInfoDevelopment\ZenLib\Project\BCB\ZenLib_Proj.groupproj
    • MediaInfoDevelopment\zlib\contrib\BCB\zlib_Proj.groupproj
  7. Copy the DLL and CSV dependencies:
    • MediaInfo.dll
      • If you do not want to build MediaInfoLib, copy 32-bit and 64-bit MediaInfo.dll from the official distribution to MediaInfoDevelopment\MediaInfo\Project\BCB\GUI\Win32\Release and MediaInfoDevelopment\MediaInfo\Project\BCB\GUI\Win64\Release respectively.
      • If you want to build it yourself, follow How to build MediaInfoLib (MSVC) below and copy MediaInfo.dlls from MediaInfoDevelopment\MediaInfoLib\Project\MSVC2022\Win32\Release to MediaInfoDevelopment\MediaInfo\Project\BCB\GUI\Win32\Release and from MediaInfoDevelopment\MediaInfoLib\Project\MSVC2022\x64\Release to MediaInfoDevelopment\MediaInfo\Project\BCB\GUI\Win64\Release.
    • Copy WebView2Loader.dll from C:\Program Files (x86)\Embarcadero\Studio\23.0\Redist\win32 to MediaInfoDevelopment\MediaInfo\Project\BCB\GUI\Win32\Release and from C:\Program Files (x86)\Embarcadero\Studio\23.0\Redist\win64 to MediaInfoDevelopment\MediaInfo\Project\BCB\GUI\Win64\Release.
    • Copy MediaInfoDevelopment\MediaInfo\Source\Resource\Plugin to MediaInfoDevelopment\MediaInfo\Project\BCB\GUI\Win32\Release and MediaInfoDevelopment\MediaInfo\Project\BCB\GUI\Win64\Release.
  8. Open MediaInfoDevelopment\MediaInfo\Project\BCB\MediaInfo_Proj.groupproj in C++Builder.
  9. Select 32-bit or 64-bit target platform then build MediaInfo GUI by selecting Project > Build MediaInfo_GUI (Shift+F9).
  10. You should now be able to run MediaInfo by selecting Run Without Debugging (Shift+Ctrl+F9) and see the GUI appear.

Note: For certain features, libcurl may be required. In that case, obtain LIBCURL.DLL and curl-ca-bundle.crt from MediaArea-Utils-Binaries and place it in the directory mentioned in step 7.

How to build MediaInfoLib (MSVC)

Screenshot 2024-06-24 215516

  1. Install the following required software on a Windows PC:
  2. Clone the required repositories by following steps 2 and 3 of How to build official Windows GUI (VCL) above.
  3. Open MediaInfoDevelopment\MediaInfoLib\Project\MSVC2022\MediaInfoLib.sln in Visual Studio 2022.
  4. Select the desired configuration and platform.
  5. Build the MediaInfoDll project.

How to build unreleased Windows GUI (Qt)

Screenshot 2024-06-24 215140

  1. Install the following required software on a Windows PC:
  2. Clone the required repositories by following steps 2 to 5 of How to build official Windows GUI (VCL) above.
  3. Build MediaInfo dependencies.
    • Follow How to build MediaInfoLib (MSVC) above using the Release configuration and x64 platform for step 4.
    • Ensure the following files are present:
      • MediaInfoDevelopment\MediaInfoLib\Project\MSVC2022\x64\Release\MediaInfo-Static.lib
      • MediaInfoDevelopment\ZenLib\Project\MSVC2022\x64\Release\ZenLib.lib
      • MediaInfoDevelopment\zlib\contrib\vstudio\vc17\x64\ZlibStatReleaseWithoutAsm\zlibstat.lib
  4. Open MediaInfoDevelopment\MediaInfo\Project\QMake\GUI\MediaInfoQt.pro in Qt Creator.
  5. Configure the project for Desktop Qt MSVC 2019 or 2022 64bit.
  6. Build MediaInfo GUI by selecting Build > Build Project "MediaInfoQt" or Ctrl+B.
  7. You should now be able to run MediaInfo by selecting Build > Run or Ctrl+R and see the GUI appear.

To deploy

  1. Open Command Prompt for Qt 6.7.2 (MSVC 2019 64-bit) or Qt 6.7.2 (MSVC 2022 64-bit).

  2. Change directory to MediaInfoDevelopment.

  3. Execute the following commands:

    MediaInfoDevelopment>mkdir MediaInfo\Release\MediaInfo_Qt_Windows_x64
    
    MediaInfoDevelopment>copy MediaInfo\Project\QMake\GUI\build\Desktop_Qt_6_7_2_MSVC2019_64bit-Release\x64\MediaInfo.exe MediaInfo\Release\MediaInfo_Qt_Windows_x64\
    
    MediaInfoDevelopment>windeployqt MediaInfo\Release\MediaInfo_Qt_Windows_x64\MediaInfo.exe
  4. The folder MediaInfo\Release\MediaInfo_Qt_Windows_x64\ can now be deployed and MediaInfo.exe in it should run sucessfully.

How to build Windows installer (NSIS)

Screenshot 2024-07-03 091458

  1. Follow How to build official Windows GUI (VCL) above and build both 64-bit and 32-bit versions of the GUI.

  2. Follow How to build MediaInfoLib (MSVC) above but build the MediaInfoShellExt project instead of the MediaInfoDll project in step 5 and build both Release Win32 and Release x64 versions of the required binaries.

  3. Install Git for Windows (https://gitforwindows.org/) if you have not.

  4. Obtain the required tools and additional binaries by executing the following in Windows Terminal with MediaInfoDevelopment as the current directory:

    MediaInfoDevelopment>git clone -n --depth=1 --filter=tree:0 https://github.com/MediaArea/MediaArea-Utils-Binaries.git
    MediaInfoDevelopment>cd MediaArea-Utils-Binaries
    MediaInfoDevelopment\MediaArea-Utils-Binaries>git sparse-checkout set Windows/NSIS Windows/libcurl
    MediaInfoDevelopment\MediaArea-Utils-Binaries>git checkout
  5. If MSVC2022 was used for step 2, edit MediaInfo_GUI_Windows.nsi, MediaInfo_GUI_Windows_i386.nsi and MediaInfo_GUI_Windows_x64.nsi in MediaInfoDevelopment\MediaInfo\Source\Install\ to replace all occurrences of MSVC2019 with MSVC2022.

  6. Run MediaInfoDevelopment\MediaInfo\Release\Release_GUI_Windows.bat.

  7. You should now find the 32-bit, 64-bit and combined installers at MediaInfoDevelopment\MediaInfo\Release\.

How to build MediaInfoLib (MSVC), official Windows GUI (VCL) and Windows installer (NSIS) using command line

  1. Install required tools:

  2. Create an empty folder. We'll call this MediaInfoDevelopment for this guide.

  3. Open Windows Terminal with MediaInfoDevelopment as the current directory.

  4. Execute the following commands (you can save this as a *.cmd file in MediaInfoDevelopment and run it):

    git clone https://github.com/MediaArea/MediaInfo.git
    git clone https://github.com/MediaArea/MediaInfoLib.git
    git clone https://github.com/MediaArea/ZenLib.git
    git clone https://github.com/MediaArea/zlib.git
    git clone -n --depth=1 --filter=tree:0 https://github.com/MediaArea/MediaArea-Utils-Binaries.git
    cd MediaArea-Utils-Binaries
    git sparse-checkout set Windows/NSIS Windows/libcurl
    git checkout
    cd ..
    set PATH_TEMP=%PATH%
    call "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\VsDevCmd.bat"
    MSBuild /t:MediaInfoShellExt /p:Configuration=Release;Platform=Win32 MediaInfoLib\Project\MSVC2022\MediaInfoLib.sln
    MSBuild /t:MediaInfoShellExt /p:Configuration=Release;Platform=x64 MediaInfoLib\Project\MSVC2022\MediaInfoLib.sln
    set PATH=%PATH_TEMP%
    call "C:\Program Files (x86)\Embarcadero\Studio\23.0\bin\rsvars.bat"
    MSBuild /p:Configuration=Release;Platform=Win32 zlib\contrib\BCB\zlib.cbproj
    MSBuild /p:Configuration=Release;Platform=Win64 zlib\contrib\BCB\zlib.cbproj
    MSBuild /p:Configuration=Release;Platform=Win32 ZenLib\Project\BCB\Library\ZenLib.cbproj
    MSBuild /p:Configuration=Release;Platform=Win64 ZenLib\Project\BCB\Library\ZenLib.cbproj
    MSBuild /p:Configuration=Release;Platform=Win32 MediaInfo\Project\BCB\GUI\MediaInfo_GUI.cbproj
    MSBuild /p:Configuration=Release;Platform=Win64 MediaInfo\Project\BCB\GUI\MediaInfo_GUI.cbproj
    set PATH=%PATH_TEMP%
    set PATH_TEMP=
    powershell -Command "(gc MediaInfo\Source\Install\MediaInfo_GUI_Windows.nsi) -replace 'MSVC2019', 'MSVC2022' | sc MediaInfo\Source\Install\MediaInfo_GUI_Windows.nsi"
    powershell -Command "(gc MediaInfo\Source\Install\MediaInfo_GUI_Windows_i386.nsi) -replace 'MSVC2019', 'MSVC2022' | sc MediaInfo\Source\Install\MediaInfo_GUI_Windows_i386.nsi"
    powershell -Command "(gc MediaInfo\Source\Install\MediaInfo_GUI_Windows_x64.nsi) -replace 'MSVC2019', 'MSVC2022' | sc MediaInfo\Source\Install\MediaInfo_GUI_Windows_x64.nsi"
    call MediaInfo\Release\Release_GUI_Windows.bat
    
  5. You should now find the 32-bit, 64-bit and combined installers in MediaInfoDevelopment\MediaInfo\Release\.


Updated on 2024-06-22 to prepare for 64-bit builds.
Updated on 2024-06-24 to add MediaInfoLib and Qt GUI as well as GetIt Package Manager and libcurl dependencies along with improvements.
Updated on 2024-07-03 to add 64-bit build, WebView2 & Plugin dependencies, deploying Qt GUI, Windows installer and building using CLI. Updated on 2024-07-30 to use C++Builder 12

cjee21 commented 2 months ago

I downloaded the community edition of Embarcadero and I can build the UI in 32 bit mode but when I try to build the 64 bit version I get errors similar to this...

[ilink64 Error] Error: Unresolved external 'ZenLib::ZtringListListF::ZtringListListF()' referenced from C:\REPOS\MEDIAINFO\PROJECT\BCB\GUI\WIN64\RELEASE\PREFERENCES.O

I built the BCB ZenLib project first, in both 32 and 64 bit, so I'm not sure what is causing this.

I successfully built a 64-bit version. Anyone interested? 😄

Screenshot 2024-06-22 180755 Screenshot 2024-06-22 180653

JeromeMartinez commented 2 months ago

I successfully built a 64-bit version. Anyone interested? 😄

Did you need to change the project files? If so, please do a PR. And we could put the 64-bit version in the 64-bit 7z package without installer, unfortunately 32-bit is still there and for the more used installer it would inflate the size to have both 32 and 64 bit, so not now, but at long term we may put the 64-bit version in the installer and move the 32-bit installer to a 2nd choice when the installer detects 64-bit...

cjee21 commented 2 months ago

Did you need to change the project files? If so, please do a PR.

Yes, changed project files for MediaInfo BCB, ZenLib BCB and zlib BCB.

And we could put the 64-bit version in the 64-bit 7z package without installer,

This should be easy to include in the PR.

unfortunately 32-bit is still there and for the more used installer it would inflate the size to have both 32 and 64 bit, so not now, but at long term we may put the 64-bit version in the installer and move the 32-bit installer to a 2nd choice when the installer detects 64-bit...

I can try and see how much it inflates...

JeromeMartinez commented 2 months ago

I can try and see how much it inflates...

Package size is a hot topic for us, most people don't care at all and download GB of content but some others complain loudly when there is 1 more MB in the main package...

For the 7z, it would actually helps as we can remove the 32-bit DLL in that case.

cjee21 commented 2 months ago

I can try and see how much it inflates...

Package size is a hot topic for us, most people don't care at all and download GB of content but some others complain loudly when there is 1 more MB in the main package...

Then maybe better to make two installers. Most PCs should be 64-bit now and Windows 11 does not even have a 32-bit version. Now it also contains both 64-bit and 32-bit DLLs.

Good thing the WebView2Loader.dll is only 100+KB

cjee21 commented 2 months ago

Making an installer that handles both 32-bit and 64-bit is around 9MiB

Installed size is less by around 3MiB when taking into account larger 64-bit EXE and excluding the 32-bit DLL

cjee21 commented 2 months ago

FYI updated the guide above (https://github.com/MediaArea/MediaInfo/issues/788#issuecomment-2124537221). Will update it again when the PRs are merged.

JeromeMartinez commented 2 months ago

FYI updated the guide above

Thank you!

cjee21 commented 2 months ago

FYI guide (https://github.com/MediaArea/MediaInfo/issues/788#issuecomment-2124537221) updated again.