Building for C++ target on Mac

Hello

I am new to openFL and Haxe programming, and recently started building a game using HaxeFlixel framework. So apologies if this is a very basic question or asked sometime before.

I have started building my game, and using target Neko to test. With Neko I have no problem in building and running my game. Now before things getting more complicated, I wanted to build it for Mac and see how it is running. But I am getting a bunch of errors when I choose the target “C++ Release” from my text editor Sublime Text 2. I am getting the same errors when I type “openfl build mac” in the terminal.

I have also Xcode and hxcpp installed in my computer. What do I need to build my game with that target? By the way here are the errors I am getting:

xcrun --sdk macosx10.9 clang++ -Iinclude -c -fvisibility=hidden -stdlib=libstdc++ -O2 -I/usr/lib/haxe/lib/hxcpp/3,1,68/include -DHX_MACOS -m64 -Wno-parentheses -Wno-null-dereference -Wno-unused-value -Wno-format-extra-args -Wno-bool-conversion -DHXCPP_M64 -DHXCPP_VISIT_ALLOCS -DHXCPP_API_LEVEL=311 -x c++ -frtti ./src/sys/io/FileOutput.cpp -oobj/darwin64/de19829f_FileOutput.o
xcrun --sdk macosx10.9 clang++ -Iinclude -c -fvisibility=hidden -stdlib=libstdc++ -O2 -I/usr/lib/haxe/lib/hxcpp/3,1,68/include -DHX_MACOS -m64 -Wno-parentheses -Wno-null-dereference -Wno-unused-value -Wno-format-extra-args -Wno-bool-conversion -DHXCPP_M64 -DHXCPP_VISIT_ALLOCS -DHXCPP_API_LEVEL=311 -x c++ -frtti ./src/sys/io/File.cpp -oobj/darwin64/de19829f_File.o
Error: In file included from ./src/sys/io/FileOutput.cpp:1:
In file included from /usr/lib/haxe/lib/hxcpp/3,1,68/include/hxcpp.h:37:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/wchar.h:91:
include/time.h:8:1: error: unknown type name 'HX_DECLARE_CLASS0'
HX_DECLARE_CLASS0(Moment)
^
include/time.h:8:26: error: expected ';' after top level declarator
HX_DECLARE_CLASS0(Moment)
                         ^
In file included from ./src/sys/io/FileOutput.cpp:1:
In file included from /usr/lib/haxe/lib/hxcpp/3,1,68/include/hxcpp.h:245:
In file included from /usr/lib/haxe/lib/hxcpp/3,1,68/include/Array.h:237:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1/algorithm:65:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1/bits/stl_algobase.h:70:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1/iosfwd:49:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1/bits/postypes.h:46:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1/cwchar:52:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1/ctime:66:11: error: no member named 'clock_t' in the global namespace
  using ::clock_t;
        ~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1/ctime:70:11: error: no member named 'clock' in the global namespace
  using ::clock;
        ~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1/ctime:71:11: error: no member named 'difftime' in the global namespace
  using ::difftime;
        ~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1/ctime:72:11: error: no member named 'mktime' in the global namespace; did you mean 'mktemp'?
  using ::mktime;
        ~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/stdlib.h:200:7: note: 'mktemp' declared here
char    *mktemp(char *);
         ^
In file included from ./src/sys/io/FileOutput.cpp:1:
In file included from /usr/lib/haxe/lib/hxcpp/3,1,68/include/hxcpp.h:245:
In file included from /usr/lib/haxe/lib/hxcpp/3,1,68/include/Array.h:237:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1/algorithm:65:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1/bits/stl_algobase.h:70:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1/iosfwd:49:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1/bits/postypes.h:46:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1/cwchar:52:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1/ctime:73:11: error: no member named 'time' in the global namespace
  using ::time;
        ~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1/ctime:74:11: error: no member named 'asctime' in the global namespace
  using ::asctime;
        ~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1/ctime:75:11: error: no member named 'ctime' in the global namespace
  using ::ctime;
        ~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1/ctime:76:11: error: no member named 'gmtime' in the global namespace
  using ::gmtime;
        ~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1/ctime:77:11: error: no member named 'localtime' in the global namespace
  using ::localtime;
        ~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1/ctime:78:11: error: no member named 'strftime' in the global namespace
  using ::strftime;
        ~~^
12 errors generated.
[Finished in 6.2s with exit code 1]

This is definitely unusual, does this occur if you try to build a basic OpenFL sample on your computer? It might be good for us to try and isolate what’s triggering this, and then if we can, track that back and see if the issue is fixed in HXCPP already, and if not, if we could fix it before the next release soon :slight_smile:

Thanks for the answer @singmajesty. I have tried an Hello World app for openFL, and it is built and running for mac with no problem. So this might be something related to the HaxeFlixel package I am including?

Alright I figured out theissue. Some classes I defined (time, moment) ere conflicting with hxcpp’s own definitions. When I changed them to ttime, mmoment, it started compiling.

ah hah, tricky. It might work, too, if you make sure your classes exist under a package, like “my.Time”

1 Like