wyatt8740 / Game_Music_Emu

(GitLab: https://gitlab.com/wyatt8740/Game_Music_Emu ) - Fork of https://github.com/kode54/Game_Music_Emu that restores a cross-platform CMake build system. Currently, aims to be ABI-compatible with GME 0.6.2.
1 stars 2 forks source link

Issues when linking with MINGW #1

Closed SteelT1 closed 6 years ago

SteelT1 commented 6 years ago

It compiles just fine, but when attempting to link. It errors out with ld.exe: unrecognized option '-z'

wyatt8740 commented 6 years ago

You need to install zlib. https://zlib.net/

wyatt8740 commented 6 years ago

If that doesn't fix the issue, tell me. Otherwise, I'll close this in a few days.

SteelT1 commented 6 years ago

After installing zlib and changing the compile flags to -Wl,-lz it linked just fine.

wyatt8740 commented 6 years ago

Huh, I guess I'll try it out in mingw. Are you doing it on windows, or cross compiling targetting windows?

And is this mingw32? or mingw-w64?

I also suspect but cannot yet confirm that using the MinGW toolchain that is offered in the cygwin setup wizard would solve this problem, too.

SteelT1 commented 6 years ago

Windows, mingw-w64.

wyatt8740 commented 6 years ago

OK, I think I've fixed building in windows. Delete your cmakecache.txt, do a git pull, and try again. I'll close this in a few hours if it fixed it.

I tested it in Windows 7, with Cygwin, using a Mingw-w64 toolchain and this command: cmake -DCMAKE_TOOLCHAIN_FILE=~/crosscompile.cmake .. With this cross-compilation script (crosscompile.cmake):

# this one is important
SET(CMAKE_SYSTEM_NAME Windows)
#this one not so much
SET(CMAKE_SYSTEM_VERSION 1)
# specify the cross compiler
set(CMAKE_C_COMPILER   /usr/bin/i686-w64-mingw32-gcc)
SET(CMAKE_CXX_COMPILER /usr/bin/i686-w64-mingw32-g++)
# where is the target environment
SET(CMAKE_FIND_ROOT_PATH   /usr/i686-w64-mingw32/sys-root/mingw)
# search for programs in the build host directories
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# for libraries and headers in the target directories
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

Initially, I had the same problem you described. After adding a condition for WIN32 builds to disable the sanitizer library (which did not work in Windows), and altering one other line relating to the linker, it built.

wyatt8740 commented 6 years ago

(should be fixed in 1a9879f)

SteelT1 commented 6 years ago

Sorry for late update, kinda forgot about it. But I can confirm it works

wyatt8740 commented 6 years ago

@SteelTitanium Thanks. I'll close this one, then.