Build Launch4j/windres:如何正确设置路径?

Build Launch4j/windres:如何正确设置路径?,build,path,launch4j,Build,Path,Launch4j,我已经为我的项目启动了4J配置。当我在windowsXP上开发它时,我用过它,它在那里工作。现在我也需要它在mac上构建: My build.xml: <?xml version="1.0" encoding="UTF-8" standalone="no"?> <project default="create-exe"> <property name="platform" value="win32"/> <property name="

我已经为我的项目启动了4J配置。当我在windowsXP上开发它时,我用过它,它在那里工作。现在我也需要它在mac上构建:

My 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>
当我将
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

我也遇到了同样的问题,无法正确设置路径/类路径,但作为一种解决方法,我在launch4j目录中创建了Ant构建,并能够让它生成可执行文件。

如Leo所述,当当前目录不是launch4j目录时,会发生此错误

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->0,因为我们不再需要删除“文件:”部分。
为了编译launch4j,我不得不将build.xml.prod重命名为build.xml,但除此之外,它工作得很好

我也有这个问题,我通过修改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构建脚本中指定启动4j的路径,如下所示

<property name="launch4j.bindir" location="../tools/launch4j/" />


您好,-chris-

我在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是在那里插入的,而不是我。

对于那些经历过以下情况的人:

error=2, No such file or directory
问题在64位Linux上运行windres时,需要安装32位库。在Linux Mint上,我安装了带有以下内容的包ia32 libs:

sudo apt-get install ia32-libs

今天也发现了同样的情况。谢谢。@Leo:你能解释一下“在launch4j目录中创建Ant构建”是什么意思吗?我有这个问题,我不知所措。我正在Netbeans中构建。将ant构建文件放在launch4j目录中,并更改所有路径以解决此问题。很好。您是否已将其提交给launch4j开发人员?在Amazon EC2上的Centos构建机器上遇到此问题,必须使用此解决方法:yum install glibc-2.12-1.149.el6.i686这些似乎已过时。在Ubuntu16.04上,它提出了以下建议:sudo apt get install lib32ncurses5 lib32z1
sudo apt-get install ia32-libs