Create standalone hxcpp executable for Windows?

416 views
Skip to first unread message

der Raab

unread,
Oct 17, 2016, 11:01:48 AM10/17/16
to Haxe
Hi again, I managed to create a standalone executable on and for Mac OS X (follow my odyssey if you wan't to https://groups.google.com/forum/#!topic/haxelang/aP4fQWiEmD4 ) and now I'd like to create the same on and for Windows.

Unfortunately I don't have much knowledge regarding native development in general and the required tools. So I had again a look at the only "official" documentation I found regarding static compilation in the https://github.com/HaxeFoundation/hxcpp/blob/master/src/ExampleMain.cpp . But since the way I use haxe to compile a single static standalone application on Mac I think the documentation regarding Windows might also be incomplete? Just to keep an note how I think it works on Mac OS X - here my (abstract) hxml:

# Main class
-main MyMain
# Used haxelibs (many)
-lib example
# Source directories

-cp src/hx
# Output file
-cpp bin/cpp/release/
# Remove all unused code
-dce full
# Static link - THIS IS THE MAGIC!
-D static

See? You just need to add -D static and that does all you need. Or did I accidentally setup something else and that's not the magic? Anyway - this is not mentioned in the ExampleMain.cpp.

So I thought I give it a try: I have my Windows 10 running in Parallels with the latest nightly build of haxe and I just hit
haxe my.hxml
and got my first error about missing Visual Studio environment variables so

I installed the latest Visual Studio and ran into the next error regarding
'cl.exe' is not recognized as an internal or external command

So I had to run the script from the "Developer Command Prompt for VS2015" - which was no easy task because I had to use
pushd

to access my Macs directories. Anyway - it still complains about not finding the cl.exe. So now I tried the way explained in ExampleMain.cpp, navigated to the C:\HaxeToolkit\haxe\lib\hxcpp\3,3,49\project directory and called neko build.n clean static-windows which gave me this error:
C:\HaxeToolkit\haxe\lib\hxcpp\3,3,49\project>neko build.n clean static-windows

C:\HaxeToolkit\haxe\lib\hxcpp\3,3,49\project>neko build.n clean static-windows
haxelib run hxcpp
Build.xml clean -DHXCPP_CLEAN_ONLY
neko run
.n Build.xml -Dwindows -DHXCPP_M64 -Dstatic_link C:/HaxeToolkit/haxe/lib/hxcpp/3,3,49/project/
C
:\HaxeToolkit\haxe\lib\hxcpp\3,3,49\project>setlocal enabledelayedexpansion
Error: 64bit is not autmatically supported for this version of VC. Set HXCPP_MSVC_CUSTOM and manually configure the executable, library and include paths
Error: Error: 64bit is not autmatically supported for this version of VC. Set HXCPP_MSVC_CUSTOM and manually configure the executable, library and include paths
#### Error building neko -Dwindows -DHXCPP_M64 -Dstatic_link

So now I'm stuck because I'm not sure what and how to do it. Could anybody point me in the right direction? Would be great! Thanks in advance

Hugh

unread,
Oct 18, 2016, 12:51:33 AM10/18/16
to Haxe
Hi
Are you trying to add your own mainline, and use haxe as a library, or do just want to use the haxe library?

If you just want want the haxe code to work, you do not need to do anything with "ExampleMain" - just run the haxe command.

Hxcpp should build stand-alone exes by default now.  So unless you are using a thirdparty library that comes with an ndll instead of a .lib file, then there is nothing special you need to do here either.  The standard .lib files should be shipped with the haxelib version of hxcpp.

The define for static linking - usually when building a .lib instead of a .ndll, is "-D static_link"

But is sounds like your main problem is the setup of visual studio.
Did you tick the box to download the c++ compilers when you ran the installer?

If you run the 'set' command from a cmd prompt, do you get any VS variables, like:
VS100COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools\
VS110COMNTOOLS
=C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\
VS120COMNTOOLS
=C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\
VS140COMNTOOLS
=C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\

der Raab

unread,
Oct 19, 2016, 11:58:40 AM10/19/16
to Haxe
Hi Hugh, again: Thank you!

You where right and I had to rerun the installer and modify / add c++ and the common tools.

Now it looks like everything should work and actually, the neko version does compile and run, but the cpp version does give me some compile time errors in the tink libraries (I guess). I tried my best to understand what exactly is the problem but again - regarding cpp, h-files and stuff like that I simply struggle to figure out if this might be a problem I could fix in Haxe source code. But since everything compiles fine on Mac OS X the problem might be my setup with Parallels, Visual Studio or somewhere in between. :D

So again, the only thing I can do is paste the error output hoping you guys might push me into the right direction. This is what I get in the cmd console:

T:\Documents\BYPR-Staff\Projects\PROJECT-Cli\dev\hxml>haxe hxcpp-static.hxml

haxelib run hxcpp
Build.xml haxe -Dasys="0.2.0" -Dconcurrent="1" -Dembed="1" -Dhaxe3="1" -Dhaxe_ver="3.3" -Dhttp-status="1.1.0" -Dhttp_status="1.1.0" -Dhxcpp_api_level="330" -Dmime="0.0.1" -Dmonsoon="0.4.0" -Dmonsoon-embed="0.0.1" -Dmonsoon_embed="0.0.1" -Dpath2ereg="0.1.0" -Dsource-header="Generated by Haxe 3.3.0 (git build development @ 9617d71)" -Dstatic="1" -Dtink_concurrent="0.1.3" -Dtink_core="1.3.0" -Dtink_http="0.5.0" -Dtink_io="0.4.1" -Dtink_macro="0.11.0" -Dtink_priority="0.1.3" -Dtink_runloop="0.1.0" -Dtink_streams="0.1.0" -Dtink_stringly="0.1.0" -Dtink_syntaxhub="0.3.6" -Dtink_tcp="0.1.1" -Dtink_url="0.2.0" -I"../../src/hx/" -I"../../../../../../PROJECT/src/hx/" -I"../../../../../../PROJECT/libs/puremvc-haxe-multicore-framework-master/src/" -I"../../../../../../PROJECT/libs/msignal-master/src/" -I"C:\\HaxeToolkit\\haxe\\lib\\tink_tcp/0,1,1/src/" -I"C:\\HaxeToolkit\\haxe\\lib\\tink_priority/0,1,3/src/" -I"C:\\HaxeToolkit\\haxe\\lib\\tink_syntaxhub/0,3,6/src/" -I"C:\\HaxeToolkit\\haxe\\lib\\tink_runloop/0,1,0/src/" -I"C:\\HaxeToolkit\\haxe\\lib\\tink_concurrent/0,1,3/src/" -I"C:\\HaxeToolkit\\haxe\\lib\\monsoon-embed/0,0,1/" -I"C:\\HaxeToolkit\\haxe\\lib\\tink_stringly/0,1,0/src/" -I"C:\\HaxeToolkit\\haxe\\lib\\tink_url/0,2,0/src/" -I"C:\\HaxeToolkit\\haxe\\lib\\tink_http/0,5,0/src/" -I"C:\\HaxeToolkit\\haxe\\lib\\path2ereg/0,1,0/" -I"C:\\HaxeToolkit\\haxe\\lib\\mime/0,0,1/" -I"C:\\HaxeToolkit\\haxe\\lib\\http-status/1,1,0/src/" -I"C:\\HaxeToolkit\\haxe\\lib\\tink_macro/0,11,0/src/" -I"C:\\HaxeToolkit\\haxe\\lib\\tink_streams/0,1,0/src/" -I"C:\\HaxeToolkit\\haxe\\lib\\tink_io/0,4,1/src/" -I"C:\\HaxeToolkit\\haxe\\lib\\tink_core/1,3,0/src/" -I"C:\\HaxeToolkit\\haxe\\lib\\asys/0,2,0/" -I"C:\\HaxeToolkit\\haxe\\lib\\monsoon/0,4,0/src/" -I"C:\\HaxeToolkit\\haxe\\extraLibs/" -I"" -I"C:\\HaxeToolkit\\haxe\\std/cpp/_std/" -I"C:\\HaxeToolkit\\haxe\\std/"

Creating T:/Documents/BYPR-Staff/Projects/PROJECT-Cli/bin/cpp/release/obj/msvc19xp/__pch/haxe/hxcpp.pch...

hxcpp
.cpp

 
- Compiling group 'haxe' with flags -Iinclude -nologo /WX- /fp:precise -DHX_WINDOWS -D_USING_V140_SDK71_ -GR -O2(optim-std) -Zi(debug) -FdT:\Documents\BYPR-Staff\Projects\PROJECT-Cli\bin\cpp\release\obj/msvc19xp/vc.pdb(debug) -Od(debug) -O2(release) -Os(optim-size) -Oy- -c -EHs -GS- -arch:SSE -IC:/HaxeToolkit/haxe/lib/hxcpp/3,3,49/include -DHXCPP_VISIT_ALLOCS(haxe) -DHXCPP_API_LEVEL=330(haxe) -D_CRT_SECURE_NO_DEPRECATE -D_ALLOW_MSC_VER_MISMATCH -D_ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH -wd4996 tags=[haxe,static]

 
- Compile: src/tink/url/_Query/QueryStringParser.cpp

Error: While running :cl.exe -Iinclude -nologo /WX- /fp:precise -DHX_WINDOWS -D_USING_V140_SDK71_ -GR -O2 -Oy- -c -EHs -GS- -arch:SSE -IC:/HaxeToolkit/haxe/lib/hxcpp/3,3,49/include -DHXCPP_VISIT_ALLOCS -DHXCPP_API_LEVEL=330 -D_CRT_SECURE_NO_DEPRECATE -D_ALLOW_MSC_VER_MISMATCH -D_ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH -wd4996 -MT -Yuhxcpp.h /FpT:/Documents/BYPR-Staff/Projects/PROJECT-Cli/bin/cpp/release/obj/msvc19xp/__pch/haxe/hxcpp.pch ./src/tink/url/_Query/QueryStringParser.cpp -FoT:/Documents/BYPR-Staff/Projects/PROJECT-Cli/bin/cpp/release/obj/msvc19xp/24ffe952_QueryStringParser.obj

QueryStringParser.cpp

include
\tink/core/NamedWith.h(9): error C2065: '_hx_pos_fe49a69a0def38bb_10_new': undeclared identifier

include
\tink/core/NamedWith.h(9): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

include
\tink/core/NamedWith.h(10): error C2059: syntax error: 'namespace'

include
\tink/core/NamedWith.h(10): error C2143: syntax error: missing ';' before '{'

include
\tink/core/NamedWith.h(10): error C2447: '{': missing function header (old-style formal list?)

include
\tink/core/NamedWith.h(36): error C2039: 'GcAllocator': is not a member of 'hx'

C
:/HaxeToolkit/haxe/lib/hxcpp/3,3,49/include\hx/LessThanEq.h(4): note: see declaration of 'hx'

include
\tink/core/NamedWith.h(36): error C2061: syntax error: identifier 'GcAllocator'

include
\tink/core/NamedWith.h(37): error C3083: 'GcAllocator': the symbol to the left of a '::' must be a type

include
\tink/core/NamedWith.h(37): error C2039: 'alloc': is not a member of 'hx'

C
:/HaxeToolkit/haxe/lib/hxcpp/3,3,49/include\hx/LessThanEq.h(4): note: see declaration of 'hx'

include
\tink/core/NamedWith.h(37): error C2065: '_hx_alloc': undeclared identifier

include
\tink/core/NamedWith.h(37): error C3861: 'alloc': identifier not found

include
\tink/core/NamedWith.h(40): error C2065: '_hx_pos_fe49a69a0def38bb_10_new': undeclared identifier

include
\tink/core/NamedWith.h(40): error C3861: 'HX_STACKFRAME': identifier not found

include
\tink/core/NamedWith.h(44): error C2039: 'NamedWith': is not a member of 'tink::core'

include
\tink/core/NamedWith.h(13): note: see declaration of 'tink::core'

include
\tink/core/NamedWith.h(44): error C2065: 'NamedWith': undeclared identifier

include
\tink/core/NamedWith.h(44): error C2227: left of '->name' must point to class/struct/union/generic type

include
\tink/core/NamedWith.h(44): note: type is 'unknown-type'

include
\tink/core/NamedWith.h(45): error C2039: 'NamedWith': is not a member of 'tink::core'

include
\tink/core/NamedWith.h(13): note: see declaration of 'tink::core'

include
\tink/core/NamedWith.h(45): error C2065: 'NamedWith': undeclared identifier

include
\tink/core/NamedWith.h(45): error C2227: left of '->value' must point to class/struct/union/generic type

include
\tink/core/NamedWith.h(45): note: type is 'unknown-type'

include
\tink/url/_Portion/Portion_Impl_.h(36): error C2039: 'GcAllocator': is not a member of 'hx'

C
:/HaxeToolkit/haxe/lib/hxcpp/3,3,49/include\hx/LessThanEq.h(4): note: see declaration of 'hx'

include
\tink/url/_Portion/Portion_Impl_.h(36): error C2061: syntax error: identifier 'GcAllocator'

include
\tink/url/_Portion/Portion_Impl_.h(37): error C3083: 'GcAllocator': the symbol to the left of a '::' must be a type

include
\tink/url/_Portion/Portion_Impl_.h(37): error C2039: 'alloc': is not a member of 'hx'

C
:/HaxeToolkit/haxe/lib/hxcpp/3,3,49/include\hx/LessThanEq.h(4): note: see declaration of 'hx'

include
\tink/url/_Portion/Portion_Impl_.h(37): error C2065: '_hx_alloc': undeclared identifier

include
\tink/url/_Portion/Portion_Impl_.h(37): error C3861: 'alloc': identifier not found

include
\tink/url/_Query/QueryStringParser.h(31): error C2039: 'GcAllocator': is not a member of 'hx'

C
:/HaxeToolkit/haxe/lib/hxcpp/3,3,49/include\hx/LessThanEq.h(4): note: see declaration of 'hx'

include
\tink/url/_Query/QueryStringParser.h(31): error C2061: syntax error: identifier 'GcAllocator'

./src/tink/url/_Query/QueryStringParser.cpp(14): error C2065: '_hx_pos_bde4a567013990e9_64_new': undeclared identifier

./src/tink/url/_Query/QueryStringParser.cpp(14): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

./src/tink/url/_Query/QueryStringParser.cpp(15): error C2440: 'initializing': cannot convert from 'initializer list' to 'int'

./src/tink/url/_Query/QueryStringParser.cpp(15): note: The initializer contains too many elements

./src/tink/url/_Query/QueryStringParser.cpp(15): error C2146: syntax error: missing ';' before identifier 'HX_DEFINE_STACK_FRAME'

./src/tink/url/_Query/QueryStringParser.cpp(18): error C2143: syntax error: missing ';' before '{'

./src/tink/url/_Query/QueryStringParser.cpp(18): error C2447: '{': missing function header (old-style formal list?)

Error: Build failed

T
:\Documents\BYPR-Staff\Projects\PROJECT-Cli\dev\hxml>


Btw, do I really need to run this haxe command in the "Developer Command Prompt for VS2015"?

der Raab

unread,
Oct 19, 2016, 12:00:50 PM10/19/16
to Haxe
Hm. half of the error output was missing - so here comes the rest:

Hugh

unread,
Oct 19, 2016, 9:37:27 PM10/19/16
to Haxe
Looks like you are using a bleed-edge version of haxe.
In this case, you also need the git version of hxcpp.

Hugh

der Raab

unread,
Oct 21, 2016, 4:51:41 AM10/21/16
to Haxe
Yes Hugh, you are right! I was able to compile using the latest git version.  THANKS!

One last (this is a lie) question. What's the equivalent of lldb on windows? :)

Hugh

unread,
Oct 24, 2016, 12:16:13 AM10/24/16
to Haxe
Microsofts Visual Studio is great on windows.
You can attach on crash using the "debug" button, or you can attach to a running process or you can create a dummy project and set the debug target you your exe and launch from within the IDE.
Reply all
Reply to author
Forward
0 new messages