0

I've got this program called threadtest.ml:

Thread.join (Thread.create (fun _ -> print_string "Hello, World!\n") ())

I'm compiling it like so:

$ ocamlc -thread unix.cma threads.cma -o threadtest threadtest.ml
File "threadtest.ml", line 1:
Error: Error on dynamically loaded library: /usr/lib/ocaml/stublibs/dllunix.so: flexdll error: cannot relocate RELOC_REL32, target is too far: 0xfffffffc020c7112  0x20c7112

This is what version of ocamlc I have.

$ ocamlc -v
The OCaml compiler, version 4.02.3
Standard library directory: /usr/lib/ocaml

What am I doing wrong? I've not found any explanation of this error.

UPDATE:

I've also tried rebasing my system by following the instructions here: https://stackoverflow.com/a/37616907/714167

But nothing seems to be working.

Community
  • 1
  • 1
Kyle Sletten
  • 5,365
  • 2
  • 26
  • 39
  • Possible duplicate of [Error linking with Ocaml Thread module on Cygwin](http://stackoverflow.com/questions/37647206/error-linking-with-ocaml-thread-module-on-cygwin) – camlspotter Jun 10 '16 at 02:08
  • You should have improved your previous question with this code example. – camlspotter Jun 10 '16 at 02:09
  • Nobody answered that question, so I rephrased the question with no project-specific information hoping that will encourage people to look at it. I've deleted the previous question. – Kyle Sletten Jun 10 '16 at 02:56

1 Answers1

1

You should compile it with ocamlc -thread unix.cma threads.cma threadtest.ml

[EDIT] As camlspotter said in the comments, it can be a Cygwin32 problem, here's a copy/paste for those, like me, that never read the comments (waiting for OP to know if it works) :

camlspotter : My Cygwin OCaml has no problem of linking of your code. If I were you, I would clean up cygwin (and flexdll if exists) and start over. If you are using Cygwin32, probably migrating to Cygwin64 might fix your problem: I had too many rebase related problems with Cygwin32 and abandoned it.

Lhooq
  • 4,281
  • 1
  • 18
  • 37
  • 1
    Yes, `threads.cma` must be linked but it is another issue. His problem is possibly due to a wrong installation of flexdll, or corruption of cygwin. – camlspotter Jun 10 '16 at 02:11
  • Indeed. I'll wait for his answer, then ;-) – Lhooq Jun 10 '16 at 02:33
  • I think you're right, but it still hasn't fixed the linking issue. – Kyle Sletten Jun 10 '16 at 03:02
  • If it doesn't fix it, can you take a look at this site : http://cygwin.1069669.n5.nabble.com/unison-2-48-build-fails-with-latest-ocaml-and-flexdll-td126546.html ? There is a Mark Geisert answer that doesn't look bad. – Lhooq Jun 10 '16 at 03:28
  • 1
    My Cygwin OCaml has no problem of linking of your code. If I were you, I would clean up cygwin (and flexdll if exists) and start over. If you are using Cygwin32, probably migrating to Cygwin64 might fix your problem: I had too many rebase related problems with Cygwin32 and abandoned it. – camlspotter Jun 10 '16 at 05:53
  • Also i have no issue to compile the code. Reinstalling ocalm and flexdll will be probably enough. Moving to cygwin64 is a bit extreme but surely reduce address collision risks. – matzeri Jun 10 '16 at 12:23
  • I tried this after the rebase, deleted everything but /home and started over. Same issue. I'm using Cygwin64 already. – Kyle Sletten Jun 10 '16 at 14:23