Jellyfin Forum
Can't build JMP from source, LNK4017 / LNK4272 warnings, then LNK1120 fatal error - Printable Version

+- Jellyfin Forum (https://forum.jellyfin.org)
+-- Forum: Support (https://forum.jellyfin.org/f-support)
+--- Forum: Troubleshooting (https://forum.jellyfin.org/f-troubleshooting)
+--- Thread: Can't build JMP from source, LNK4017 / LNK4272 warnings, then LNK1120 fatal error (/t-can-t-build-jmp-from-source-lnk4017-lnk4272-warnings-then-lnk1120-fatal-error)



Can't build JMP from source, LNK4017 / LNK4272 warnings, then LNK1120 fatal error - raulo1985 - 2024-12-13

Hi:

I'm trying to build JMP from source (for Windows) by following the Github page instructions, but when I run this command line (on x64_x86 Cross Tools of VS 2022):

Quote:lib /def:mpv\mpv.def /out:mpv\mpv.dll.lib /MACHINE:X64

I get many LNK4017 warnings (but it does create a mpv.dll.lib and a mpv.dll.exp file). Then, when I run the ninja command line, I get this:

Quote:fatal error LNK1104 (and it says it can't open the 'mpv\libmpv-2.dll.lib' file).

Just to try something, since I can't find a libmpv-2.dll.lib file in any folder, I renamed the created mpv.dll.lib file to  libmpv-2.dll.lib, run ninja again, and this time I get many:

Quote:LNK4272 warnings: library machine type 'x64' conflicts with target machine type 'X86'.

It ends with a fatal error LNK1120, and then ninja: build stopped: subcommand failed.

I'm obviously out of my comfort zone with these commands, but I tried to look for an answer (Google) and didn't find anything (tried a couple of things, but got the same error messages).

What am I doing wrong? Any guidance would be highly appreciated.

Thanks in advance!

PS: on a side note, I can only get to that point with older  versions of libmpv1, because newer ones don't include a mpv.def file, which is required apparently. How can I try with a newer libmpv1 version without the mpv.def file? Or you can just use one that came with an older version?


RE: Can't build JMP from source, LNK4017 / LNK4272 warnings, then LNK1120 fatal error - qwerty12 - 2024-12-13

I've never built JMP from source, so take what you will from this.

(2024-12-13, 12:01 AM)raulo1985 Wrote: [...](on x64_x86 Cross Tools of VS 2022)[...]

Quote:lib /def:mpv\mpv.def /out:mpv\mpv.dll.lib /MACHINE:X64
LNK4272 warnings: library machine type 'x64' conflicts with target machine type 'X86'.

Well, which is it: are you trying to cross-compile a 32-bit build of JMP on a 64-bit machine, or do you actually want a 64-bit build of JMP? If it's the former, I'd start by changing /MACHINE:X64 and if it's the latter, you should be running "x64 Native Tools Command Prompt for VS 2022" instead.

Quote:PS: on a side note, I can only get to that point with older  versions of libmpv1, because newer ones don't include a mpv.def file, which is required apparently. How can I try with a newer libmpv1 version without the mpv.def file? Or you can just use one that came with an older version?

Look at the workflow file for JMP. You'll notice it runs gendef as part of the build process to produce a def file from a given libmpv.dll. If you want a copy of that program, you can take an executable from here: https://packages.msys2.org/packages/mingw-w64-x86_64-tools-git


RE: Can't build JMP from source, LNK4017 / LNK4272 warnings, then LNK1120 fatal error - raulo1985 - 2024-12-14

(2024-12-13, 06:51 AM)qwerty12 Wrote: I've never built JMP from source, so take what you will from this.

(2024-12-13, 12:01 AM)raulo1985 Wrote: [...](on x64_x86 Cross Tools of VS 2022)[...]

Quote:lib /def:mpv\mpv.def /out:mpv\mpv.dll.lib /MACHINE:X64
LNK4272 warnings: library machine type 'x64' conflicts with target machine type 'X86'.

Well, which is it: are you trying to cross-compile a 32-bit build of JMP on a 64-bit machine, or do you actually want a 64-bit build of JMP? If it's the former, I'd start by changing /MACHINE:X64 and if it's the latter, you should be running "x64 Native Tools Command Prompt for VS 2022" instead.

Quote:PS: on a side note, I can only get to that point with older  versions of libmpv1, because newer ones don't include a mpv.def file, which is required apparently. How can I try with a newer libmpv1 version without the mpv.def file? Or you can just use one that came with an older version?

Look at the workflow file for JMP. You'll notice it runs gendef as part of the build process to produce a def file from a given libmpv.dll. If you want a copy of that program, you can take an executable from here: https://packages.msys2.org/packages/mingw-w64-x86_64-tools-git

Thanks for your reply, greatly appreciate it. I'm trying to create a x64 build, I used Cross tools because that's what the instructions said. When I use x64 Native Tools Command Prompt for VS 2022 I get many "PlayerComponent.cpp.obj : error LNK2019: unresolved external symbol" messages (related to mpv) and it ends with a fatal error. So I'm still stuck.


RE: Can't build JMP from source, LNK4017 / LNK4272 warnings, then LNK1120 fatal error - qwerty12 - 2024-12-15

(2024-12-14, 02:37 PM)raulo1985 Wrote: Thanks for your reply, greatly appreciate it. I'm trying to create a x64 build, I used Cross tools because that's what the instructions said. When I use x64 Native Tools Command Prompt for VS 2022 I get many "PlayerComponent.cpp.obj : error LNK2019: unresolved external symbol" messages (related to mpv) and it ends with a fatal error. So I'm still stuck.

I did manage to build it on my system (although I didn't then carry on with the instructions for building an installer) by following the steps from the automated workflow used by JMP that I linked in my previous post and the README. I have no idea how your system is configured and what steps you've followed (and omitted), but I can go through what I did with a clean tree in the hopes it may help you. If you started building a 32-bit build and are now switching to produce a 64-bit build, I'd start by cleaning the build folder.

I already had CMake and Ninja installed via Scoop, so they were already the latest versions and were in my %PATH%. Git for Windows was installed, of course. I did have to install Qt's 5.15.2 Qt WebEngine and MSVC 2019 64-bit from Qt's installer (username and password taken from BugMeNot).

---

  1. I ran "x64 Native Tools Command Prompt for VS 2022"
  2. Cloned the code: git clone --single-branch --branch master https://github.com/jellyfin/jellyfin-media-player.git
  3. cd jellyfin-media-player && mkdir build && cd build
  4. I downloaded and extracted https://github.com/shinchiro/mpv-winbuild-cmake/releases/download/20241215/mpv-dev-x86_64-20241215-git-e52f975.7z into jellyfin-media-player\build\mpv
  5. I extracted gendef.exe from https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-tools-git-12.0.0.r446.ga2d19218d-1-any.pkg.tar.zst (WinRAR/7-Zip), placed it into jellyfin-media-player\build\mpv and ran gendef libmpv-2.dll
  6. From the jellyfin-media-player\build folder, I ran cmake -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=output -DCMAKE_MAKE_PROGRAM=ninja.exe -DQTROOT=C:/Qt/5.15.2/msvc2019_64 -DMPV_INCLUDE_DIR=mpv/include -DMPV_LIBRARY=mpv/libmpv-2.dll -DCMAKE_INSTALL_PREFIX=output ..
  7. I ran lib /def:mpv\libmpv-2.def /out:mpv\libmpv-2.dll.lib /MACHINE:X64
  8. I finally ran ninja and got a src\JellyfinMediaPlayer.exe for my troubles
  9. Running it failed; I had to run set "PATH=C:\Qt\5.15.2\msvc2019_64\bin;%PATH%" so the Qt DLLs are found and copy mpv\libmpv-2.dll src\ for src\JellyfinMediaPlayer.exe to start

Now, the actual loading of JMP fails - I imagine it's looking for some resource or for more (QtWebEngine) DLLs to load at runtime l that I need to copy from elsewhere (presumably the steps to create an installer bundles everything together) - but it did build for a 64-bit system, on a 64-bit machine, using the latest 64-bit libmpv dll from shinchiro:
[Image: nJhPnEG.jpeg]