Author Topic: ocamlopt vs. C compiler  (Read 876 times)

FredSRichardson

  • Guest
ocamlopt vs. C compiler
« on: June 02, 2003, 10:33:27 AM »
I noticed that ocamlopt is used to compile C code in the WeiDU makefile as well.  Is there any difference between using ocamlopt instead of the C compiler in terms of the object code it produces?  Does ocamlopt just run the native C compiler (with some flags)?

I'm just curious.  I looked through the ocaml docs briefly but I didn't see an answer there.

Offline weimer

  • Moderator
  • Planewalker
  • *****
  • Posts: 2222
  • Gender: Male
    • WeiDU and Weimer Mods
ocamlopt vs. C compiler
« Reply #1 on: June 02, 2003, 11:26:19 AM »
When you configure and compile ocaml itself for your system, you have to specify whether you are going to use MSVC or GCC. It uses this information to know what sort of object files and libraries to expect when linking in C code with OCaml (cf. JNI). For example, ocaml atop MSVC will pass things like "/lib wsock32.lib" or whatnot.

There isn't really any difference and you could call the underlying C compiler yourself. You can pass -verbose to ocamlc to see what it is doing under the hood. For example, when you use ocamlopt to build zlib.c in WeiDU it's really doing:

Code: [Select]
+ cl /nologo /Ox /MT -c  "-Iobj/x86_WIN32" "-Izlib" -I"C:\ocaml-3.06-msvc\lib" "zlib/zlib.c"

 

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Name: Email:
Verification:
Type the letters shown in the picture
Listen to the letters / Request another image
Type the letters shown in the picture:
What color is grass?:
What is the seventh word in this sentence?:
What is five minus two (use the full word)?: