我为我的项目启动了launch4j配置。当我在windowsXP上开发它时,我用它回来了。现在我需要它在Mac上构建:
我的build.xml:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project default="create-exe">
<property name="platform" value="win32"/>
<property name="launch4j.dir" location="${basedir}/tools/launch4j/" />
<include file="create-jar.xml" as="sub"/>
<target name="create-exe" depends = "sub.create-jar">
<launch4j configFile="launch4j-config.xml" />
<delete file="client.win32.jar"/>
</target>
<taskdef name="launch4j" classname="net.sf.launch4j.ant.Launch4jTask">
<classpath>
<pathelement path="tools/launch4j/launch4j.jar"/>
<pathelement path="tools/launch4j/lib/xstream.jar"/>
</classpath>
</taskdef>
</project>
我得到以下输出:
create-exe:
[launch4j] Compiling resources
[launch4j] Generated resource file...
[launch4j] LANGUAGE 0, 1
[launch4j] 2 RCDATA BEGIN "1.6.0\0" END
[launch4j] 18 RCDATA BEGIN "0\0" END
[launch4j] 25 RCDATA BEGIN "512\0" END
[launch4j] 27 RCDATA BEGIN "1024\0" END
[launch4j] 21 RCDATA BEGIN "http://java.com/download\0" END
[launch4j] 20 RCDATA BEGIN "32\0" END
[launch4j] 9 RCDATA BEGIN "true\0" END
[launch4j] 101 RCDATA BEGIN "An error occurred while starting the application.\0" END
[launch4j] 102 RCDATA BEGIN "This application was configured to use a bundled Java Runtime Environment but the runtime is missing or corrupted.\0" END
[launch4j] 103 RCDATA BEGIN "This application requires a Java Runtime Environment\0" END
[launch4j] 104 RCDATA BEGIN "The registry refers to a nonexistent Java Runtime Environment installation or the runtime is corrupted.\0" END
[launch4j] 17 RCDATA BEGIN "true\0" END
BUILD FAILED
/Users/fabian/dev/rsys-client/create-win32-exe.xml:9: net.sf.launch4j.BuilderException: net.sf.launch4j.ExecException: java.io.IOException: Cannot run program "./bin/windres": error=2, No such file or directory
当我将bindir="tools/launch4j/bin"
添加到launch4j执行时,找到了ld和windres,输出变为:
create-exe:
[launch4j] Compiling resources
[launch4j] Linking
[launch4j] /Users/fabian/dev/rsys-client/tools/launch4j/bin/ld: cannot find ./w32api/crt2.o: No such file or directory
[launch4j] /Users/fabian/dev/rsys-client/tools/launch4j/bin/ld: cannot find ./head/guihead.o: No such file or directory
[launch4j] /Users/fabian/dev/rsys-client/tools/launch4j/bin/ld: cannot find ./head/head.o: No such file or directory
[launch4j] /Users/fabian/dev/rsys-client/tools/launch4j/bin/ld: cannot find ./w32api/libmingw32.a: No such file or directory
[launch4j] /Users/fabian/dev/rsys-client/tools/launch4j/bin/ld: cannot find ./w32api/libgcc.a: No such file or directory
[launch4j] /Users/fabian/dev/rsys-client/tools/launch4j/bin/ld: cannot find ./w32api/libmsvcrt.a: No such file or directory
[launch4j] /Users/fabian/dev/rsys-client/tools/launch4j/bin/ld: cannot find ./w32api/libkernel32.a: No such file or directory
[launch4j] /Users/fabian/dev/rsys-client/tools/launch4j/bin/ld: cannot find ./w32api/libuser32.a: No such file or directory
[launch4j] /Users/fabian/dev/rsys-client/tools/launch4j/bin/ld: cannot find ./w32api/libadvapi32.a: No such file or directory
[launch4j] /Users/fabian/dev/rsys-client/tools/launch4j/bin/ld: cannot find ./w32api/libshell32.a: No such file or directory
BUILD FAILED
/Users/fabian/dev/rsys-client/create-win32-exe.xml:9: net.sf.launch4j.BuilderException: net.sf.launch4j.ExecException: Exec failed (1): /Users/fabian/dev/rsys-client/tools/launch4j/bin/ld -mi386pe --oformat pei-i386 --dynamicbase --nxcompat --no-seh --subsystem windows -s ./w32api/crt2.o ./head/guihead.o ./head/head.o /var/folders/n5/44dkvyzd00z0h5mklk_pwtch0000gn/T/launch4j3026065429236284429o ./w32api/libmingw32.a ./w32api/libgcc.a ./w32api/libmsvcrt.a ./w32api/libkernel32.a ./w32api/libuser32.a ./w32api/libadvapi32.a ./w32api/libshell32.a -o /Users/fabian/dev/rsys-client/Kassa.exe
Total time: 6 seconds
答案 0 :(得分:6)
对于那些经历过:
的人error=2, No such file or directory
在64位Linux上运行 windres 时出现问题,您需要安装32位库。在Linux Mint上我安装了包ia32-libs:
sudo apt-get install ia32-libs
答案 1 :(得分:4)
当您的当前目录不是launch4j目录时会发生此错误,正如Leo所说。
Launch4j试图通过查找找到自己的安装目录 launch4j.properties的类路径。这是在Util.java中完成的 getJarBaseDir()方法。最近更改了这些内容:
URI uri = new URI(Util.class.getClassLoader()
.getResource(Launch4jProperties)
.getFile());
String path = uri.getPath();
if (path.startsWith("file:")) {
String jarPath = path.substring(5,path.lastIndexOf('!'));
问题是uri.getPath()没有返回本地文件URI的“file:”部分 - 它只返回以/开头的URI的路径部分。我将最后两行更改为此,然后开始工作:
if (path.startsWith("/")) {
String jarPath = path.substring(0, path.lastIndexOf('!'));
注意5 - &gt;在子字符串中为0因为我们不再需要删除“file:”部分。 我不得不将build.xml.prod重命名为build.xml以编译launch4j,但除此之外它工作得很好。
答案 2 :(得分:2)
我遇到了同样的问题并且无法正确设置路径/类路径,但作为一种解决方法,我在launch4j目录中创建了Ant构建,并且我能够使其生成可执行文件。
答案 3 :(得分:2)
我也有这个问题,我通过修改launch4j代码修复了它 在类Launch4JTask.java中,我替换了行
final Builder b = new Builder(Log.getAntLog());
这一个
final Builder b = new Builder(Log.getAntLog(), new File(getOwningTarget().getProject().getProperty("launch4j.bindir")));
通过此更改,我可以在我的ant构建脚本中指定Launch4j的路径,就像那样
<property name="launch4j.bindir" location="../tools/launch4j/" />
问候,-chris -
答案 4 :(得分:0)
我在Maven中构建launch4j时遇到了类似的问题:
...
[INFO] launch4j: (longPathIn.m2Repository)\windres.exe: can't popen `type (longPathToTemp)\Temp\launch4j8580185391499327059rc': No error
[ERROR]
net.sf.launch4j.BuilderException: net.sf.launch4j.ExecException: Exec failed(1): [Ljava.lang.String;@9f1fb5
at net.sf.launch4j.Builder.build(Builder.java:145)
...
清洁系统变量ComSpec后,它开始正常工作:
was: ComSpec=%SystemRoot%\system32\cmd.exe;c:\Program Files (x86)\NSIS\NSIS.exe
now: ComSpec=%SystemRoot%\system32\cmd.exe
似乎NSIS在那里插入了自己,而不是我。