Compile Haxe Project to native library

89 views
Skip to first unread message

Kyle Kirby

unread,
Mar 13, 2015, 12:45:18 PM3/13/15
to haxe...@googlegroups.com

I checked all over, and I can't find an answer (or perhaps I'm not so good at searching). Anyways, is it possible to compile a project to a native library, basically exporting all classes using the language's built-in namespace paradigm and remove the requirement of the compiler's -main <class>. The use case would be to build a library in Haxe that could be compiled to a language and used like any other class/library native to that language. For example, compiling a PHP library and using it in a non-Haxe PHP project.

Thanks!

Heinz Hölzer

unread,
Mar 13, 2015, 1:11:23 PM3/13/15
to haxe...@googlegroups.com
You can compile with just Main instead of -main Main, but i don't experience with it.

Heinz Hölzer

unread,
Mar 13, 2015, 1:13:03 PM3/13/15
to haxe...@googlegroups.com
and it could be a good idea to disable dead code elimination with "-dce off".

der Raab

unread,
Mar 16, 2015, 6:54:06 PM3/16/15
to haxe...@googlegroups.com
I do sort of the same within my current workflow. Whenever we reach a milestone, I compile a complete source directory in a flash target specific SWC file (which contains all my code as compiled SWF file) and use that SWC file to compile an AIR application using most of the contained code. I think the magic happens because of the --macro compiler flags. I just copy and paste my hxml - maybe that helps:


# Main class
#-main TestCoreMainSWF


--macro include('com')
--macro include('de')
--macro include('msignal')


# used haxelibs
-lib air3
-lib munit
-lib hamcrest
-lib openfl
-lib lime


# local source directories
-cp ../../src/hx
-cp ../../test/hx


# ActionScript specific
-cp ../../src/hx-as
-cp ../../test/hx-as


# no dead code elimination
-dce no
# private hx field -> protected flash field -> breaks some APIs (msignal)!
# -D swf-protected


# swf settings
-swf-version 12
-swf-header 1024:768:30:FFFFFF


# output file
-swf ../../out/swc/library.swc

I would expect it works the same way with the PHP target.



On Friday, March 13, 2015 at 5:45:18 PM UTC+1, Kyle Kirby wrote:

Dion Whitehead Amago

unread,
Mar 16, 2015, 7:51:53 PM3/16/15
to haxe...@googlegroups.com
This works fine with the javascript target, just have an empty main method and expose the classes/methods you need.

Bruno Santos

unread,
Mar 16, 2015, 8:27:00 PM3/16/15
to haxe...@googlegroups.com

Check wighawag post about hxcpp externs and creating a cpp static lib from haxe. Is this what you're looking for?

http://www.wighawag.com/blog/2014/12/Hxcpp-extern

--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
---
You received this message because you are subscribed to the Google Groups "Haxe" group.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages