libretro / easyrpg-libretro

⚠️⚠️⚠️ DON'T USE THIS FORK FOR YOUR OWN BUILDS / PACKAGES / ETC ⛔️⛔️⛔️ NO SUPPORT WHEN YOU USE IT ⚠️⚠️⚠️ It is only used by the libretro buildbot. ❤️❤️❤️ For your own builds use the upstream repository: https://github.com/EasyRPG/Player/ (See: "Building a libretro core" in the Readme) ❤️❤️❤️
https://easyrpg.org/
GNU General Public License v3.0
10 stars 8 forks source link

How to compile the libretro core on windows with visual studio 2015 community edition? #35

Closed whocares0101 closed 5 years ago

whocares0101 commented 5 years ago

The instructions in README.md don't work for me.

Software:

VS2015 Update3 community edition on win7 x64 cmake version 3.10.2

What I tried:

cloned https://github.com/libretro/easyrpg-libretro.git to C:\tmp\easyrpg-libretro

git submodule init
Submodule 'builds/libretro/libretro-common' (https://github.com/libretro/libretr
o-common) registered for path 'builds/libretro/libretro-common'

git submodule update
Cloning into 'C:/tmp/easyrpg-libretro/builds/libretro/libretro-common'...
Submodule path 'builds/libretro/libretro-common': checked out '79c6979d34298bcb3
d67ad64d937c9140d54df9f'

cmake . -DPLAYER_TARGET_PLATFORM=libretro -DBUILD_SHARED_LIBS=ON
-- Building for: Visual Studio 14 2015
-- The CXX compiler identification is MSVC 19.0.24215.1
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studi
o 14.0/VC/bin/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studi
o 14.0/VC/bin/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Windows: Using dynamic runtime library (/MD)
-- The C compiler identification is MSVC 19.0.24215.1
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio
14.0/VC/bin/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio
14.0/VC/bin/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check if the system is big endian
-- Searching 16 bit integer
-- Looking for C++ include sys/types.h
-- Looking for C++ include sys/types.h - found
-- Looking for C++ include stdint.h
-- Looking for C++ include stdint.h - found
-- Looking for C++ include stddef.h
-- Looking for C++ include stddef.h - found
-- Check size of unsigned short
-- Check size of unsigned short - done
-- Using unsigned short
-- Check if the system is big endian - little endian
CMake Error at CMakeLists.txt:246 (find_package):
  By not providing "Findliblcf.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "liblcf", but
  CMake did not find one.

  Could not find a package configuration file provided by "liblcf" with any
  of the following names:

    liblcfConfig.cmake
    liblcf-config.cmake

  Add the installation prefix of "liblcf" to CMAKE_PREFIX_PATH or set
  "liblcf_DIR" to a directory containing one of the above files.  If "liblcf"
  provides a separate development package or SDK, be sure it has been
  installed.

-- Configuring incomplete, errors occurred!
See also "C:/tmp/easyrpg-libretro/CMakeFiles/CMakeOutput.log".

Adding -DPLAYER_BUILD_LIBLCF=ON didn't work either.

cmake . -DPLAYER_TARGET_PLATFORM=libretro -DBUILD_SHARED_LIBS=ON -DPLAYER_BUILD_LIBLCF=ON
-- Windows: Using dynamic runtime library (/MD)
-- Found Git: C:/Program Files/Git/cmd/git.exe (found version "2.20.0.windows.1"
)
Cloning into 'C:/tmp/easyrpg-libretro/lib/liblcf'...
-- Windows: Using dynamic runtime library (/MD)
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
-- The following ICU libraries were not found:
--   i18n (required)
--   uc (required)
--   data (required)
CMake Error at C:/Program Files/CMake/share/cmake-3.10/Modules/FindPackageHandle
StandardArgs.cmake:137 (message):
  Failed to find all ICU components (missing: ICU_INCLUDE_DIR ICU_LIBRARY
  _ICU_REQUIRED_LIBS_FOUND)
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.
cmake:378 (_FPHSA_FAILURE_MESSAGE)
  lib/liblcf/builds/cmake/Modules/FindICU.cmake:317 (FIND_PACKAGE_HANDLE_STANDAR
D_ARGS)
  lib/liblcf/CMakeLists.txt:149 (find_package)

-- Configuring incomplete, errors occurred!
See also "C:/tmp/easyrpg-libretro/CMakeFiles/CMakeOutput.log".
Ghabry commented 5 years ago

The instructions are outdated, you have to use the one in the upstream repo. In short: You can't use these "baked in" libraries for MSVC (I discourage using them in general, but there buildbots need them....)

First you must install all dependencies through vcpkg:

Clone https://github.com/EasyRPG/buildscripts/ and run windows\build.cmd This will compile all dependencies except liblcf. Takes at least 1h, compiling this is slow.... (you can save some time by deleting the x86 or x64 build line from build.cmd, depending on what you don't need)

For compiling liblcf you can't currently use upstream because it is already again diverged too much. Use the bundled liblcf instead: builds/libretro/deps/libretro/liblcf/ When you copy-paste that liblcf folder to lib/liblcf it will work with -DPLAYER_BUILD_LIBLCF=ON btw.

The CMake configuration for Player:

cmake -DSHARED_RUNTIME=OFF -DVCPKG_TARGET_TRIPLET=x64-windows-static
  -DCMAKE_TOOLCHAIN_FILE=[CHANGE_TO_VCPKG_PATH]\scripts\buildsystems\vcpkg.cmake
  -DCMAKE_BUILD_TYPE=Release -DPLAYER_TARGET_PLATFORM=libretro
  -DPLAYER_BUILD_LIBLCF=ON

for x86 it is x86-windows-static

whocares0101 commented 5 years ago

This still doesn't work.

I used build.cmd, without the x86 part it took around 20 minutes. There was an error mentioning msys2 (build_log.txt) not sure if this is a real problem, the script continued anyway.

Cmake worked by the looks of it, it generated a VS solution and project files. cmake_log.txt

But VS generated 218 errors (vs_log.txt) for EasyRPG_Player. Also platform shows Win32 everywhere, not sure if this is ok or not.

Ghabry commented 5 years ago

The vcpkg and CMake logfiles look fine.

About the VS build errors: Right, these are also things that were fixed upstream already. Ensure first that you have the latest version of VS2015 (all updates installed, otherwise /utf-8 is unavailable).

Add these 4 lines to the CMakeLists.txt: https://github.com/EasyRPG/Player/blob/master/CMakeLists.txt#L388

# MSVC: Set UTF-8 encoding for all files (important for rtp table)
if(MSVC)
    target_compile_options(${PROJECT_NAME} PRIVATE "/utf-8")
endif()

Delete the CMakeCache.txt afterwards before rerunning CMake to generate the Visual Studio project.

Also platform shows Win32 everywhere, not sure if this is ok or not.

No, this is wrong. Before generating the Visual Studio project with CMake open from the start menu a "Visual Studio command prompt". Select the x64 or x86_x64 cross tools one.

In the toolbar you should be able to switch to x64 and Release.

whocares0101 commented 5 years ago

Even with VS2015 x64 Native Tools Command Prompt I get Win32 in the configuration manager, no idea why, I changed this manually to x64.

The projects lcf, retro_common, and EasyRPG_Player have /machine:X86 set under additional options which needs to be changed manually for x64.

The default for EasyRPG_Player is to build a static library, I changed it to dynamic.

The project retro_common uses /MD(d), lcf and EasyRPG_Player use /MT(d), I changed it to /MT(d).

Needed to add the library path to the VC directories > C:\tmp\buildscripts\windows\vcpkg\installed\x64-windows-static\lib Also needed to manually add the static libraries to EasyRPG_Player additional dependencies.

There are four instances of DEBUG_VALIDATE(); in scene.cpp which are undeclared, I just commented them. scene.cpp(161): error C2065: '__PRETTY_FUNCTION__': undeclared identifier

The debug release does not compile icuin.lib(csdetect.ao) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in async_handler.obj according to https://stackoverflow.com/a/12950627/1373630 this is a mismatch between debug and release runtimes. But I have set lcf, retro_common, and EasyRPG_Player to /MTd, maybe ICU uses /MT? vs_debug_log.txt

The release build did compile however and can be loaded with RetroArch it also gets me to the title screen of VD2 and reliably crashes with command line arguments.

Here are the sln and project files created by cmake and the ones I have modified. vs_sln_cmake.zip vs_sln_mod.zip

Ghabry commented 5 years ago

I always use the built-in CMake support in Visual Studio 2017, therefore I sometimes forget some stuff.

Well "-DSHARED_RUNTIME=OFF" will use "/MT" (or /MTd) which matches the vcpkg configuration. To build a DLL use "-DBUILD_SHARED_LIBS=ON", I forgot this one.

When creating the project with CMake try generator '-G " Visual Studio 14 2015 Win64"'.

The library mismatch is a non fixable problem in the generator because it is a CMake limitation: The debug and release libraries are in different folders but some of them have the same name, therefore CMake will pick Debug even for Release (or Release for Debug).

That is the reason why you must specifiy the "-DCMAKE_BUILD_TYPE=Release" or "-DCMAKE_BUILD_TYPE=Debug" when generating the project. Is annoying but there is no way to solve it, even asked the vcpkg maintainers :/.

It also crashes with command line in Visual studio? Thats interesting, I assumed this is a MinGW problem.

whocares0101 commented 5 years ago

Building this is far too complicated for my taste, I'm not really using VS or C++ normally. But I got a build reatroarch would load and this was enough as it seems. So thanks for the support.