Apache flex 使用mxmlc构建flex库

Apache flex 使用mxmlc构建flex库,apache-flex,mxmlc,Apache Flex,Mxmlc,我想通过mxmlc编译器直接构建一个flex库项目。我的库有一个.as文件,它在一个名为com.test的包中 package com.test { public class Main { public function Main(){... 我在cmd上运行以下命令 D:\4.11.0\bin\mxmlc D:\TestLibrary\src\com\test\Main.as 但它给了我以下的错误 Error: A file found in a source-path must hav

我想通过mxmlc编译器直接构建一个flex库项目。我的库有一个.as文件,它在一个名为com.test的包中

package com.test { public class Main {  public function Main(){...
我在cmd上运行以下命令

D:\4.11.0\bin\mxmlc D:\TestLibrary\src\com\test\Main.as
但它给了我以下的错误

Error: A file found in a source-path must have the same package structure '', as the definition's package, 'com.test'
如果我从脚本中删除包定义,如下所示,它将正常工作

package { public class Main { ...

我的问题是为什么会发生这种情况以及如何修复它?

您需要另外告诉编译器源代码的根:

mxmlc D:\TestLibrary\src\com\test\Main.as -source-path D:\TestLibrary\src\

通过提供“source path”属性,您可以告诉编译器根所在的位置以及与之相关的位置,现在它应该知道com.test.Main是类的相对路径。

谢谢Charisofer,最后我可以构建库项目并生成swc文件。这是我使用的命令。希望对其他人有帮助

D:\4.11.0\bin\compc -source-path D:\TestLibrary\src -include-sources D:\TestLibrary\src\com\test\Main.as -debug=false -output D:\Auto_Release\main.swc
要构建swf,需要使用mxmlc


要构建swc,需要使用compc

谢谢,它现在可以工作了。我想构建库项目的swc,但是这个命令生成swf文件。如何生成swc文件?mxmlc用于编译SWF,如果您想编译swc,请使用compc()