MizunagiKB / gd_cubism

Unofficial Live2D Player for Godot Engine
https://mizunagikb.github.io/gd_cubism/
Other
150 stars 17 forks source link

Building failure under Windows. #101

Closed Irrawa closed 2 months ago

Irrawa commented 2 months ago

I followed the building instruction and arrived at the build command:

E:\godot_code\gd_cubism\gd_cubism>scons platform=windows vsproj=yes arch=x86_64 target=template_debug
scons: Reading SConscript files ...
WARNING: Unknown SCons variables were passed and will be ignored:
    vsproj=yes
Auto-detected 32 CPU cores available for build parallelism. Using 31 cores by default. You can override it with the -j argument.
Building for architecture x86_64 on platform windows

--- GDCubism ---

     CUBISM_NATIVE_CORE_DIR = thirdparty\CubismSdkForNative-5-r.1\Core
CUBISM_NATIVE_FRAMEWORK_DIR = thirdparty\CubismSdkForNative-5-r.1\Framework
   CUBISM_MOTION_CUSTOMDATA = 1
COUNTERMEASURES_90017_90030 = 1
                   platform = windows
                       arch = x86_64
               MSVC_VERSION = (undefined)
KeyError: 'MSVC_VERSION':
  File "E:\godot_code\gd_cubism\gd_cubism\SConstruct", line 85:
    .joinpath(env["MSVC_VERSION"].replace(".", ""))
  File "C:\Users\25230\scoop\apps\python\current\Lib\site-packages\SCons\Environment.py", line 587:
    return self._dict[key]

So added version info in .\SConstruct:

# Set MSVC_VERSION if not already set
msvc_version = env.get("MSVC_VERSION", "14.3")  # Set default MSVC version here
env["MSVC_VERSION"] = msvc_version
print("               MSVC_VERSION = {:s}".format(msvc_version))

Compilation is complete. During linking, errors like these happened:

 Linking Shared Library demo\addons\gd_cubism\bin\libgd_cubism.windows.debug.x86_64.dll ...
=====
Warning: corrupt .drectve at end of def file
Warning: corrupt .drectve at end of def file
Warning: corrupt .drectve at end of def file
Warning: corrupt .drectve at end of def file
Warning: corrupt .drectve at end of def file
Warning: corrupt .drectve at end of def file
Warning: corrupt .drectve at end of def file
Warning: corrupt .drectve at end of def file
Warning: corrupt .drectve at end of def file
Warning: corrupt .drectve at end of def file
Warning: corrupt .drectve at end of def file
Warning: corrupt .drectve at end of def file
Warning: corrupt .drectve at end of def file
...
...
...
C:/Users/25230/scoop/apps/mingw/13.2.0-rt_v11-rev1/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: thirdparty\CubismSdkForNative-5-r.1\Core\lib\windows\x86_64\143\Live2DCubismCore_MT.lib(CMakeFiles/Live2DCubismCore_MT.dir/src/DebugUtils.c.obj):(.xdata[$unwind$csmiDebugPrint]+0x8): undefined reference to `__GSHandlerCheck'
C:/Users/25230/scoop/apps/mingw/13.2.0-rt_v11-rev1/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: thirdparty\CubismSdkForNative-5-r.1\Core\lib\windows\x86_64\143\Live2DCubismCore_MT.lib(CMakeFiles/Live2DCubismCore_MT.dir/src/platforms/PlatformLogger.c.obj):(.text$mn+0x1f): undefined reference to `__security_cookie'
C:/Users/25230/scoop/apps/mingw/13.2.0-rt_v11-rev1/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: thirdparty\CubismSdkForNative-5-r.1\Core\lib\windows\x86_64\143\Live2DCubismCore_MT.lib(CMakeFiles/Live2DCubismCore_MT.dir/src/platforms/PlatformLogger.c.obj):(.text$mn+0x36): undefined reference to `__local_stdio_printf_options'
C:/Users/25230/scoop/apps/mingw/13.2.0-rt_v11-rev1/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: thirdparty\CubismSdkForNative-5-r.1\Core\lib\windows\x86_64\143\Live2DCubismCore_MT.lib(CMakeFiles/Live2DCubismCore_MT.dir/src/platforms/PlatformLogger.c.obj):(.text$mn+0x78): undefined reference to `__security_check_cookie'
C:/Users/25230/scoop/apps/mingw/13.2.0-rt_v11-rev1/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: thirdparty\CubismSdkForNative-5-r.1\Core\lib\windows\x86_64\143\Live2DCubismCore_MT.lib(CMakeFiles/Live2DCubismCore_MT.dir/src/platforms/PlatformLogger.c.obj):(.xdata[$unwind$csmiForceLogPrint]+0xc): undefined reference to `__GSHandlerCheck'
C:/Users/25230/scoop/apps/mingw/13.2.0-rt_v11-rev1/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: thirdparty\CubismSdkForNative-5-r.1\Core\lib\windows\x86_64\143\Live2DCubismCore_MT.lib(CMakeFiles/Live2DCubismCore_MT.dir/src/platforms/PlatformLogger_Win.c.obj):(.text$mn+0x55): undefined reference to `fprintf'
collect2.exe: error: ld returned 1 exit status

=====
scons: *** [demo\addons\gd_cubism\bin\libgd_cubism.windows.debug.x86_64.dll] Error 1
scons: building terminated because of errors.

E:\godot_code\gd_cubism\gd_cubism>

Is this a bug? How can I solve this?

MizunagiKB commented 2 months ago

@Irrawa Thank you for reporting the issue that occurred during the build process.

Upon reviewing the build logs, it appears that Visual Studio is not installed in your environment, and MinGW is being used instead.

While Godot Engine supports building with MinGW, the CubismSDK used by GDCubism is provided as a library intended for Visual Studio.

The following information is available on Live2D's webpage:

https://github.com/Live2D/CubismNativeSamples/blob/develop/README.md

Visual Studio 2013    Update 5
Visual Studio 2015    Update 3
Visual Studio 2017    15.9.60
Visual Studio 2019    16.11.34
Visual Studio 2022    17.9.4

Since the libraries included with CubismSDK are provided only as binaries and not as source code, using a development environment other than those listed above may result in link failures due to runtime discrepancies or symbol information mismatches, even if the compilation succeeds.

As I am not well-versed in MinGW, I cannot propose a specific solution, but it is likely that some work will be required to convert the Visual Studio libraries for use with MinGW.

If it is not inconvenient, I recommend installing Visual Studio 2022 Community.

https://visualstudio.microsoft.com/vs/community/

Irrawa commented 2 months ago

Thank you for your kind suggestion, and I finally solved the problem. I used Visual Studio all the time actually, but since I works on other projects, UE and other toolkits are also installed. After I completely uninstalled Visual Studio and reinstalled it with only C++ desktop toolkit, errors disappeared and the build was successful. I guess there were some conflicts or so.