tslabs / zx-evo

TS-Configuration for ZX Spectrum clone named ZX-Evolution
60 stars 21 forks source link

Visual Studio 2015 compilation issues #64

Closed oboroc closed 7 years ago

oboroc commented 7 years ago

I opened Unreal_2010.sln with Visual Studio 2015. tslabs, you mentioned you're using it. First time I opened it, VS2015 prompted me to upgrade project and solution. I let it. Then I tried to build solution, I got this error:

1>LIBCMTD.lib(swprintf.obj) : error LNK2001: unresolved external symbol __swprintf
1>bin\Debug\Unreal.exe : fatal error LNK1120: 1 unresolved externals
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

There is a Stack Overflow discussion about unresolved external symbol sprintf and sscanf in Visual Studio 2015. The problem is that project contains *.lib files that were compiled using older versions of Visual C++. Those older versions expected linkable versions of standard C library functions, including swprintf(). Visual C++ 2015 is using inline versions for those functions, and so linker can't find linkable versions.

*.lib files in Unreal project:

zx-evo\pentevo\unreal\Unreal\lib\dinput.lib
zx-evo\pentevo\unreal\Unreal\lib\dxerr8.lib
zx-evo\pentevo\unreal\Unreal\ft8xx\ft8xxemu.lib

The quick and dirty fix is to add legacy_stdio_definitions.lib to project. This will restore old linkable standard C library functions.

Best fix is to replace *.lib with some stub code that has function declarations and load needed DLLs at run-time. Here is a good example on Stack Overflow: Dynamically load a function from a DLL.

thims commented 7 years ago

Fixed by adding solution and project for VS2015 and removing dependencies on dinput&dxerr8. Please check if it works ok.

oboroc commented 7 years ago

Thanks for looking into it! I tried to compile with Unreal_2015.sln. "Debug Unreal - Win32" target builds fine, "Release Unreal - Win32" fails to build. Compilation itself works fine, but something fails in post-build parts:

1>  Updating archive C:\Users\Adrian\Documents\GitHub\zx-evo\pentevo\unreal\Unreal\bin\Release\..\unreal.7z
1>
1>
1>
1>EXEC : System error :
1>  Not implemented
1>
1>
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: The command "rd /q /s "C:\Users\Adrian\Documents\GitHub\zx-evo\pentevo\unreal\Unreal\bin\Release\rom"
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: md "C:\Users\Adrian\Documents\GitHub\zx-evo\pentevo\unreal\Unreal\bin\Release\rom"
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: md "C:\Users\Adrian\Documents\GitHub\zx-evo\pentevo\unreal\Unreal\bin\Release\doc"
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: copy /y "C:\Users\Adrian\Documents\GitHub\zx-evo\pentevo\unreal\Unreal\lib\*.dll" "C:\Users\Adrian\Documents\GitHub\zx-evo\pentevo\unreal\Unreal\bin\Release\"
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: copy /y "C:\Users\Adrian\Documents\GitHub\zx-evo\pentevo\unreal\Unreal\cfg\*.*" "C:\Users\Adrian\Documents\GitHub\zx-evo\pentevo\unreal\Unreal\bin\Release\"
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: copy /y "C:\Users\Adrian\Documents\GitHub\zx-evo\pentevo\unreal\Unreal\cfg\rom\*.*" "C:\Users\Adrian\Documents\GitHub\zx-evo\pentevo\unreal\Unreal\bin\Release\rom"
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: copy /y "C:\Users\Adrian\Documents\GitHub\zx-evo\pentevo\unreal\Unreal\doc\*.*" "C:\Users\Adrian\Documents\GitHub\zx-evo\pentevo\unreal\Unreal\bin\Release\doc"
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: ..\..\tools\7z\7z.exe e -y -bd -o"C:\Users\Adrian\Documents\GitHub\zx-evo\pentevo\unreal\Unreal\bin\Release\" .\cfg\hdd\wc.7z
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: ..\..\tools\7z\7z.exe a -r -mx9 -y -bd "C:\Users\Adrian\Documents\GitHub\zx-evo\pentevo\unreal\Unreal\bin\Release\..\unreal.7z" "C:\Users\Adrian\Documents\GitHub\zx-evo\pentevo\unreal\Unreal\bin\Release\*"
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073:
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: :VCEnd" exited with code 2.
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
thims commented 7 years ago

Actually, this bug exists in all solutions. You need to delete the unreal\bin\unreal.7z manually before building the Rrelease. I'll fix it later.

oboroc commented 7 years ago

@thims, so if I want to build release, I shouldn't build debug first?

oboroc commented 7 years ago

ok, I'll close this issue. Thanks, @thims