Squalr / Squally

2D Platformer Educational Game for Teaching Game Hacking - C++/cocos2d-x
https://store.steampowered.com/app/770200/Squally/
Mozilla Public License 2.0
461 stars 58 forks source link

Error Installing mpg123 As Part of dep.py #133

Closed cbat98 closed 1 year ago

cbat98 commented 4 years ago

When I try running the dep.py script on windows, I get an error preventing mpg123 from being installed properly, as it seems to be failing post validation checks. I've done some digging to try and fix this, but this is a tad out of my depth and have just been going round in circles checking error codes and reading source files. Any input would be great.

installing: mpg123 The following packages will be built and installed: mpg123[core]:x86-windows Starting package 1/1: mpg123:x86-windows Building package mpg123[core]:x86-windows... -- Downloading http://downloads.sourceforge.net/project/mpg123/mpg123/1.25.8/mpg123-1.25.8.tar.bz2... -- Extracting source C:/Users/Charlie/Downloads/Squally/vcpkg/downloads/mpg123-1.25.8.tar.bz2 -- Applying patch 0001-fix-crt-linking.patch -- Applying patch 0002-fix-x86-build.patch -- Applying patch 0003-add-arm-configs.patch -- Using source at C:/Users/Charlie/Downloads/Squally/vcpkg/buildtrees/mpg123/src/mpg123-1-9840211cc0 -- Downloading https://www.tortall.net/projects/yasm/snapshots/v1.3.0.6.g1962/yasm-1.3.0.6.g1962.exe... -- Installing: C:/Users/Charlie/Downloads/Squally/vcpkg/downloads/tools/yasm/1.3.0.6/yasm.exe -- Building C:/Users/Charlie/Downloads/Squally/vcpkg/buildtrees/mpg123/src/mpg123-1-9840211cc0/ports/MSVC++/2015/win32/libmpg123/libmpg123.vcxproj for Release -- Building C:/Users/Charlie/Downloads/Squally/vcpkg/buildtrees/mpg123/src/mpg123-1-9840211cc0/ports/MSVC++/2015/win32/libmpg123/libmpg123.vcxproj for Debug -- Installing -- Installing: C:/Users/Charlie/Downloads/Squally/vcpkg/packages/mpg123_x86-windows/debug/lib/libmpg123.pdb -- Installing: C:/Users/Charlie/Downloads/Squally/vcpkg/packages/mpg123_x86-windows/lib/libmpg123.pdb -- Installing: C:/Users/Charlie/Downloads/Squally/vcpkg/packages/mpg123_x86-windows/debug/lib/libmpg123.lib -- Installing: C:/Users/Charlie/Downloads/Squally/vcpkg/packages/mpg123_x86-windows/lib/libmpg123.lib -- Installing: C:/Users/Charlie/Downloads/Squally/vcpkg/packages/mpg123_x86-windows/include/mpg123.h -- Installing: C:/Users/Charlie/Downloads/Squally/vcpkg/packages/mpg123_x86-windows/include/fmt123.h -- Installing: C:/Users/Charlie/Downloads/Squally/vcpkg/packages/mpg123_x86-windows/include/mpg123.h.in -- Installing: C:/Users/Charlie/Downloads/Squally/vcpkg/packages/mpg123_x86-windows/share/mpg123/copyright -- Installing done -- Performing post-build validation Expected Debug,Dynamic crt linkage, but the following libs had invalid crt linkage:

C:/Users/Charlie/Downloads/Squally/vcpkg/packages/mpg123_x86-windows/debug/lib/libmpg123.lib: Debug,Static To inspect the lib files, use: dumpbin.exe /directives mylibfile.lib Expected Release,Dynamic crt linkage, but the following libs had invalid crt linkage:

C:/Users/Charlie/Downloads/Squally/vcpkg/packages/mpg123_x86-windows/lib/libmpg123.lib: Release,Static

To inspect the lib files, use: dumpbin.exe /directives mylibfile.lib Found 2 error(s). Please correct the portfile: C:\Users\Charlie\Downloads\Squally\vcpkg\ports\mpg123\portfile.cmake -- Performing post-build validation done Error: Building package mpg123:x86-windows failed with: POST_BUILD_CHECKS_FAILED Please ensure you're using the latest portfiles with .\vcpkg update, then submit an issue at https://github.com/Microsoft/vcpkg/issues including: Package: mpg123:x86-windows Vcpkg version: 2019.08.27-nohash

