soulweaver91 / project-carrot

Project Carrot, an open source spiritual clone of the Jazz Jackrabbit 2 game engine
https://carrot.soulweaver.fi/
MIT License
38 stars 4 forks source link

Add macOS support #56

Closed soulweaver91 closed 7 years ago

soulweaver91 commented 7 years ago

Now that I have a device for this, the support for macOS should be considered. So far, this script derived naïvely from the Linux one seems to be close to what is needed:

# Install required packages
brew install qt5 sfml
brew link qt5 --force
cd ~
curl -o bass24.zip http://us.un4seen.com/files/bass24-osx.zip
curl -o bassfx24.zip http://us.un4seen.com/files/z/0/bass_fx24-osx.zip
unzip bass24.zip -d bass
unzip bassfx24.zip -d bassfx
rm bass24.zip bassfx24.zip
# Set up the necessary environment
export BASS_DIR=~/bass
export BASS_FX_DIR=~/bassfx
export SFML_DIR=/usr/local/Cellar/sfml/2.4.1
# Clone this repository and compile the code
git clone https://github.com/soulweaver91/project-carrot.git
cd project-carrot
qmake -spec macx-clang
make release
# Move to the release folder and copy the BASS and BASS FX library files
cd Release
cp $BASS_DIR/libbass.dylib .
cp $BASS_FX_DIR/libbass_fx.dylib .

This works well, until the part where it doesn't compile 😛

