ocamljava icon indicating copy to clipboard operation
ocamljava copied to clipboard

ocamljava error during linking on Windows; ocaml, ocamlc, & ocamlrun all work

Open ghost opened this issue 11 years ago • 5 comments

First, thanks for a Java version of OCaml. For months I've been trying to find one programming language that's a good compromise between a number of things: functional, to go along with theorem proving, but with the potential for more easily tapping into parallel programming. I noticed your ForkJoin, MapReduce, etc., and since OCaml-Java is tied into Java, there's the possibility of Jcuda.

Now the problems. The second problem is the important one.

  • An easy problem is that the batch files don't work if there are spaces in the path. That's because there are no quotes around the jar file argument. A normal line looks like this:

    "%OCJ_JAVA%" -Xss8M -jar %~dp0/../lib/ocamlc.jar %*

It's not a problem, really. I just put the argument in quotes.

  • The reason I'm submitting this is because ocamljava gives the following error due to linking:

    E:\E_1\02-p\1o_jv_w rk_test> ocamljava -o "E:\E_1\02-p\1o_jv_w rk_test\hello_world.jar" "E:\E_1\02-p\1o_jv_w rk_test\hello_world.ml" File "E:\E_1\02-p\1o_jv_w rk_test\hello_world.ml", line 1: Error: Error during linking: unable to open archive ("\ocamljava-2.0-alpha2\lib\ocaml\ocamlrun.jar")

Here is some additional information.

  • I'm not having any problems like that for ocaml, ocamlc, and ocamlrun, which are the only other commands I've used.
  • If I compile and link in two steps, it still doesn't work.
  • I get the same error with ocamljava-2.0-alpha1.
  • I don't get that error with ocamljava-2.0-early-access11.

Thanks.

ghost avatar Nov 19 '14 22:11 ghost

What steps did you take beyond the environment variable to install it? In particular, are the jar files located in C:\ or elsewhere? It needs to read from it's own library and it can't find what I think is probably the ocaml-lib-files.jar In the installation lib directory, there is a jar embedded in it equal to the missing resource:

$ jar tvf ocaml-lib-files.jar | grep jar 1175509 Tue Jul 01 07:46:30 EDT 2014 ocamljava-2.0-early-access12/lib/ocaml/ocamlrun.jar

If you move the installation to C:\ it might work. I myself have similar loading issues when trying to separate the jars into different folders (issue #3).

struktured avatar Nov 20 '14 01:11 struktured

I only set JAVA_HOME and my PATH like this in a batch file, and start jEdit:

set JAVA_HOME=E:\E_2\jre7-64
set PATH=%JAVA_HOME%\bin;%PATH%
set PATH=C:\ocamljava_v2.0-alpha2\bin;%PATH%

I put it on C like shown here, but it doesn't work:

C:\ocjtest> echo %JAVA_HOME%
   E:\E_2\jre7-64
   Process echo exited with code 0
C:\ocjtest> which ocamljava.bat
   C:\ocamljava_v2.0-alpha2\bin\ocamljava.bat
   Process which exited with code 0
C:\ocjtest> cat hello_world.ml
   print_string "hello world!\n";;
   Process cat exited with code 0
C:\ocjtest> ocamljava.bat -o hello_world.jar hello_world.ml
   File "hello_world.ml", line 1:
   Error: Error during linking:
   unable to open archive ("\\ocamljava-2.0-alpha2\\lib\\ocaml\\ocamlrun.jar")

I change to ocamljava-2.0-early-access11, and it works, and the jar executes:

C:\ocjtest> which ocamljava.bat
   C:\ocamljava-2.0-early-access11\bin\ocamljava.bat
   Process which exited with code 0
C:\ocjtest> ocamljava.bat -o hello_world.jar hello_world.ml
   Process ocamljava.bat exited with code 0
C:\ocjtest> java -jar hello_world.jar
   hello world!
   Process java exited with code 0

Your error message is what came up on a Google search, and brought me here. Thanks.

ghost avatar Nov 20 '14 02:11 ghost

Ghost, I encounter the same problem as you did... did you solve the issue ?

kyoann avatar Dec 01 '15 18:12 kyoann

Ghost, @kyoann

unable to open archive ("\\ocamljava-2.0-alpha2\\lib\\ocaml\\ocamlrun.jar")

set PATH=C:\ocamljava_v2.0-alpha2\bin;%PATH%

Your problem might be that

ocamljava_v2.0-alpha2 != ocamljava-2.0-alpha2

The hard coded path has to match up exactly.

struktured avatar May 12 '16 20:05 struktured

Since I'had the same problem with alpha3 and just solved it, I'd share:

You go to \\ocamljava-2.0-alpha3\\lib\\ and there you'll find a file ocaml-lib-files.jar . Open it with 7zip and cope the ocaml folder to lib

Now you can link hello-world.jar and it runs

vrotaru avatar Apr 14 '18 07:04 vrotaru