2013-01-14 117 views
3

我有launch4j配置爲我的項目。我用它回來,當我在WindowsXP上開發,它在哪裏工作。現在我需要它來建立在Mac以及:Launch4j/windres:如何正確設置路徑?

我的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 

回答

2

我正面臨同樣的問題並且無法正確設置路徑/類路徑,但作爲解決方案,我在launch4j目錄內創建了Ant構建,並且能夠生成可執行文件。

+0

今天發現一樣。謝謝。 –

+0

@Leo:你能解釋一下「在launch4j目錄下創建Ant構建」是什麼意思嗎?我遇到這個問題,我很茫然。我正在建立Netbeans。 – Clayton

+1

將ant-buildfile放入launch4j-dir中,並更改所有路徑以解決此問題。 –

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 - 它只返回的URI開頭的路徑部分/。我改變了最後兩行到這一點,並開始工作:

if (path.startsWith("/")) { 
    String jarPath = path.substring(0, path.lastIndexOf('!')); 

注5 - 在子,因爲我們並不需要刪除> 0「文件:」部分了。 我不得不將build.xml.prod重命名爲build.xml,以便編譯launch4j,但除此之外它工作正常。

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/" /> 

Greetings,-chris-

+1

不錯。你把它提交給launch4j開發者了嗎? –

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插入本身就存在,而不是我。

6

對於那些體驗:在64位Linux上運行windres

error=2, No such file or directory 

問題,您需要安裝32位的庫。在Linux Mint上,我安裝了包ia32-libs:

sudo apt-get install ia32-libs 
+1

在Amazon EC2上的Centos構建機器上運行此操作,必須使用此修復: yum install glibc-2.12-1.149.el6.i686 – SteveDonie

+0

似乎這些已過時。在Ubuntu 16.04上,它建議以下工作:sudo apt-get install lib32ncurses5 lib32z1 – javydreamercsw

相關問題