ℹ️ Skipped - page is already crawled
| Filter | Status | Condition | Details |
|---|---|---|---|
| HTTP status | PASS | download_http_code = 200 | HTTP 200 |
| Age cutoff | PASS | download_stamp > now() - 6 MONTH | 1.1 months ago |
| History drop | PASS | isNull(history_drop_reason) | No drop reason |
| Spam/ban | PASS | fh_dont_index != 1 AND ml_spam_score = 0 | ml_spam_score=0 |
| Canonical | PASS | meta_canonical IS NULL OR = '' OR = src_unparsed | Not set |
| Property | Value |
|---|---|
| URL | https://haxe.org/manual/compiler-usage.html |
| Last Crawled | 2026-03-12 18:13:00 (1 month ago) |
| First Indexed | 2016-12-29 05:19:15 (9 years ago) |
| HTTP Status Code | 200 |
| Meta Title | Compiler Usage - Haxe - The Cross-platform Toolkit |
| Meta Description | Haxe is an open source toolkit based on a modern, high level, strictly typed programming language. |
| Meta Canonical | null |
| Boilerpipe Text | Basic Usage
The Haxe Compiler is typically invoked from command line with several arguments which have to answer two questions:
What should be compiled?
What should the output be?
To answer the first question, it is usually sufficient to provide a class path via the
-p <path>
argument, along with the main class to be compiled via the
-m <dot_path>
argument. The Haxe Compiler then resolves the main class file and begins compilation.
The second question usually comes down to providing an argument specifying the desired target. Each Haxe target has a dedicated command line switch, such as
--js <file_name>
for JavaScript and
--php <directory>
for PHP. Depending on the nature of the target, the argument value is either a directory path (for
--php
,
--cpp
,
--cs
, and
--java
) or a file name.
Common arguments
Input:
-p <path>
(or
--class-path <path>
) Add a class path where
.hx
source files or packages (sub-directories) can be found.
-L <library_name>
(or
--library <library_name>
) Add a
Haxelib
library. By default the most recent version in the local Haxelib repository is used. To require a specific library version use
-L library_name:version
. To require a version from git use
-L library_name:git:https://github.com/user/project.git#commit
where the optional #commit can be a branch, tag or commit hash.
-m <dot_path>
(or
--main <dot_path>
) Set the main class.
-D <var[=value]>
(or
--define <var[=value]>
) Define a
conditional compilation flag
.
Output:
--js <file_name.js>
Generate
JavaScript
source code in specified file.
--swf <file_name.swf>
Generate the specified file as
Flash
.swf
.
--neko <file_name.n>
Generate
Neko
binary as specified file.
--php <directory>
Generate
PHP
source code in specified directory. Use
-D php7
for PHP7 source code.
--cpp <directory>
Generate
C++
source code in specified directory and compiles it using native C++ compiler.
--cs <directory>
Generate
C#
source code in specified directory and compiles it using native C# compiler.
--java <directory>
Generate
Java
source code in specified directory and compiles it using the Java Compiler. Add
-D jvm
to generate JVM byte code directly bypassing Java compilation step.
--jvm <file_name.jar>
Generate
JVM bytecode
as a jar file.
--python <file_name.py>
Generate
Python
source code in the specified file.
--lua <file_name.lua>
Generate
Lua
source code in the specified file.
--hl <file_name.hl>
Generate
HashLink
byte code in specified file.
--cppia <file_name.cppia>
Generate the specified script as a
cppia
file.
-x <file>
Shortcut for compiling and executing a Neko file.
--no-output
Compile but do not generate any file.
--interp
Interpret the program using internal macro system.
Other global arguments
--run <module> [args...]
Compile and execute a Haxe module with command line arguments.
--xml <file>
Generate XML types description. Useful for API documentation generation tools like
Dox
.
--json <file>
Generate JSON types description.
-v
(or
--verbose
) Turn on verbose mode.
--dce <std|full|no>
Set the
Dead Code Elimination
mode (default
std
).
--debug
Add debug information to the compiled code.
-r <file>[@name]
(or
--resource <file>[@name]
) Add a named resource file.
--prompt
Prompt on error.
--cmd <command>
Run the specified shell command after a successful compilation.
--no-traces
Don't compile trace calls in the program.
--display
Display code tips to provide
completion information for IDEs and editors
.
--times
Measure compilation times.
--no-inline
Disable
inlining
.
--no-opt
Disable code optimizations.
--remap <package:target>
Remap a package to another one.
--macro
Call the given
initialization macro
before typing anything else.
--wait <host:port>
Wait on the given port for commands to run (see
Completion server
).
--connect <host:port>
Connect on the given port and run commands there (see
Completion server
).
-C <dir>
(or
--cwd <dir>
) Set current working directory.
Target specific arguments
-D php-front=<filename>
Select the name for the php front file.
-D php-lib=<filename>
Select the name for the php lib folder.
-D php-prefix=<name>
Prefix all classes with given name.
--swf-version <version>
Change the SWF version.
--swf-header <header>
Define SWF header (width:height:fps:color).
--swf-lib <file>
Add the SWF library to the compiled SWF.
--swf-lib-extern <file>
Use the SWF library for type checking.
--flash-strict
More type strict flash API.
--java-lib <file>
Add an external JAR or class directory library.
--net-lib <file>[@std]
Add an external .NET DLL file.
--net-std <file>
Add a root std .NET DLL search path.
--c-arg <arg>
Pass option
arg
to the native Java/C# compiler.
Trivia: Run commands after compilation
Use
--cmd
to run the specified command after a successful compilation. It can be used to run (testing) tools or to directly run the build, e.g.
--cmd java -jar bin/Main.jar
(for Java),
--cmd node main.js
(for Node.js) or
--cmd neko Main.n
(for Neko) etc.
Global compiler configuration macros:
In order to include single modules, their paths can be listed directly on command line or in hxml:
haxe ... ModuleName pack.ModuleName
. For more specific includes or excludes, use these
initialization macros
:
--macro include(pack:String, recursive=true, ?ignore:Array<String>, ?classPaths:Array<String>, strict=false)
Includes all modules in package pack in the compilation. If
recursive
is true, the compiler recursively adds all sub-packages.
--macro exclude(pack:String, recursive=true
Exclude a specific class, enum, or all classes and enums in a package from being generated. Excluded types become
extern
. If
recursive
is true, the compiler recursively excludes all sub-packages.
--macro excludeFile(fileName:String)
Exclude classes and enums listed from given external file (one per line) from being generated.
--macro keep(?path:String, ?paths:Array<String>, recursive=true)
Marks a package, module or sub-type dot path to be kept by DCE. This also extends to the sub-types of resolved modules. If
recursive
is true, the compiler recursively keeps all sub-packages for package paths.
--macro includeFile(file:String, position)
Embed a JavaScript file at compile time.
position
can be either "top", "inline" or "closure".
The full documentation of these methods can be found in the
haxe.macro.Compiler
API documentation.
Help
haxe --version
Print the current Haxe compiler version.
haxe --help
Display this list of options.
haxe --help-defines
Print help for all
compiler specific defines
.
haxe --help-metas
Print help for all
compiler metadata
.
Related content
Compilation tutorials
in the Haxe Code Cookbook. |
| Markdown | [](https://haxe.org/)
- [Home](https://haxe.org/)
- [Download](https://haxe.org/download/)
- [Blog](https://haxe.org/blog/)
- [Use Cases](https://haxe.org/use-cases/)
- [Overview](https://haxe.org/use-cases/)
- [Games](https://haxe.org/use-cases/games/)
- [Web](https://haxe.org/use-cases/web/)
- [Mobile](https://haxe.org/use-cases/mobile/)
- [Desktop](https://haxe.org/use-cases/desktop/)
- [Command Line](https://haxe.org/use-cases/cli/)
- [Cross Platform APIs](https://haxe.org/use-cases/cross-platform-apis/)
- [Who Uses Haxe](https://haxe.org/use-cases/who-uses-haxe.html)
- [Haxe Foundation](https://haxe.org/foundation/)
- [About The Foundation](https://haxe.org/foundation/)
- [Who is who](https://haxe.org/foundation/people.html)
- [Jobs](https://haxe.org/foundation/jobs.html)
- [Supported Projects](https://haxe.org/foundation/supported-projects.html)
- [Support Plans](https://haxe.org/foundation/support-plans.html)
- [Donate](https://haxe.org/foundation/donate.html)
- [Branding](https://haxe.org/foundation/branding.html)
- [Shop](https://haxe.org/foundation/shop.html)
- [Open Source](https://haxe.org/foundation/open-source.html)
- [Contact](https://haxe.org/foundation/contact.html)
- [Support Plans](https://haxe.org/foundation/support-plans.html)
- [Learn Haxe](https://haxe.org/documentation/introduction)
- [Introduction](https://haxe.org/documentation/introduction/)
- [Manual](https://haxe.org/manual/)
- [Code Cookbook](https://code.haxe.org/)
- [API Documentation](https://api.haxe.org/)
- [Videos](https://haxe.org/videos/)
- [Try Haxe online](https://try.haxe.org/)
- [Haxelib](https://lib.haxe.org/)
- [Connect](https://haxe.org/HaxeFoundation)
- [GitHub](https://github.com/HaxeFoundation)
- [Bug reports](https://github.com/HaxeFoundation/haxe/issues)
- [Stack Overflow](https://stackoverflow.com/questions/tagged/haxe)
- [Forums](http://community.haxe.org/)
- [Discord](https://discordapp.com/invite/0uEuWH3spjck73Lo)
- [Gitter](https://gitter.im/HaxeFoundation/haxe)
- [Blog](https://haxe.org/blog)
- [Facebook](https://www.facebook.com/haxe.org/)
- [\#haxe](https://twitter.com/search?q=%23haxe)
- [@haxelang](https://twitter.com/haxelang)
- [@haxe\_org](https://twitter.com/haxe_org)
- [Contact](https://haxe.org/foundation/contact.html)
[Inline Constructors](https://haxe.org/manual/lf-inline-constructor.html)[HXML](https://haxe.org/manual/compiler-usage-hxml.html)
- [Introduction](https://haxe.org/manual/introduction.html)
- [What is Haxe?](https://haxe.org/manual/introduction-what-is-haxe.html)
- [About this Document](https://haxe.org/manual/introduction-about-this-document.html)
- [Authors and contributions](https://haxe.org/manual/introduction-authors-and-contributions.html)
- [License](https://haxe.org/manual/introduction-license.html)
- [Hello World](https://haxe.org/manual/introduction-hello-world.html)
- [History](https://haxe.org/manual/introduction-haxe-history.html)
- [Types](https://haxe.org/manual/types.html)
- [Basic Types](https://haxe.org/manual/types-basic-types.html)
- [Numeric types](https://haxe.org/manual/types-numeric-types.html)
- [Overflow](https://haxe.org/manual/types-overflow.html)
- [Bool](https://haxe.org/manual/types-bool.html)
- [Void](https://haxe.org/manual/types-void.html)
- [Nullability](https://haxe.org/manual/types-nullability.html)
- [Optional Arguments and Nullability](https://haxe.org/manual/types-nullability-optional-arguments.html)
- [Class Instance](https://haxe.org/manual/types-class-instance.html)
- [Class constructor](https://haxe.org/manual/types-class-constructor.html)
- [Inheritance](https://haxe.org/manual/types-class-inheritance.html)
- [Interfaces](https://haxe.org/manual/types-interfaces.html)
- [Abstract Class](https://haxe.org/manual/types-abstract-class.html)
- [Enum Instance](https://haxe.org/manual/types-enum-instance.html)
- [Enum Constructor](https://haxe.org/manual/types-enum-constructor.html)
- [Using enums](https://haxe.org/manual/types-enum-using.html)
- [Anonymous Structure](https://haxe.org/manual/types-anonymous-structure.html)
- [JSON for Structure Values](https://haxe.org/manual/types-structure-json.html)
- [Class Notation for Structure Types](https://haxe.org/manual/types-structure-class-notation.html)
- [Optional Fields](https://haxe.org/manual/types-structure-optional-fields.html)
- [Impact on Performance](https://haxe.org/manual/types-structure-performance.html)
- [Extensions](https://haxe.org/manual/types-structure-extensions.html)
- [Function Type](https://haxe.org/manual/types-function.html)
- [Optional Arguments](https://haxe.org/manual/types-function-optional-arguments.html)
- [Default values](https://haxe.org/manual/types-function-default-values.html)
- [Dynamic](https://haxe.org/manual/types-dynamic.html)
- [Dynamic with Type Parameter](https://haxe.org/manual/types-dynamic-with-type-parameter.html)
- [Dynamic access](https://haxe.org/manual/types-dynamic-access.html)
- [Any type](https://haxe.org/manual/types-dynamic-any.html)
- [Abstract](https://haxe.org/manual/types-abstract.html)
- [Access to Underlying Data](https://haxe.org/manual/types-abstract-this.html)
- [Implicit Casts](https://haxe.org/manual/types-abstract-implicit-casts.html)
- [Operator Overloading](https://haxe.org/manual/types-abstract-operator-overloading.html)
- [Array Access](https://haxe.org/manual/types-abstract-array-access.html)
- [Enum abstracts](https://haxe.org/manual/types-abstract-enum.html)
- [Forwarding abstract fields](https://haxe.org/manual/types-abstract-forward.html)
- [Core-type abstracts](https://haxe.org/manual/types-abstract-core-type.html)
- [Monomorph](https://haxe.org/manual/types-monomorph.html)
- [Type System](https://haxe.org/manual/type-system.html)
- [Typedef](https://haxe.org/manual/type-system-typedef.html)
- [Type Parameters](https://haxe.org/manual/type-system-type-parameters.html)
- [Constraints](https://haxe.org/manual/type-system-type-parameter-constraints.html)
- [Defaults](https://haxe.org/manual/type-system-type-parameter-defaults.html)
- [Generic](https://haxe.org/manual/type-system-generic.html)
- [Construction of generic type parameters](https://haxe.org/manual/type-system-generic-type-parameter-construction.html)
- [Variance](https://haxe.org/manual/type-system-variance.html)
- [Unification](https://haxe.org/manual/type-system-unification.html)
- [Between Class/Interface](https://haxe.org/manual/type-system-unification-between-classes-and-interfaces.html)
- [Structural Subtyping](https://haxe.org/manual/type-system-structural-subtyping.html)
- [Monomorphs](https://haxe.org/manual/type-system-monomorphs.html)
- [Function Return](https://haxe.org/manual/type-system-unification-function-return.html)
- [Common Base Type](https://haxe.org/manual/type-system-unification-common-base-type.html)
- [Type Inference](https://haxe.org/manual/type-system-type-inference.html)
- [Top-down Inference](https://haxe.org/manual/type-system-top-down-inference.html)
- [Limitations](https://haxe.org/manual/type-system-inference-limitations.html)
- [Modules and Paths](https://haxe.org/manual/type-system-modules-and-paths.html)
- [Module Sub-Types](https://haxe.org/manual/type-system-module-sub-types.html)
- [Import](https://haxe.org/manual/type-system-import.html)
- [Import defaults / import.hx](https://haxe.org/manual/type-system-import-defaults.html)
- [Resolution Order](https://haxe.org/manual/type-system-resolution-order.html)
- [untyped](https://haxe.org/manual/type-system-untyped.html)
- [Class Fields](https://haxe.org/manual/class-field.html)
- [Variable](https://haxe.org/manual/class-field-variable.html)
- [Property](https://haxe.org/manual/class-field-property.html)
- [Common accessor identifier combinations](https://haxe.org/manual/class-field-property-common-combinations.html)
- [Impact on the type system](https://haxe.org/manual/class-field-property-type-system-impact.html)
- [Rules for getter and setter](https://haxe.org/manual/class-field-property-rules.html)
- [Method](https://haxe.org/manual/class-field-method.html)
- [Overriding Methods](https://haxe.org/manual/class-field-overriding.html)
- [Effects of variance and access modifiers](https://haxe.org/manual/class-field-override-effects.html)
- [Access Modifier](https://haxe.org/manual/class-field-access-modifier.html)
- [Visibility](https://haxe.org/manual/class-field-visibility.html)
- [Inline](https://haxe.org/manual/class-field-inline.html)
- [Dynamic](https://haxe.org/manual/class-field-dynamic.html)
- [Override](https://haxe.org/manual/class-field-override.html)
- [Static](https://haxe.org/manual/class-field-static.html)
- [Extern](https://haxe.org/manual/class-field-extern.html)
- [Final](https://haxe.org/manual/class-field-final.html)
- [Expressions](https://haxe.org/manual/expression.html)
- [Blocks](https://haxe.org/manual/expression-block.html)
- [Literals](https://haxe.org/manual/expression-literals.html)
- [Array Declaration](https://haxe.org/manual/expression-array-declaration.html)
- [Map Declaration](https://haxe.org/manual/expression-map-declaration.html)
- [Object Declaration](https://haxe.org/manual/expression-object-declaration.html)
- [Constants](https://haxe.org/manual/expression-constants.html)
- [Operators](https://haxe.org/manual/expression-operators.html)
- [Unary Operators](https://haxe.org/manual/expression-operators-unops.html)
- [Binary Operators](https://haxe.org/manual/expression-operators-binops.html)
- [Ternary Operator](https://haxe.org/manual/expression-operators-ternary.html)
- [Precedence](https://haxe.org/manual/expression-operators-precedence.html)
- [Overloading and macros](https://haxe.org/manual/expression-operators-overloading.html)
- [Field Access](https://haxe.org/manual/expression-field-access.html)
- [Null coalescing](https://haxe.org/manual/expression-null-coalesce.html)
- [Array Access](https://haxe.org/manual/expression-array-access.html)
- [Function Call](https://haxe.org/manual/expression-function-call.html)
- [var and final](https://haxe.org/manual/expression-var.html)
- [Local static variables](https://haxe.org/manual/expression-local-static.html)
- [Local Functions](https://haxe.org/manual/expression-arrow-function.html)
- [new](https://haxe.org/manual/expression-new.html)
- [for](https://haxe.org/manual/expression-for.html)
- [while](https://haxe.org/manual/expression-while.html)
- [do-while](https://haxe.org/manual/expression-do-while.html)
- [if](https://haxe.org/manual/expression-if.html)
- [switch](https://haxe.org/manual/expression-switch.html)
- [throw](https://haxe.org/manual/expression-throw.html)
- [try/catch](https://haxe.org/manual/expression-try-catch.html)
- [return](https://haxe.org/manual/expression-return.html)
- [break](https://haxe.org/manual/expression-break.html)
- [continue](https://haxe.org/manual/expression-continue.html)
- [cast](https://haxe.org/manual/expression-cast.html)
- [unsafe cast](https://haxe.org/manual/expression-cast-unsafe.html)
- [safe cast](https://haxe.org/manual/expression-cast-safe.html)
- [type check](https://haxe.org/manual/expression-type-check.html)
- [inline](https://haxe.org/manual/expression-inline.html)
- [Language Features](https://haxe.org/manual/lf.html)
- [Conditional Compilation](https://haxe.org/manual/lf-condition-compilation.html)
- [Target defines](https://haxe.org/manual/lf-target-defines.html)
- [Target-Specific Files](https://haxe.org/manual/lf-target-specific-files.html)
- [Custom defines documentation](https://haxe.org/manual/lf-custom-defines-documentation.html)
- [Externs](https://haxe.org/manual/lf-externs.html)
- [Native Metadata](https://haxe.org/manual/lf-externs-native.html)
- [Implementing Dynamic](https://haxe.org/manual/types-dynamic-implemented.html)
- [Static Extension](https://haxe.org/manual/lf-static-extension.html)
- [In the Haxe Standard Library](https://haxe.org/manual/lf-static-extension-in-std.html)
- [Static Extension Metadata](https://haxe.org/manual/lf-static-extension-metadata.html)
- [Pattern Matching](https://haxe.org/manual/lf-pattern-matching.html)
- [Introduction](https://haxe.org/manual/lf-pattern-matching-introduction.html)
- [Enum matching](https://haxe.org/manual/lf-pattern-matching-enums.html)
- [Variable capture](https://haxe.org/manual/lf-pattern-matching-variable-capture.html)
- [Structure matching](https://haxe.org/manual/lf-pattern-matching-structure.html)
- [Array matching](https://haxe.org/manual/lf-pattern-matching-array.html)
- [Or patterns](https://haxe.org/manual/lf-pattern-matching-or.html)
- [Guards](https://haxe.org/manual/lf-pattern-matching-guards.html)
- [Match on multiple values](https://haxe.org/manual/lf-pattern-matching-tuples.html)
- [Extractors](https://haxe.org/manual/lf-pattern-matching-extractors.html)
- [Exhaustiveness checks](https://haxe.org/manual/lf-pattern-matching-exhaustiveness.html)
- [Useless pattern checks](https://haxe.org/manual/lf-pattern-matching-unused.html)
- [Single pattern check](https://haxe.org/manual/lf-pattern-matching-single.html)
- [String Interpolation](https://haxe.org/manual/lf-string-interpolation.html)
- [Array Comprehension](https://haxe.org/manual/lf-array-comprehension.html)
- [Map Comprehension](https://haxe.org/manual/lf-map-comprehension.html)
- [Iterators](https://haxe.org/manual/lf-iterators.html)
- [Function Bindings](https://haxe.org/manual/lf-function-bindings.html)
- [Metadata](https://haxe.org/manual/lf-metadata.html)
- [Custom metadata documentation](https://haxe.org/manual/lf-custom-metadata-documentation.html)
- [Access Control](https://haxe.org/manual/lf-access-control.html)
- [Inline Constructors](https://haxe.org/manual/lf-inline-constructor.html)
- [Compiler Usage](https://haxe.org/manual/compiler-usage.html)
- [HXML](https://haxe.org/manual/compiler-usage-hxml.html)
- [Global Compiler Flags](https://haxe.org/manual/compiler-usage-flags.html)
- [Error Reporting](https://haxe.org/manual/compiler-usage-reporting.html)
- [Compiler Features](https://haxe.org/manual/cr-features.html)
- [Built-in Compiler Metadata](https://haxe.org/manual/cr-metadata.html)
- [Dead Code Elimination](https://haxe.org/manual/cr-dce.html)
- [Compiler Services](https://haxe.org/manual/cr-completion.html)
- [Overview](https://haxe.org/manual/cr-completion-overview.html)
- [Field access completion](https://haxe.org/manual/cr-completion-field-access.html)
- [Call argument completion](https://haxe.org/manual/cr-completion-call-argument.html)
- [Type path completion](https://haxe.org/manual/cr-completion-type-path.html)
- [Usage completion](https://haxe.org/manual/cr-completion-usage.html)
- [Position completion](https://haxe.org/manual/cr-completion-position.html)
- [Top-level completion](https://haxe.org/manual/cr-completion-top-level.html)
- [Completion server](https://haxe.org/manual/cr-completion-server.html)
- [Resources](https://haxe.org/manual/cr-resources.html)
- [Embedding resources](https://haxe.org/manual/cr-resources-embed.html)
- [Retrieving text resources](https://haxe.org/manual/cr-resources-getString.html)
- [Retrieving binary resources](https://haxe.org/manual/cr-resources-getBytes.html)
- [Implementation details](https://haxe.org/manual/cr-resources-impl.html)
- [Runtime Type Information](https://haxe.org/manual/cr-rtti.html)
- [Static Analyzer](https://haxe.org/manual/cr-static-analyzer.html)
- [Loop unrolling](https://haxe.org/manual/cr-loop-unrolling.html)
- [Tail Recursion Elimination (TRE)](https://haxe.org/manual/cr-tail-recursion-elimination.html)
- [Null Safety](https://haxe.org/manual/cr-null-safety.html)
- [Warnings](https://haxe.org/manual/cr-warnings.html)
- [Macros](https://haxe.org/manual/macro.html)
- [Macro Context](https://haxe.org/manual/macro-context.html)
- [Arguments](https://haxe.org/manual/macro-arguments.html)
- [ExprOf](https://haxe.org/manual/macro-ExprOf.html)
- [Constant Expressions](https://haxe.org/manual/macro-constant-arguments.html)
- [Rest Argument](https://haxe.org/manual/macro-rest-argument.html)
- [Reification](https://haxe.org/manual/macro-reification.html)
- [Expression Reification](https://haxe.org/manual/macro-reification-expression.html)
- [Type Reification](https://haxe.org/manual/macro-reification-type.html)
- [Class Reification](https://haxe.org/manual/macro-reification-class.html)
- [Tools](https://haxe.org/manual/macro-tools.html)
- [Type Building](https://haxe.org/manual/macro-type-building.html)
- [Enum building](https://haxe.org/manual/macro-enum-building.html)
- [@:autoBuild](https://haxe.org/manual/macro-auto-build.html)
- [@:genericBuild](https://haxe.org/manual/macro-generic-build.html)
- [Limitations](https://haxe.org/manual/macro-limitations.html)
- [Macro-in-Macro](https://haxe.org/manual/macro-limitations-macro-in-macro.html)
- [Static extension](https://haxe.org/manual/macro-limitations-static-extension.html)
- [Build Order](https://haxe.org/manual/macro-limitations-build-order.html)
- [Type Parameters](https://haxe.org/manual/macro-limitations-type-parameters.html)
- [Persistent Variables](https://haxe.org/manual/macro-persistent-variables.html)
- [Initialization Macros](https://haxe.org/manual/macro-initialization.html)
- [Standard Library](https://haxe.org/manual/std.html)
- [String](https://haxe.org/manual/std-String.html)
- [String literals](https://haxe.org/manual/std-String-literals.html)
- [Unicode](https://haxe.org/manual/std-String-unicode.html)
- [Encoding](https://haxe.org/manual/std-String-encoding.html)
- [Data Structures](https://haxe.org/manual/std-ds.html)
- [Array](https://haxe.org/manual/std-Array.html)
- [Vector](https://haxe.org/manual/std-vector.html)
- [List](https://haxe.org/manual/std-List.html)
- [GenericStack](https://haxe.org/manual/std-GenericStack.html)
- [Map](https://haxe.org/manual/std-Map.html)
- [Option](https://haxe.org/manual/std-Option.html)
- [Regular Expressions](https://haxe.org/manual/std-regex.html)
- [Matching](https://haxe.org/manual/std-regex-match.html)
- [Groups](https://haxe.org/manual/std-regex-groups.html)
- [Replace](https://haxe.org/manual/std-regex-replace.html)
- [Split](https://haxe.org/manual/std-regex-split.html)
- [Map](https://haxe.org/manual/std-regex-map.html)
- [Implementation Details](https://haxe.org/manual/std-regex-implementation-details.html)
- [Math](https://haxe.org/manual/std-math.html)
- [Special Numbers](https://haxe.org/manual/std-math-special-numbers.html)
- [Mathematical Errors](https://haxe.org/manual/std-math-mathematical-errors.html)
- [Integer Math](https://haxe.org/manual/std-math-integer-math.html)
- [Extensions](https://haxe.org/manual/std-math-extensions.html)
- [Lambda](https://haxe.org/manual/std-Lambda.html)
- [Template](https://haxe.org/manual/std-template.html)
- [Reflection](https://haxe.org/manual/std-reflection.html)
- [Serialization](https://haxe.org/manual/std-serialization.html)
- [Serialization format](https://haxe.org/manual/std-serialization-format.html)
- [Xml](https://haxe.org/manual/std-Xml.html)
- [Getting started with Xml](https://haxe.org/manual/std-Xml-getting-started.html)
- [Parsing Xml](https://haxe.org/manual/std-Xml-parsing.html)
- [Encoding Xml](https://haxe.org/manual/std-Xml-encoding.html)
- [Simplified Xml access](https://haxe.org/manual/std-Xml-simplified-access.html)
- [Json](https://haxe.org/manual/std-Json.html)
- [Parsing JSON](https://haxe.org/manual/std-Json-parsing.html)
- [Encoding JSON](https://haxe.org/manual/std-Json-encoding.html)
- [Implementation details](https://haxe.org/manual/std-Json-implementation-details.html)
- [Input/Output](https://haxe.org/manual/std-input-output.html)
- [Sys](https://haxe.org/manual/std-sys.html)
- [Threading](https://haxe.org/manual/std-threading.html)
- [Standard IO Streams](https://haxe.org/manual/std-sys-standard-io-streams.html)
- [Process](https://haxe.org/manual/std-input-output-process.html)
- [Remoting](https://haxe.org/manual/std-remoting.html)
- [Remoting Connection](https://haxe.org/manual/std-remoting-connection.html)
- [Implementation details](https://haxe.org/manual/std-remoting-implementation-details.html)
- [Unit Testing](https://haxe.org/manual/std-unit-testing.html)
- [Haxe 3 Compatibility](https://haxe.org/manual/std-hx3compat.html)
- [Haxelib](https://haxe.org/manual/haxelib.html)
- [Target Details](https://haxe.org/manual/target-details.html)
- [Accessing Target-specific Syntax](https://haxe.org/manual/target-syntax.html)
- [JavaScript](https://haxe.org/manual/target-javascript.html)
- [Getting started with Haxe/JavaScript](https://haxe.org/manual/target-javascript-getting-started.html)
- [ECMAScript 6 class generation](https://haxe.org/manual/target-javascript-es6.html)
- [Using external JavaScript libraries](https://haxe.org/manual/target-javascript-external-libraries.html)
- [JavaScript target Metadata](https://haxe.org/manual/target-javascript-metadata.html)
- [Exposing Haxe classes for JavaScript](https://haxe.org/manual/target-javascript-expose.html)
- [Loading extern classes using "require" function](https://haxe.org/manual/target-javascript-require.html)
- [Flash](https://haxe.org/manual/target-flash.html)
- [Getting started with Haxe/Flash](https://haxe.org/manual/target-flash-getting-started.html)
- [Embedding resources](https://haxe.org/manual/target-flash-resources.html)
- [Using external Flash libraries](https://haxe.org/manual/target-flash-external-libraries.html)
- [Flash target Metadata](https://haxe.org/manual/target-flash-metadata.html)
- [Neko](https://haxe.org/manual/target-neko.html)
- [Getting started with Haxe/Neko](https://haxe.org/manual/target-neko-getting-started.html)
- [PHP](https://haxe.org/manual/target-php.html)
- [Getting started with Haxe/PHP](https://haxe.org/manual/target-php-getting-started.html)
- [Defines](https://haxe.org/manual/target-php-defines.html)
- [C++](https://haxe.org/manual/target-cpp.html)
- [Getting started with Haxe/C++](https://haxe.org/manual/target-cpp-getting-started.html)
- [The Hxcpp Build Environment](https://haxe.org/manual/target-cpp-build-environment.html)
- [Build.xml](https://haxe.org/manual/target-cpp-file-format.html)
- [Structure of the top-level](https://haxe.org/manual/target-cpp-build_xml-TopLevel.html)
- [Files](https://haxe.org/manual/target-cpp-build_xml-Files.html)
- [Tags](https://haxe.org/manual/target-cpp-build_xml-Tags.html)
- [Targets](https://haxe.org/manual/target-cpp-build_xml-Targets.html)
- [Compiler](https://haxe.org/manual/target-cpp-build_xml-Compiler.html)
- [Linker](https://haxe.org/manual/target-cpp-build_xml-Linker.html)
- [Stripper](https://haxe.org/manual/target-cpp-build_xml-Stripper.html)
- [The Haxe Target](https://haxe.org/manual/target-cpp-build_xml-HaxeTarget.html)
- [Xml Injection](https://haxe.org/manual/target-cpp-build_xml-XmlInjection.html)
- [Defines](https://haxe.org/manual/target-cpp-defines.html)
- [The Hxcpp Cache](https://haxe.org/manual/target-cpp-CompileCache.html)
- [Threads And Stacks](https://haxe.org/manual/target-cpp-ThreadsAndStacks.html)
- [Cppia](https://haxe.org/manual/target-cppia.html)
- [Getting started with Haxe/Cppia](https://haxe.org/manual/target-cppia-getting-started.html)
- [Java](https://haxe.org/manual/target-java.html)
- [Getting started with Haxe/Java](https://haxe.org/manual/target-java-getting-started.html)
- [JVM](https://haxe.org/manual/target-jvm.html)
- [Getting started with Haxe/JVM](https://haxe.org/manual/target-jvm-getting-started.html)
- [C\#](https://haxe.org/manual/target-cs.html)
- [Getting started with Haxe/C\#](https://haxe.org/manual/target-cs-getting-started.html)
- [.NET version and external libraries](https://haxe.org/manual/target-cs-external-libraries.html)
- [Haxe/C\# Defines](https://haxe.org/manual/target-cs-defines.html)
- [Haxe/C\# Metadata](https://haxe.org/manual/target-cs-metadata.html)
- [Injecting raw C\# code](https://haxe.org/manual/target-cs-code-injection.html)
- [Python](https://haxe.org/manual/target-python.html)
- [Getting started with Haxe/Python](https://haxe.org/manual/target-python-getting-started.html)
- [Lua](https://haxe.org/manual/target-lua.html)
- [Getting started with Haxe/Lua](https://haxe.org/manual/target-lua-getting-started.html)
- [Using external Lua libraries](https://haxe.org/manual/target-lua-external-libraries.html)
- [Version flags](https://haxe.org/manual/target-lua-flags.html)
- [Multireturns](https://haxe.org/manual/target-lua-multireturns.html)
- [HashLink](https://haxe.org/manual/target-hl.html)
- [Getting started with Haxe/HashLink](https://haxe.org/manual/target-hl-getting-started.html)
- [HashLink/C Compilation](https://haxe.org/manual/target-hl-c-compilation.html)
- [Debugging](https://haxe.org/manual/debugging.html)
- [Logging and Trace](https://haxe.org/manual/debugging-trace-log.html)
- [Position Information Parameter](https://haxe.org/manual/debugging-posinfos.html)
- [Tracing Types](https://haxe.org/manual/debugging-type-function.html)
- [IDE Integration](https://haxe.org/manual/debugging-ide-integration.html)
- [Debugging in JavaScript](https://haxe.org/manual/debugging-javascript.html)
- [Source Maps](https://haxe.org/manual/debugging-source-map.html)
- [Source Maps in JavaScript](https://haxe.org/manual/debugging-source-map-javascript.html)
- [Source Maps in PHP7](https://haxe.org/manual/debugging-sourcemap-php7.html)
# 7 Compiler Usage
##### [Basic Usage](https://haxe.org/manual/compiler-usage.html#basic-usage)
The Haxe Compiler is typically invoked from command line with several arguments which have to answer two questions:
- What should be compiled?
- What should the output be?
To answer the first question, it is usually sufficient to provide a class path via the `-p <path>` argument, along with the main class to be compiled via the `-m <dot_path>` argument. The Haxe Compiler then resolves the main class file and begins compilation.
The second question usually comes down to providing an argument specifying the desired target. Each Haxe target has a dedicated command line switch, such as `--js <file_name>` for JavaScript and `--php <directory>` for PHP. Depending on the nature of the target, the argument value is either a directory path (for `--php`, `--cpp`, `--cs`, and `--java`) or a file name.
##### [Common arguments](https://haxe.org/manual/compiler-usage.html#common-arguments)
**Input:**
- `-p <path>` (or `--class-path <path>`) Add a class path where `.hx` source files or packages (sub-directories) can be found.
- `-L <library_name>` (or `--library <library_name>`) Add a [Haxelib](https://haxe.org/manual/haxelib.html) library. By default the most recent version in the local Haxelib repository is used. To require a specific library version use `-L library_name:version`. To require a version from git use `-L library_name:git:https://github.com/user/project.git#commit` where the optional \#commit can be a branch, tag or commit hash.
- `-m <dot_path>` (or `--main <dot_path>`) Set the main class.
- `-D <var[=value]>` (or `--define <var[=value]>`) Define a [conditional compilation flag](https://haxe.org/manual/lf-condition-compilation.html).
**Output:**
- `--js <file_name.js>` Generate [JavaScript](https://haxe.org/manual/target-javascript.html) source code in specified file.
- `--swf <file_name.swf>` Generate the specified file as [Flash](https://haxe.org/manual/target-flash.html) `.swf`.
- `--neko <file_name.n>` Generate [Neko](https://haxe.org/manual/target-neko.html) binary as specified file.
- `--php <directory>` Generate [PHP](https://haxe.org/manual/target-php.html) source code in specified directory. Use `-D php7` for PHP7 source code.
- `--cpp <directory>` Generate [C++](https://haxe.org/manual/target-cpp.html) source code in specified directory and compiles it using native C++ compiler.
- `--cs <directory>` Generate [C\#](https://haxe.org/manual/target-cs.html) source code in specified directory and compiles it using native C\# compiler.
- `--java <directory>` Generate [Java](https://haxe.org/manual/target-java.html) source code in specified directory and compiles it using the Java Compiler. Add `-D jvm` to generate JVM byte code directly bypassing Java compilation step.
- `--jvm <file_name.jar>` Generate [JVM bytecode](https://haxe.org/manual/target-jvm.html) as a jar file.
- `--python <file_name.py>` Generate [Python](https://haxe.org/manual/target-python.html) source code in the specified file.
- `--lua <file_name.lua>` Generate [Lua](https://haxe.org/manual/target-lua.html) source code in the specified file.
- `--hl <file_name.hl>` Generate [HashLink](https://haxe.org/manual/target-hl.html) byte code in specified file.
- `--cppia <file_name.cppia>` Generate the specified script as a [cppia](https://haxe.org/manual/target-cppia.html) file.
- `-x <file>` Shortcut for compiling and executing a Neko file.
- `--no-output` Compile but do not generate any file.
- `--interp` Interpret the program using internal macro system.
##### [Other global arguments](https://haxe.org/manual/compiler-usage.html#other-global-arguments)
- `--run <module> [args...]` Compile and execute a Haxe module with command line arguments.
- `--xml <file>` Generate XML types description. Useful for API documentation generation tools like [Dox](https://github.com/HaxeFoundation/dox).
- `--json <file>` Generate JSON types description.
- `-v` (or `--verbose`) Turn on verbose mode.
- `--dce <std|full|no>` Set the [Dead Code Elimination](https://haxe.org/manual/cr-dce.html) mode (default `std`).
- `--debug` Add debug information to the compiled code.
- `-r <file>[@name]` (or `--resource <file>[@name]`) Add a named resource file.
- `--prompt` Prompt on error.
- `--cmd <command>` Run the specified shell command after a successful compilation.
- `--no-traces` Don't compile trace calls in the program.
- `--display` Display code tips to provide [completion information for IDEs and editors](https://haxe.org/manual/cr-completion-overview.html).
- `--times` Measure compilation times.
- `--no-inline` Disable [inlining](https://haxe.org/manual/class-field-inline.html).
- `--no-opt` Disable code optimizations.
- `--remap <package:target>` Remap a package to another one.
- `--macro` Call the given [initialization macro](https://haxe.org/manual/macro-initialization.html) before typing anything else.
- `--wait <host:port>` Wait on the given port for commands to run (see [Completion server](https://haxe.org/manual/cr-completion-server.html)).
- `--connect <host:port>` Connect on the given port and run commands there (see [Completion server](https://haxe.org/manual/cr-completion-server.html)).
- `-C <dir>` (or `--cwd <dir>`) Set current working directory.
##### [Target specific arguments](https://haxe.org/manual/compiler-usage.html#target-specific-arguments)
- `-D php-front=<filename>` Select the name for the php front file.
- `-D php-lib=<filename>` Select the name for the php lib folder.
- `-D php-prefix=<name>` Prefix all classes with given name.
- `--swf-version <version>` Change the SWF version.
- `--swf-header <header>` Define SWF header (width:height:fps:color).
- `--swf-lib <file>` Add the SWF library to the compiled SWF.
- `--swf-lib-extern <file>` Use the SWF library for type checking.
- `--flash-strict` More type strict flash API.
- `--java-lib <file>` Add an external JAR or class directory library.
- `--net-lib <file>[@std]` Add an external .NET DLL file.
- `--net-std <file>` Add a root std .NET DLL search path.
- `--c-arg <arg>` Pass option `arg` to the native Java/C\# compiler.
> ##### [Trivia: Run commands after compilation](https://haxe.org/manual/compiler-usage.html#trivia-run-commands-after-compilation)
> Use `--cmd` to run the specified command after a successful compilation. It can be used to run (testing) tools or to directly run the build, e.g. `--cmd java -jar bin/Main.jar` (for Java), `--cmd node main.js` (for Node.js) or `--cmd neko Main.n` (for Neko) etc.
##### [Global compiler configuration macros:](https://haxe.org/manual/compiler-usage.html#global-compiler-configuration-macros)
In order to include single modules, their paths can be listed directly on command line or in hxml: `haxe ... ModuleName pack.ModuleName`. For more specific includes or excludes, use these [initialization macros](https://haxe.org/manual/macro-initialization.html):
- `--macro include(pack:String, recursive=true, ?ignore:Array<String>, ?classPaths:Array<String>, strict=false)` Includes all modules in package pack in the compilation. If `recursive` is true, the compiler recursively adds all sub-packages.
- `--macro exclude(pack:String, recursive=true` Exclude a specific class, enum, or all classes and enums in a package from being generated. Excluded types become `extern`. If `recursive` is true, the compiler recursively excludes all sub-packages.
- `--macro excludeFile(fileName:String)` Exclude classes and enums listed from given external file (one per line) from being generated.
- `--macro keep(?path:String, ?paths:Array<String>, recursive=true)` Marks a package, module or sub-type dot path to be kept by DCE. This also extends to the sub-types of resolved modules. If `recursive` is true, the compiler recursively keeps all sub-packages for package paths.
- `--macro includeFile(file:String, position)` Embed a JavaScript file at compile time. `position` can be either "top", "inline" or "closure".
The full documentation of these methods can be found in the [`haxe.macro.Compiler`](http://api.haxe.org/haxe/macro/Compiler.html) API documentation.
##### [Help](https://haxe.org/manual/compiler-usage.html#help)
- `haxe --version` Print the current Haxe compiler version.
- `haxe --help` Display this list of options.
- `haxe --help-defines` Print help for all [compiler specific defines](https://haxe.org/manual/compiler-usage-flags.html).
- `haxe --help-metas` Print help for all [compiler metadata](https://haxe.org/manual/lf-condition-compilation.html).
##### [Related content](https://haxe.org/manual/compiler-usage.html#related-content)
- [Compilation tutorials](http://code.haxe.org/category/compilation/) in the Haxe Code Cookbook.
[Inline Constructors](https://haxe.org/manual/lf-inline-constructor.html)[Contribute to this page](https://github.com/HaxeFoundation/HaxeManual/tree/master/content/07-compiler-usage.md#L1-L104)[HXML](https://haxe.org/manual/compiler-usage-hxml.html)
***
- ##### [Home](https://haxe.org/)
##### [Download](https://haxe.org/download/)
##### [Blog](https://haxe.org/blog/)
##### [Support Plans](https://haxe.org/foundation/support-plans.html)
- ##### [Use Cases](https://haxe.org/use-cases/)
- [Overview](https://haxe.org/use-cases/)
- [Games](https://haxe.org/use-cases/games/)
- [Web](https://haxe.org/use-cases/web/)
- [Mobile](https://haxe.org/use-cases/mobile/)
- [Desktop](https://haxe.org/use-cases/desktop/)
- [Command Line](https://haxe.org/use-cases/cli/)
- [Cross Platform APIs](https://haxe.org/use-cases/cross-platform-apis/)
- [Who Uses Haxe](https://haxe.org/use-cases/who-uses-haxe.html)
- ##### [Haxe Foundation](https://haxe.org/foundation/)
- [About The Foundation](https://haxe.org/foundation/)
- [Who is who](https://haxe.org/foundation/people.html)
- [Jobs](https://haxe.org/foundation/jobs.html)
- [Supported Projects](https://haxe.org/foundation/supported-projects.html)
- [Support Plans](https://haxe.org/foundation/support-plans.html)
- [Donate](https://haxe.org/foundation/donate.html)
- [Branding](https://haxe.org/foundation/branding.html)
- [Shop](https://haxe.org/foundation/shop.html)
- [Open Source](https://haxe.org/foundation/open-source.html)
- [Contact](https://haxe.org/foundation/contact.html)
- ##### [Learn Haxe](https://haxe.org/documentation/introduction)
- [Introduction](https://haxe.org/documentation/introduction/)
- [Manual](https://haxe.org/manual/)
- [Code Cookbook](https://code.haxe.org/)
- [API Documentation](https://api.haxe.org/)
- [Videos](https://haxe.org/videos/)
- [Try Haxe online](https://try.haxe.org/)
- [Haxelib](https://lib.haxe.org/)
© 2025 [Haxe Foundation](https://haxe.org/foundation/ "Haxe Foundation Website") \| [Contribute to this page](https://github.com/HaxeFoundation/HaxeManual/tree/master/content/07-compiler-usage.md#L1-L104 "Use Github to suggest an edit to this page")

 |
| Readable Markdown | null |
| Shard | 46 (laksa) |
| Root Hash | 1361353600043012046 |
| Unparsed URL | org,haxe!/manual/compiler-usage.html s443 |