Additionally, attach any relevant sections from the log files above.

dep.py: A problem appears to have occurred, writing package to requirements.json skipped.

mattbucci commented 4 years ago

Looks like we'll need to file an issue with vpkg, I already have had one open for about a year for yet another dependency: https://github.com/Microsoft/vcpkg/issues/5018

I think we'll either need to fix these package in vcpkg ourselves or move the package out of vcpkg

mattbucci commented 4 years ago

I checked https://github.com/Squalr/vcpkg/commits/master/ports/mpg123/portfile.cmake to make sure have the latest version and it looks to be the same as https://github.com/microsoft/vcpkg/commits/master/ports/mpg123 👎

I wonder if any of the recent commits broke it @zcanann did you have this same problem on windows? we could revert to https://github.com/Squalr/vcpkg/commit/bde9a0496726c0be181f97879e47a35a9928c242#diff-a030ab7272a55ea1491258fb928458d0 if it used to work

zcanann commented 4 years ago

Huh, is this even used on Windows?

Maybe requirements.json can be edited to only pull it on on darwin/linux. Right now it's under common.

JackBoosY commented 4 years ago

Hi everyone, does this issue still exists?

superhero1 commented 4 years ago

Yes still exists

JackBoosY commented 4 years ago

The reason for reporting this error is that the library was generated incorrectly. We expected to use dynamic CRT linkage but static CRT linkage. vcpkg uses the Visual Studio project libmpg123.vcxproj inside mpg123 source to build it, so I think the project file has been modified. And I can't find the script dep.ph, can anyone help me?

mattbucci commented 4 years ago

hi @JackBoosY it's dep.py, This is the script https://github.com/Squalr/Squally/blob/develop/dep.py

The project uses vcpkg to pull in mpg123 and that can be found here: https://github.com/microsoft/vcpkg/tree/master/ports/mpg123

Originally I thought the mpg123 portfiles might be behind microsoft's version and that was what was causing issues. Squally's version of the portfiles is a fork located here: https://github.com/Squalr/vcpkg/commits/c2b6e8e46d71ad4bc3169138715eba78f049c649/ports/mpg123

I feel this commit is suspect: https://github.com/Squalr/vcpkg/commit/39b331ec10f23dda7602c509da2535d980e7e669#diff-a030ab7272a55ea1491258fb928458d0 but I could not get mpg123 to build correctly, even using the direct portfiles from microsoft.

mattbucci commented 4 years ago

More info on VCpkg here: https://docs.microsoft.com/en-us/cpp/build/vcpkg?view=vs-2019

https://vcpkg.readthedocs.io/en/latest/examples/installing-and-using-packages/

dep.py is just a simple wrapper around vcpkg

JackBoosY commented 4 years ago

@mattbucci The patch 0001-fix-crt-linking.patch fixes the CRT linkage, ~so if you want to build static, that patch should be applied.~ This patch modifies the CRT linage under static configuration to MultiThreadedDebug / MultiThreaded and should be always applied. And now I still can't repro this issue:

PS F:\vcpkg> .\vcpkg.exe install mpg123
Computing installation plan...
The following packages will be built and installed:
    mpg123[core]:x86-windows
