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]


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

(2024-12-15, 01:07 PM)qwerty12 Wrote:
(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=CConfused-faceQt/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]

Thank you very much for your detailed guide. I was doing exactly what you said, I guess what did the trick was generating the .def file. That's the only thing you did differently, so that must have been the issue.

This is kinda new for me and I'm trying to learn by myself, but I got stuck again and a little more help would be highly appreciated. I ended on the exact same spot that you did, and JMP in fact fails when I load it (looks exactly the same as your screenshot), it asks for some qt5 dlls (like qt5webengine.dll). But the thing is that I'm trying to create an installer (like the official ones), specially if you say that probably by doing so it would bundle everything together, including the missing resources. That's where I get stuck, I'm trying to figure how to create an installer.

Could you please help me with that, or point me in the right direction so I can figure it out?

Thanks again!


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

(2024-12-17, 11:16 PM)raulo1985 Wrote: But the thing is that I'm trying to create an installer (like the official ones), specially if you say that probably by doing so it would bundle everything together, including the missing resources. That's where I get stuck, I'm trying to figure how to create an installer.

I'm not at all familiar with programs used for creating installers, let alone the specific installer workflow employed by JMP, so there's not really much I can suggest. From a quick look at the README and the workflow file again, you're meant to install WiX Toolset v3.11.2, and then after successfully building with ninja (as you have done) you're meant to run set PATH=%PATH%;C:\Program Files (x86)\WiX Toolset v3.11\bin;%CD% and ninja windows_package which, hopefully, churns out an installer. I think that process may require Python to be installed.

However, that probably won't work without this first: because the program depends on the Microsoft Visual C++ 2015-2022 Redistributable, you need to download that separately and have that as a part of the installer. You can see that being done here: https://github.com/jellyfin/jellyfin-media-player/blob/master/.github/workflows/main.yml#L79-L80
Looking at that, I'm confused as to what practical purpose that sed invocation serves. Maybe it's some WiX thing that I'm unfamiliar with. You can try running that, I guess, but I'd start by simply trying to save https://aka.ms/vs/17/release/vc_redist.x64.exe as bundle/win/Bundle.wxs

I don't actually know if there's any basis for what I said regarding as to why it won't start. To check, install the usual Jellyfin Media Player from its installer and then replace JellyfinMediaPlayer.exe and the libmpv-2.dll in C:\Program Files\Jellyfin Media Player (or wherever it actually installs to) with the ones you built and see if that starts.



(Looking at your other thread, if this is to autofill the server address, username and password, I reckon you would have an easier time trying something like modifying web-client\extension\find-webclient.js instead and just having the recipient install the usual Jellyfin Media Player instead and creating a self-extracting 7-Zip archive that will replace the existing find-webclient.js. Or, if JMP saves the credentials in plaintext, a script that just writes out an initial config file. Dunno.)


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

qwerty12 dateline='[url=tel:1734554765' Wrote: 1734554765[/url]']
raulo1985 dateline='[url=tel:1734477395' Wrote: 1734477395[/url]']
But the thing is that I'm trying to create an installer (like the official ones), specially if you say that probably by doing so it would bundle everything together, including the missing resources. That's where I get stuck, I'm trying to figure how to create an installer.

I'm not at all familiar with programs used for creating installers, let alone the specific installer workflow employed by JMP, so there's not really much I can suggest. From a quick look at the README and the workflow file again, you're meant to install WiX Toolset v3.11.2, and then after successfully building with ninja (as you have done) you're meant to run set PATH=%PATH%;C:\Program Files (x86)\WiX Toolset v3.11\bin;%CD% and ninja windows_package which, hopefully, churns out an installer. I think that process may require Python to be installed.

However, that probably won't work without this first: because the program depends on the Microsoft Visual C++ 2015-2022 Redistributable, you need to download that separately and have that as a part of the installer. You can see that being done here: https://github.com/jellyfin/jellyfin-media-player/blob/master/.github/workflows/main.yml#L79-L80
Looking at that, I'm confused as to what practical purpose that sed invocation serves. Maybe it's some WiX thing that I'm unfamiliar with. You can try running that, I guess, but I'd start by simply trying to save https://aka.ms/vs/17/release/vc_redist.x64.exe as bundle/win/Bundle.wxs

I don't actually know if there's any basis for what I said regarding as to why it won't start. To check, install the usual Jellyfin Media Player from its installer and then replace JellyfinMediaPlayer.exe and the libmpv-2.dll in C:\Program Files\Jellyfin Media Player (or wherever it actually installs to) with the ones you built and see if that starts.



(Looking at your other thread, if this is to autofill the server address, username and password, I reckon you would have an easier time trying something like modifying web-client\extension\find-webclient.js instead and just having the recipient install the usual Jellyfin Media Player instead and creating a self-extracting 7-Zip archive that will replace the existing find-webclient.js. Or, if JMP saves the credentials in plaintext, a script that just writes out an initial config file. Dunno.)

Thanks again for all your help.
I’m not able to try your suggestions now (not my pc), but for the meantime, a couple of questions:

- When you say save vc_redist.x64.exe as bundle/win/Bundle.wxs, do you mean renaming the .exe file and its extension to Bundle.wxs? Sorry for the noob question.

