+1 vote

Any idea how to compile GDNative C++ on OSX (mac os catalina)? I've tried to follow the latest tutorial on Godot Documentation . Everything was smooth until compiling the plugin. I'm using the given SConstruct file in the tutorial.
Below is the terminal output.

scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
g++ -o src/gdexample.os -c -g -O2 -arch x86_64 -fPIC -I. -Igodot-cpp/godot_headers -Igodot-cpp/include -Igodot-cpp/include/core -Igodot-cpp/include/gen -Isrc src/gdexample.cpp
In file included from src/gdexample.cpp:1:
In file included from src/gdexample.h:4:
In file included from godot-cpp/include/core/Godot.hpp:11:
In file included from godot-cpp/include/core/CoreTypes.hpp:4:
godot-cpp/include/core/Defs.hpp:6:6: warning: scoped enumerations are a C++11 extension [-Wc++11-extensions]
enum class Error {
     ^
In file included from src/gdexample.cpp:1:
In file included from src/gdexample.h:4:
In file included from godot-cpp/include/core/Godot.hpp:11:
In file included from godot-cpp/include/core/CoreTypes.hpp:4:
In file included from godot-cpp/include/core/Defs.hpp:62:
In file included from godot-cpp/include/core/GodotGlobal.hpp:4:
godot-cpp/include/core/Array.hpp:17:48: warning: variadic templates are a C++11 extension [-Wc++11-extensions]
template <typename T, typename ValueT, typename... Args>
                                               ^
godot-cpp/include/core/Array.hpp:34:64: warning: variadic templates are a C++11 extension [-Wc++11-extensions]
template <typename KV, typename KeyT, typename ValueT, typename... Args>
                                                               ^
godot-cpp/include/core/Array.hpp:79:17: warning: variadic templates are a C++11 extension [-Wc++11-extensions]
        template <class... Args>
                       ^
In file included from src/gdexample.cpp:1:
In file included from src/gdexample.h:4:
In file included from godot-cpp/include/core/Godot.hpp:11:
In file included from godot-cpp/include/core/CoreTypes.hpp:4:
In file included from godot-cpp/include/core/Defs.hpp:62:
godot-cpp/include/core/GodotGlobal.hpp:39:17: warning: variadic templates are a C++11 extension [-Wc++11-extensions]
        template <class... Args>
                       ^
In file included from src/gdexample.cpp:1:
In file included from src/gdexample.h:4:
In file included from godot-cpp/include/core/Godot.hpp:11:
In file included from godot-cpp/include/core/CoreTypes.hpp:8:
godot-cpp/include/core/Basis.hpp:61:12: error: union member 'elements' has a non-trivial default constructor
                        Vector3 elements[3]; // Not for direct access, use [] operator instead
                                ^
godot-cpp/include/core/Vector3.hpp:40:9: note: because type 'godot::Vector3' has a user-provided default constructor
        inline Vector3() {
               ^
In file included from src/gdexample.cpp:1:
In file included from src/gdexample.h:4:
In file included from godot-cpp/include/core/Godot.hpp:11:
In file included from godot-cpp/include/core/CoreTypes.hpp:8:
godot-cpp/include/core/Basis.hpp:284:11: error: union member 'elements' has a non-trivial default constructor
                Vector3 elements[3]; // Not for direct access, use [] operator instead
                        ^
godot-cpp/include/core/Vector3.hpp:40:9: note: because type 'godot::Vector3' has a user-provided default constructor
        inline Vector3() {
               ^
In file included from src/gdexample.cpp:1:
In file included from src/gdexample.h:4:
In file included from godot-cpp/include/core/Godot.hpp:11:
In file included from godot-cpp/include/core/CoreTypes.hpp:8:
godot-cpp/include/core/Basis.hpp:73:4: error: use of undeclared identifier 'elements'
                        elements[0][column] = p_value.x;
                        ^
godot-cpp/include/core/Basis.hpp:74:4: error: use of undeclared identifier 'elements'
                        elements[1][column] = p_value.y;
                        ^
godot-cpp/include/core/Basis.hpp:75:4: error: use of undeclared identifier 'elements'
                        elements[2][column] = p_value.z;
                        ^
godot-cpp/include/core/Basis.hpp:80:19: error: use of undeclared identifier 'elements'
                        return Vector3(elements[0][column], elements[1][column], elements[2][column]);
                                       ^
godot-cpp/include/core/Basis.hpp:80:40: error: use of undeclared identifier 'elements'
                        return Vector3(elements[0][column], elements[1][column], elements[2][column]);
                                                            ^
godot-cpp/include/core/Basis.hpp:80:61: error: use of undeclared identifier 'elements'
                        return Vector3(elements[0][column], elements[1][column], elements[2][column]);
                                                                                 ^
godot-cpp/include/core/Basis.hpp:88:11: error: use of undeclared identifier 'elements'
                        return elements[p_axis][column];
                               ^
godot-cpp/include/core/Basis.hpp:92:11: error: use of undeclared identifier 'elements'
                        return elements[p_axis][column];
                               ^
godot-cpp/include/core/Basis.hpp:288:3: error: use of undeclared identifier 'elements'
                elements[0] = p_basis.elements[0];
                ^
godot-cpp/include/core/Basis.hpp:288:25: error: no member named 'elements' in 'godot::Basis'
                elements[0] = p_basis.elements[0];
                              ~~~~~~~ ^
godot-cpp/include/core/Basis.hpp:289:3: error: use of undeclared identifier 'elements'
                elements[1] = p_basis.elements[1];
                ^
godot-cpp/include/core/Basis.hpp:289:25: error: no member named 'elements' in 'godot::Basis'
                elements[1] = p_basis.elements[1];
                              ~~~~~~~ ^
godot-cpp/include/core/Basis.hpp:290:3: error: use of undeclared identifier 'elements'
                elements[2] = p_basis.elements[2];
                ^
godot-cpp/include/core/Basis.hpp:290:25: error: no member named 'elements' in 'godot::Basis'
                elements[2] = p_basis.elements[2];
                              ~~~~~~~ ^
godot-cpp/include/core/Basis.hpp:294:3: error: use of undeclared identifier 'elements'
                elements[0] = p_basis.elements[0];
                ^
godot-cpp/include/core/Basis.hpp:294:25: error: no member named 'elements' in 'godot::Basis'
                elements[0] = p_basis.elements[0];
                              ~~~~~~~ ^
godot-cpp/include/core/Basis.hpp:295:3: error: use of undeclared identifier 'elements'
                elements[1] = p_basis.elements[1];
                ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
5 warnings and 20 errors generated.
scons: *** [src/gdexample.os] Error 1
scons: building terminated because of errors.

I think problem is related to SConstruct file. because some other users experienced the same issue. Old forum post But unfortunately the link provided in that discussion is no longer working. Any help is really appreciated.
Thanks

asked Mar 29 in Projects by juju (18 points)

1 Answer

+1 vote

Just had the same issue; I was able to solve it by adding '-std=c++17' to the two CCFLAGS definitions in the osx section of the SConstruct file.

  1. Open the SConstruct file in an editor
  2. Search for the two CCFLAGS entries (one for debug, one for release builds) listed in the if env['platform'] == "osx" section
  3. Append , '-std=c++17' before the closing ] for both
answered Apr 12 by ArdaE (92 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.