djdron / UnrealSpeccyP

Portable ZX-Spectrum emulator supports Z80 128K (Pentagon) AY/YM, Beeper, Beta Disk, Tape, Kempston Joystick/Mouse, Snapshots, Replays.
https://bitbucket.org/djdron/unrealspeccyp
Other
63 stars 14 forks source link

Fix the build on macOS #7

Closed morozov closed 2 years ago

morozov commented 2 years ago

These are the changes I got to make in order to build the project in Xcode on macOS (note, I have zero experience in this, so these changes may be incorrect from the whole project perspective). Please see the details in the commit messages.

Right before posting the pull request, I realized that wxWidgets is meant to be installed as a Git submodule. But if I do so, the includes like #include <wx/wx.h> still won't work because the headers are unavailable system-wide.

Please let me know how you'd prefer to address the wxWidgets dependency issue. Or am I just installing it wrong?

djdron commented 2 years ago

Hello, Sergei!) I appreciate your work to compile USP for macOS. But you've used an old method. The new one is to use CMake.

You need Xcode command line tools & CMake to be installed.

Fetch required submodules (from usp root folder). git submodule update --init --recursive

Build files placed in build/cmake folder. All you need is to create some build folder inside build/cmake like build/cmake/build_osx_wx.

Generate project files cmake .. -G "Unix Makefiles" -DUSE_WX_WIDGETS=1 -DUSE_SDL=0 -DCMAKE_BUILD_TYPE=Release

You can use -G Xcode to generate Xcode project files. Run build command: cmake --build . -- -j8

But now CMakeLists.txt is not correctly tuned to build .app bundle. Now it builds just binary. Need to fix it like it does in SDL2 version path.

morozov commented 2 years ago

@djdron, thanks for the recommendations. I tried building it the right way from master, and the build failed with the following messages:

$ git submodule update --init --recursive
$ mkdir build/cmake/build_osx_wx
$ cd build/cmake/build_osx_wx
$ cmake .. -G "Unix Makefiles" -DUSE_WX_WIDGETS=1 -DUSE_SDL=0 -DCMAKE_BUILD_TYPE=Release
...
-- Build files have been written to: /Users/smorozov/Projects/usp/build/cmake/build_osx_wx

$ cmake --build . -- -j8
...
[ 32%] Linking CXX static library ../../../lib/libwx_baseu-3.1.a
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../lib/libwx_baseu-3.1.a(memory.cpp.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../lib/libwx_baseu-3.1.a(wxprintf.cpp.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../lib/libwx_baseu-3.1.a(xti.cpp.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../lib/libwx_baseu-3.1.a(xtistrm.cpp.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../lib/libwx_baseu-3.1.a(fswatcherg.cpp.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../lib/libwx_baseu-3.1.a(lzmastream.cpp.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../lib/libwx_baseu-3.1.a(epolldispatcher.cpp.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../lib/libwx_baseu-3.1.a(fdiounix.cpp.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../lib/libwx_baseu-3.1.a(utils.mm.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../lib/libwx_baseu-3.1.a(memory.cpp.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../lib/libwx_baseu-3.1.a(wxprintf.cpp.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../lib/libwx_baseu-3.1.a(xti.cpp.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../lib/libwx_baseu-3.1.a(xtistrm.cpp.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../lib/libwx_baseu-3.1.a(fswatcherg.cpp.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../lib/libwx_baseu-3.1.a(lzmastream.cpp.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../lib/libwx_baseu-3.1.a(epolldispatcher.cpp.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../lib/libwx_baseu-3.1.a(fdiounix.cpp.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../lib/libwx_baseu-3.1.a(utils.mm.o) has no symbols
[ 32%] Built target wxbase
make: *** [all] Error 2

See the full build log.

Is there another missing step on my end? FWIW, I'm trying to build it just to use it myself since I couldn't find an official macOS build anywhere. If you could release one yourself, it might simplify things for both of us :-)

djdron commented 2 years ago

@morozov , seems wxWidgets libtiff (usp/3rdparty/wxWidgets/src/tiff/libtiff) somehow conflicts with system installed /usr/local/include/tiffconf.h

Official build for macOS is SDL2 version. You can find it in bitbucket download section (dmg). Here is the Docker build setup for macOS (used in AppVeyor test build).

djdron commented 2 years ago

@morozov , BTW, just kicked AppVeyor build, you may grab artifacts from here (Image:Ubuntu) after successful build.

morozov commented 2 years ago

Thanks for pointing out the official build. I believe I found it earlier but got confused that it's not signed.

The docker image worked for me as well.