Detecting compiler hash for triplet x86-windows...
Starting package 1/1: mpg123:x86-windows
Building package mpg123[core]:x86-windows...
Could not locate cached archive: C:\Users\AppData\Local\vcpkg\archives\07\07c652cf710f3c44c14f7e857748997b6774a638.zip
-- Trying auto-select mirror...
-- Downloading https://sourceforge.net/projects/mpg123/files/mpg123/1.25.8/mpg123-1.25.8.tar.bz2/download...
-- Skipping hash check for F:/vcpkg/downloads/temp/mpg123-1.25.8.tar.bz2.
-- The default mirror is in Disaster Recovery mode, trying other mirrors...
-- Trying mirror cfhcable...
-- Using cached F:/vcpkg/downloads/mpg123-1.25.8.tar.bz2
-- Skipping hash check for F:/vcpkg/downloads/mpg123-1.25.8.tar.bz2.
-- Extracting source F:/vcpkg/downloads/mpg123-1.25.8.tar.bz2
-- Applying patch 0001-fix-crt-linking.patch
-- Applying patch 0002-fix-x86-build.patch
-- Applying patch 0003-add-arm-configs.patch
-- Applying patch 0004-add-arm64-uwp-config.patch
-- Using source at F:/vcpkg/buildtrees/mpg123/src/f226317ddd-0aae5f9fd8.clean
-- Building F:/vcpkg/buildtrees/mpg123/src/f226317ddd-0aae5f9fd8.clean/ports/MSVC++/2015/win32/libmpg123/libmpg123.vcxproj for Release
-- Building F:/vcpkg/buildtrees/mpg123/src/f226317ddd-0aae5f9fd8.clean/ports/MSVC++/2015/win32/libmpg123/libmpg123.vcxproj for Debug
-- Installing
-- Installing: F:/vcpkg/packages/mpg123_x86-windows/debug/bin/libmpg123.dll
-- Installing: F:/vcpkg/packages/mpg123_x86-windows/debug/bin/libmpg123.pdb
-- Installing: F:/vcpkg/packages/mpg123_x86-windows/bin/libmpg123.dll
-- Installing: F:/vcpkg/packages/mpg123_x86-windows/bin/libmpg123.pdb
-- Installing: F:/vcpkg/packages/mpg123_x86-windows/debug/lib/libmpg123.lib
-- Installing: F:/vcpkg/packages/mpg123_x86-windows/lib/libmpg123.lib
-- Installing: F:/vcpkg/packages/mpg123_x86-windows/include/mpg123.h
-- Installing: F:/vcpkg/packages/mpg123_x86-windows/include/fmt123.h
-- Installing: F:/vcpkg/packages/mpg123_x86-windows/include/mpg123.h.in
-- Installing: F:/vcpkg/packages/mpg123_x86-windows/share/mpg123/copyright
-- Installing done
-- Performing post-build validation
-- Performing post-build validation done
Stored binary cache: C:\Users\AppData\Local\vcpkg\archives\07\07c652cf710f3c44c14f7e857748997b6774a638.zip
Building package mpg123[core]:x86-windows... done
Installing package mpg123[core]:x86-windows...
Installing package mpg123[core]:x86-windows... done
Elapsed time for package mpg123:x86-windows: 2.646 min

Total elapsed time: 3.042 min

I used the latest version in vcpkg master branch.

JackBoosY commented 4 years ago

If the latest version does not work properly, please leave me the logs under _VCPKGROOT/buildtrees/mpg123.

Thanks.

mattbucci commented 4 years ago

Here are my logs @JackBoosY build-x86-windows-dbg-err.zip

My assumption is that the error is due to the change in the windows-86 triplet to compile a static binary instead of a dynamic one here: https://github.com/Squalr/vcpkg/blob/master/triplets/x86-windows.cmake

I assume mpg123 should still be able to build even if you set this to static instead of dynamic. You should be able to reproduce the problem by changing your triplet for x86 windows to build a static lib

JackBoosY commented 4 years ago

@mattbucci I think so. Thanks for this info, I'll digger into it later.

JackBoosY commented 4 years ago

Confirmed. And you should use community triplet x86-windows-static-md instead of change triplet file x86-windows.

superhero1 commented 4 years ago

@mattbucci So can we automatically compile mpg123 static while everything else is still dynamic? I can do so manually but weird mpg123 is not supporting dynamic.

JackBoosY commented 4 years ago

@superhero1 This is easy to solve, just comment out _VCPKGROOT/ports/mpg123/porfile.cmake line 33: 0001-fix-crt-linking.patch will solve this issue. Then use command ./vcpkg install mpg123:x86-windows-static-md. Build okay.

JackBoosY commented 4 years ago

The reason for this issue is that the patch failed to patch the RuntimeLibrary option in vcxproj according to VCPKG_CRT_LINKAGE. I will open a PR to fix the issue.

mattbucci commented 1 year ago

Switched to OGG so no more mp3 requirements needed