- Regarding your last paragraph, I actually want to learn how to modify all the client settings defaults (specially with Tizen client, JMP and WebOS client) so I can remotely install everything by myself and not rely on my relatives tech abilities to do it (it takes too much time, and still somehow they usually end up with a bad configured client). So I’m interested on modifying every setting that you can modify when going to your profile pic at your client (playback, subtitles, even the order of how the libraries are shown if possible, etc). I’ve successfully build and deploy clients for Tizen TVs and WebOS TVs, but haven’t found a way to modify those defaults. Like I mentioned on my other thread, I found that in the appSettings.js and userSettings.js files almost all those settings are mentioned, but I don’t know much about coding so I’ll probably break everything if I modify those files without some assistance/guidance.

But one thing that could be also useful for this purpose is what you said, to have the server’s ip/ddns/username/password already set up so the client not only has its defaults already configured after installation/deployment, but also automatically logs in to the server without having to type the username and password. How can that be done? What should I modify in the find-webclient.js file for that purpose? At least when I look into that file of my already installed and configured JMP, I don’t see anything that mentions or points to my server (and when I execute the program, it automatically logs in).

In other words, I don’t know what to modify on a client before building it so, after being installed, it auto logs in to my server so the person at the client side don’t have to do, hopefully, anything after deployment (if that’s possible of course).

Having the client log in automatically after deployment would be great for my use case, but that’s not all that I want to achieve (which is to modify every client setting default). A deploy-and-forget kinda philosophy, specially considering my relative’s relation with any type of even the simplest tech (so it’s easier for me trying to figure this out than guiding them to even set up the client’s language or the size of the subtitles).


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

(2024-12-21, 12:51 AM)raulo1985 Wrote: - When you say save vc_redist.x64.exe as bundle/win/Bundle.wxs, do you mean renaming the .exe file and its extension to Bundle.wxs? Sorry for the noob question.

That's my reading of the workflow file, yes - save the exe file as Bundle.wxs in a bundle/win folder, which you probably will need to create first in the folder where you cloned the source. You might need to perform the path substitution to Bundle.wxs that the workflow does - read the workflow for details - but I would try without doing that first.

Quote:- Regarding your last paragraph, I actually want to learn how to modify all the client settings defaults (specially with Tizen client, JMP and WebOS client) so I can remotely install everything by myself and not rely on my relatives tech abilities to do it (it takes too much time, and still somehow they usually end up with a bad configured client). So I’m interested on modifying every setting that you can modify when going to your profile pic at your client (playback, subtitles, even the order of how the libraries are shown if possible, etc). I’ve successfully build and deploy clients for Tizen TVs and WebOS TVs, but haven’t found a way to modify those defaults. Like I mentioned on my other thread, I found that in the appSettings.js and userSettings.js files almost all those settings are mentioned, but I don’t know much about coding so I’ll probably break everything if I modify those files without some assistance/guidance.

Even if you change them, you'll need to do so again the next time you upgrade Jellyfin. And because in the distributed builds of Jellyfin those files are minified, and probably have a different name from one version to the next, that's not really a sustainable approach in the long term IMO. (OTOH, you could say the same thing about custom builds of clients...)

Quote:But one thing that could be also useful for this purpose is what you said, to have the server’s ip/ddns/username/password already set up so the client not only has its defaults already configured after installation/deployment, but also automatically logs in to the server without having to type the username and password. How can that be done? What should I modify in the find-webclient.js file for that purpose?

I do not directly know. I have no affiliation with Jellyfin as a project whatsoever and I am not at all familiar with the clients' intricacies. (I posted here because I'm not new to using the Microsoft toolchain to build my own simple stuff.) I've never used JMP myself. My following suggestions are probably useless partly because of that. ChatGPT will know more than me.
I believe the actual developers hang out in Matrix rooms. At most, I've changed how things work on the server side (thank you, HarmonyLib and the Jellyfin plugin system).

If my cursory look is correct, I think that file gets executed when JMP is showing the screen to input the server address. The idea is something like this (there's examples of some of this in the file): you get the Element that represents the server address input, fill it in with a value, find the Element that represents the "proceed" button and simulate a click on that. I don't know if that JavaScript file continues to remain loaded when Jellyfin's login screen is displayed; if so, there's mechanisms to detect when new Elements are created, when the URL is changed etc. etc. And if that JavaScript doesn't remain loaded, look into QtWebEngine's API to see if you can determine when the login page is displayed and modify JMP to inject your own JavaScript at that point.

Quote:At least when I look into that file of my already installed and configured JMP, I don’t see anything that mentions or points to my server (and when I execute the program, it automatically logs in).

Surely in %APPDATA% or %LOCALAPPDATA% there's some sort of "jellyfin media player" folder that has the settings? I think the web part of Jellyfin relies on the browser's LocalStorage to persist the settings - QtWebEngine probably churns out a database etc. file containing the settings.

Quote:In other words, I don’t know what to modify on a client before building it so, after being installed, it auto logs in to my server so the person at the client side don’t have to do, hopefully, anything after deployment (if that’s possible of course).

That would make two of us Smiling-face