In file included from /usr/local/Cellar/qt5/5.7.0/lib/QtCore.framework/Headers/QBitArray:1:
In file included from /usr/local/Cellar/qt5/5.7.0/lib/QtCore.framework/Headers/qbitarray.h:43:
In file included from /usr/local/Cellar/qt5/5.7.0/lib/QtCore.framework/Headers/qbytearray.h:44:
In file included from /usr/local/Cellar/qt5/5.7.0/lib/QtCore.framework/Headers/qrefcount.h:43:
In file included from /usr/local/Cellar/qt5/5.7.0/lib/QtCore.framework/Headers/qatomic.h:41:
In file included from /usr/local/Cellar/qt5/5.7.0/lib/QtCore.framework/Headers/qglobal.h:94:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:3642:20: error: 
      no matching function for call to '__sort3'
    unsigned __r = __sort3<_Compare>(__x1, __x2, __x3, __c);
                   ^~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:3862:20: note: 
      in instantiation of function template specialization
      'std::__1::__sort4<std::__1::__less<TileMapLayer, TileMapLayer> &,
      TileMapLayer *>' requested here
            _VSTD::__sort4<_Compare>(__first, __first+1, __first+2, --__...
                   ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:4041:5: note: 
      in instantiation of function template specialization
      'std::__1::__sort<std::__1::__less<TileMapLayer, TileMapLayer> &,
      TileMapLayer *>' requested here
    __sort<_Comp_ref>(__first, __last, __comp);
    ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:4050:12: note: 
      in instantiation of function template specialization
      'std::__1::sort<TileMapLayer *, std::__1::__less<TileMapLayer,
      TileMapLayer> >' requested here
    _VSTD::sort(__first, __last, __less<typename iterator_traits<_Random...
           ^
src/gamestate/TileMap.cpp:506:18: note: in instantiation of function template
      specialization 'std::__1::sort<TileMapLayer *>' requested here
            std::sort(levelLayout.begin(),levelLayout.end());
                 ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:3602:1: note: 
      candidate template ignored: substitution failure [with _Compare =
      std::__1::__less<TileMapLayer, TileMapLayer> &, _ForwardIterator =
      TileMapLayer *]
__sort3(_ForwardIterator __x, _ForwardIterator __y, _ForwardIterator __z...
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:3668:20: error: 
      no matching function for call to '__sort4'
    unsigned __r = __sort4<_Compare>(__x1, __x2, __x3, __x4, __c);
                   ^~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:3865:20: note: 
      in instantiation of function template specialization
      'std::__1::__sort5<std::__1::__less<TileMapLayer, TileMapLayer> &,
      TileMapLayer *>' requested here
            _VSTD::__sort5<_Compare>(__first, __first+1, __first+2, __fi...
                   ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:4041:5: note: 
      in instantiation of function template specialization
      'std::__1::__sort<std::__1::__less<TileMapLayer, TileMapLayer> &,
      TileMapLayer *>' requested here
    __sort<_Comp_ref>(__first, __last, __comp);
    ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:4050:12: note: 
      in instantiation of function template specialization
      'std::__1::sort<TileMapLayer *, std::__1::__less<TileMapLayer,
      TileMapLayer> >' requested here
    _VSTD::sort(__first, __last, __less<typename iterator_traits<_Random...
           ^
src/gamestate/TileMap.cpp:506:18: note: in instantiation of function template
      specialization 'std::__1::sort<TileMapLayer *>' requested here
            std::sort(levelLayout.begin(),levelLayout.end());
                 ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:3639:1: note: 
      candidate template ignored: substitution failure [with _Compare =
      std::__1::__less<TileMapLayer, TileMapLayer> &, _ForwardIterator =
      TileMapLayer *]
__sort4(_ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3,
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:3733:5: error: 
      no matching function for call to '__sort3'
    __sort3<_Compare>(__first, __first+1, __j, __comp);
    ^~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:3870:20: note: 
      in instantiation of function template specialization
      'std::__1::__insertion_sort_3<std::__1::__less<TileMapLayer, TileMapLayer>
      &, TileMapLayer *>' requested here
            _VSTD::__insertion_sort_3<_Compare>(__first, __last, __comp);
                   ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:4041:5: note: 
      in instantiation of function template specialization
      'std::__1::__sort<std::__1::__less<TileMapLayer, TileMapLayer> &,
      TileMapLayer *>' requested here
    __sort<_Comp_ref>(__first, __last, __comp);
    ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:4050:12: note: 
      in instantiation of function template specialization
      'std::__1::sort<TileMapLayer *, std::__1::__less<TileMapLayer,
      TileMapLayer> >' requested here
    _VSTD::sort(__first, __last, __less<typename iterator_traits<_Random...
           ^
src/gamestate/TileMap.cpp:506:18: note: in instantiation of function template
      specialization 'std::__1::sort<TileMapLayer *>' requested here
            std::sort(levelLayout.begin(),levelLayout.end());
                 ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:3602:1: note: 
      candidate template ignored: substitution failure [with _Compare =
      std::__1::__less<TileMapLayer, TileMapLayer> &, _ForwardIterator =
      TileMapLayer *]
__sort3(_ForwardIterator __x, _ForwardIterator __y, _ForwardIterator __z...
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:3766:9: error: 
      no matching function for call to '__sort3'
        _VSTD::__sort3<_Compare>(__first, __first+1, --__last, __comp);
        ^~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__config:397:15: note: 
      expanded from macro '_VSTD'
#define _VSTD std::_LIBCPP_NAMESPACE
              ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:3996:32: note: 
      in instantiation of function template specialization
      'std::__1::__insertion_sort_incomplete<std::__1::__less<TileMapLayer,
      TileMapLayer> &, TileMapLayer *>' requested here
            bool __fs = _VSTD::__insertion_sort_incomplete<_Compare>(__f...
                               ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:4041:5: note: 
      in instantiation of function template specialization
      'std::__1::__sort<std::__1::__less<TileMapLayer, TileMapLayer> &,
      TileMapLayer *>' requested here
    __sort<_Comp_ref>(__first, __last, __comp);
    ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:4050:12: note: 
      in instantiation of function template specialization
      'std::__1::sort<TileMapLayer *, std::__1::__less<TileMapLayer,
      TileMapLayer> >' requested here
    _VSTD::sort(__first, __last, __less<typename iterator_traits<_Random...
           ^
src/gamestate/TileMap.cpp:506:18: note: in instantiation of function template
      specialization 'std::__1::sort<TileMapLayer *>' requested here
            std::sort(levelLayout.begin(),levelLayout.end());
                 ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:3602:1: note: 
      candidate template ignored: substitution failure [with _Compare =
      std::__1::__less<TileMapLayer, TileMapLayer> &, _ForwardIterator =
      TileMapLayer *]
__sort3(_ForwardIterator __x, _ForwardIterator __y, _ForwardIterator __z...
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:3769:9: error: 
      no matching function for call to '__sort4'
        _VSTD::__sort4<_Compare>(__first, __first+1, __first+2, --__last...
        ^~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__config:397:15: note: 
      expanded from macro '_VSTD'
#define _VSTD std::_LIBCPP_NAMESPACE
              ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:3639:1: note: 
      candidate template ignored: substitution failure [with _Compare =
      std::__1::__less<TileMapLayer, TileMapLayer> &, _ForwardIterator =
      TileMapLayer *]
__sort4(_ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3,
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:3772:9: error: 
      no matching function for call to '__sort5'
        _VSTD::__sort5<_Compare>(__first, __first+1, __first+2, __first+...
        ^~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__config:397:15: note: 
      expanded from macro '_VSTD'
#define _VSTD std::_LIBCPP_NAMESPACE
              ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:3665:1: note: 
      candidate template ignored: substitution failure [with _Compare =
      std::__1::__less<TileMapLayer, TileMapLayer> &, _ForwardIterator =
      TileMapLayer *]
__sort5(_ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3,
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:3777:5: error: 
      no matching function for call to '__sort3'
    __sort3<_Compare>(__first, __first+1, __j, __comp);
    ^~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:3602:1: note: 
      candidate template ignored: substitution failure [with _Compare =
      std::__1::__less<TileMapLayer, TileMapLayer> &, _ForwardIterator =
      TileMapLayer *]
__sort3(_ForwardIterator __x, _ForwardIterator __y, _ForwardIterator __z...
^
8 errors generated.
make[1]: *** [Release/TileMap.o] Error 1

Things to add to repo or fix:

soulweaver91 commented 7 years ago

Fix for the compile failure found and more progress done. New script:

# Install required packages
brew install qt5 sfml
brew link qt5 --force
cd ~
# Download BASS and BASS FX
curl -o bass24.zip http://us.un4seen.com/files/bass24-osx.zip
curl -o bassfx24.zip http://us.un4seen.com/files/z/0/bass_fx24-osx.zip
unzip bass24.zip -d bass
unzip bassfx24.zip -d bassfx
rm bass24.zip bassfx24.zip
# Set up the necessary environment
export BASS_DIR=~/bass
export BASS_FX_DIR=~/bassfx
export SFML_DIR=/usr/local/Cellar/sfml/2.4.1
# Clone this repository and compile the code
git clone https://github.com/soulweaver91/project-carrot.git
cd project-carrot
qmake -spec macx-clang
make release
# Copy Qt and SFML dependencies into the bundle (only necessary for distribution)
macdeployqt Release/CarrotQt5.app
# Copy the BASS and BASS FX library files into the bundle
mkdir -p Release/CarrotQt5.app/Contents/Plugins/
cp -r $BASS_DIR/libbass.dylib Release/CarrotQt5.app/Contents/Plugins/
cp -r $BASS_FX_DIR/libbass_fx.dylib Release/CarrotQt5.app/Contents/Plugins/
install_name_tool -change @loader_path/libbass.dylib @executable_path/../Plugins/libbass.dylib Release/CarrotQt5.app/Contents/MacOS/CarrotQt5 
install_name_tool -change @loader_path/libbass_fx.dylib @executable_path/../Plugins/libbass_fx.dylib Release/CarrotQt5.app/Contents/MacOS/CarrotQt5 

After this, it starts up. The path it tries to find the files from is wrong, though, and as a result it bails out after failing to load the fonts.

soulweaver91 commented 7 years ago

With the debug config that uses the current directory always, we're getting past that, but:

http://pastebin.com/BRq8aigD :boom:

Apparently sf::RenderWindow::create((sf::WindowHandle)winId()); is what crashes it. There's some special code for X11 right above it, so maybe there needs to be a bit more of something for it to work properly.

soulweaver91 commented 7 years ago

:tada:

screenshot 2016-12-15 at 00 42 36

The question is, what was the relevant change when built via Xcode? The only new code difference was fixing the directory the resources are searched from.