caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] ocamlmklib fails with code compiled with ocamlopt -c
@ 2012-03-21 18:02 Ricardo Catalinas Jiménez
  2012-03-21 18:40 ` Wojciech Meyer
  0 siblings, 1 reply; 2+ messages in thread
From: Ricardo Catalinas Jiménez @ 2012-03-21 18:02 UTC (permalink / raw)
  To: caml-list

I found out the next issue when using the native compiler to generate a
dynamic library from C:

  $ ocamlopt -c foo.c
  $ ocamlmklib -o foo foo.o
  /usr/bin/ld: fsync.o: relocation R_X86_64_32 against `.rodata' can not
  be used when making a shared object; recompile with -fPIC
  fsync.o: could not read symbols: Bad value
  collect2: ld returned 1 exit status

But `man ocamlopt' reads:
  -fPIC Generate position-independent machine code. This is the default.

Anyway, I tried specifying manually `-fPIC' and it gave me the same
error.

But with `ocamlc -c' everything works as expected. Is this normal?


Best regards
-- 
Ricardo (http://r.untroubled.be/)

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] ocamlmklib fails with code compiled with ocamlopt -c
  2012-03-21 18:02 [Caml-list] ocamlmklib fails with code compiled with ocamlopt -c Ricardo Catalinas Jiménez
@ 2012-03-21 18:40 ` Wojciech Meyer
  0 siblings, 0 replies; 2+ messages in thread
From: Wojciech Meyer @ 2012-03-21 18:40 UTC (permalink / raw)
  To: caml-list

Ricardo Catalinas Jiménez <jimenezrick@gmail.com> writes:

> I found out the next issue when using the native compiler to generate a
> dynamic library from C:
>
>   $ ocamlopt -c foo.c
>   $ ocamlmklib -o foo foo.o
>   /usr/bin/ld: fsync.o: relocation R_X86_64_32 against `.rodata' can not
>   be used when making a shared object; recompile with -fPIC
>   fsync.o: could not read symbols: Bad value
>   collect2: ld returned 1 exit status
>
> But `man ocamlopt' reads:
>   -fPIC Generate position-independent machine code. This is the default.
>
> Anyway, I tried specifying manually `-fPIC' and it gave me the same
> error.
>
> But with `ocamlc -c' everything works as expected. Is this normal?

You have to use `-shared' command line option when compiling with ocamlopt.

- Wojciech


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-03-21 18:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-21 18:02 [Caml-list] ocamlmklib fails with code compiled with ocamlopt -c Ricardo Catalinas Jiménez
2012-03-21 18:40 ` Wojciech Meyer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).