Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiling on OSX #3

Open
philippkeller opened this issue Oct 12, 2020 · 2 comments
Open

Compiling on OSX #3

philippkeller opened this issue Oct 12, 2020 · 2 comments

Comments

@philippkeller
Copy link

I tried to compile on OSX.
in IDE/VC/vcpkg/build_vcpkg.sh I replacedtriplet with x64-osx, then the build_vcpkg.sh ran through successfully.

After installing ninja with brew install ninja this step also worked:

cmake -G Ninja -DCMAKE_BUILD_TYPE:STRING=Release -DVCPKG_TARGET_TRIPLET:STRING=x64-linux ../../..

But now I'm stuck at cmake --build . with this error:

../../../src/main.cpp:75:14: fatal error: 'MacFunctions.h' file not found

I did cp IDE/xCode/MacFunctions.* src/ in order to provide the header file and replaced

    #include <MacFunctions.h>

With

    #include "MacFunctions.h"

There might be a smarter way to solve this…? Anyway: this made this error go away, but now I'm stuck at these errors:

philipp:..d/x64-Release% cmake --build .
[1/176] Building CXX object src/CMakeFiles/dune.dir/Bullet.cpp.o
FAILED: src/CMakeFiles/dune.dir/Bullet.cpp.o
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -DFMT_LOCALE -DNEED_DOUBLE_FROM_CHARS -DNEED_DOUBLE_TO_CHARS -DNEED_FLOAT_FROM_CHARS -DNEED_FLOAT_TO_CHARS -I../../../src/../include -I../../../src/../external/enet/include -I../../../external/digestpp/. -Iexternal/rectpack2D/include -isystem ../../../IDE/VC/vcpkg/vcpkg/installed/x64-osx/include -isystem ../../../IDE/VC/vcpkg/vcpkg/installed/x64-osx/include/SDL2 -O3 -DNDEBUG -flto=thin -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -std=c++17 -Winvalid-pch -Xclang -include-pch -Xclang /var/tmp/dunelegacy/out/build/x64-Release/src/CMakeFiles/dune.dir/cmake_pch.hxx.pch -Xclang -include -Xclang /var/tmp/dunelegacy/out/build/x64-Release/src/CMakeFiles/dune.dir/cmake_pch.hxx -MD -MT src/CMakeFiles/dune.dir/Bullet.cpp.o -MF src/CMakeFiles/dune.dir/Bullet.cpp.o.d -o src/CMakeFiles/dune.dir/Bullet.cpp.o -c ../../../src/Bullet.cpp
../../../src/Bullet.cpp:299:32: error: non-constant-expression cannot be narrowed from type 'long' to 'int' in initializer list [-Wc++11-narrowing]
        SDL_Rect scaled_source{lround(source.x * scaleX), lround(source.y * scaleY), lround(w * scaleX), lround(h * scaleY)};
                               ^~~~~~~~~~~~~~~~~~~~~~~~~
../../../src/Bullet.cpp:299:32: note: insert an explicit cast to silence this issue
        SDL_Rect scaled_source{lround(source.x * scaleX), lround(source.y * scaleY), lround(w * scaleX), lround(h * scaleY)};
                               ^~~~~~~~~~~~~~~~~~~~~~~~~
                               static_cast<int>(        )
../../../src/Bullet.cpp:299:59: error: non-constant-expression cannot be narrowed from type 'long' to 'int' in initializer list [-Wc++11-narrowing]
        SDL_Rect scaled_source{lround(source.x * scaleX), lround(source.y * scaleY), lround(w * scaleX), lround(h * scaleY)};
                                                          ^~~~~~~~~~~~~~~~~~~~~~~~~
../../../src/Bullet.cpp:299:59: note: insert an explicit cast to silence this issue
        SDL_Rect scaled_source{lround(source.x * scaleX), lround(source.y * scaleY), lround(w * scaleX), lround(h * scaleY)};
                                                          ^~~~~~~~~~~~~~~~~~~~~~~~~
                                                          static_cast<int>(        )
../../../src/Bullet.cpp:299:86: error: non-constant-expression cannot be narrowed from type 'long' to 'int' in initializer list [-Wc++11-narrowing]
        SDL_Rect scaled_source{lround(source.x * scaleX), lround(source.y * scaleY), lround(w * scaleX), lround(h * scaleY)};
                                                                                     ^~~~~~~~~~~~~~~~~~
../../../src/Bullet.cpp:299:86: note: insert an explicit cast to silence this issue
        SDL_Rect scaled_source{lround(source.x * scaleX), lround(source.y * scaleY), lround(w * scaleX), lround(h * scaleY)};
                                                                                     ^~~~~~~~~~~~~~~~~~
                                                                                     static_cast<int>( )
../../../src/Bullet.cpp:299:106: error: non-constant-expression cannot be narrowed from type 'long' to 'int' in initializer list [-Wc++11-narrowing]
        SDL_Rect scaled_source{lround(source.x * scaleX), lround(source.y * scaleY), lround(w * scaleX), lround(h * scaleY)};
                                                                                                         ^~~~~~~~~~~~~~~~~~
../../../src/Bullet.cpp:299:106: note: insert an explicit cast to silence this issue
        SDL_Rect scaled_source{lround(source.x * scaleX), lround(source.y * scaleY), lround(w * scaleX), lround(h * scaleY)};
                                                                                                         ^~~~~~~~~~~~~~~~~~
                                                                                                         static_cast<int>( )
4 errors generated.
[6/176] Building CXX object src/CMakeFiles/dunelegacy.dir/main.cpp.o
ninja: build stopped: subcommand failed.

Any idea what might be wrong? This is my c++ version:

philipp:..d/x64-Release% /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ --version
Apple clang version 11.0.3 (clang-1103.0.32.62)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
@henricj
Copy link
Owner

henricj commented Dec 30, 2020

I don't have a mac handy for testing, so I'm not surprised there are build issues. Those narrowing issues should be safe to silence with casts.

That said, one may want to omit the target triplet from the cmake command line. Alternately, "-DVCPKG_TARGET_TRIPLET:STRING=x64-osx" should be better than "x64-linux" (or, even "arm64-osx" if on an ARM64 mac).

@henricj
Copy link
Owner

henricj commented Mar 7, 2024

The code now compiles on macOS, but it crashes during startup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants