Ocaml compilation on Window

Hello!I was trying to compile OCaml static website on Windows,by cloning their repo but it was having some issues with Openssl .Can someone please help me with this ?

1 Like

Hello, welcome to the forum!

In order to get help for the issue you are facing as efficiently as possible, it will help if you provide precise descriptions of the issue you are facing and how to reproduce it (and any other relevant context).

Vague descriptions such as “by cloning their repo” or “having some issue with Openssl” are, unfortunately, wholly insufficient for anyone wanting to assist you.

On this subject, Simon Tatham has written an excellent essay entitled How to Report Bugs Effectively. I cannot recommend it enough.

Cheers,
Nicolas

7 Likes

I don’t have a windows computer anymore, but when I did I was using ocaml under cygwin.

It’s true that ocaml is easier to use under Linux, but using it with Cygwin is not that bad, and even can have some advantages. (For example there is no good portability of linux binaries to other distros, and even other versions of the same distro. But if you create a binary from an ocaml program with Cygwin, you can easily run it on any linux distro with wine.)

Are you using Cygwin for the task you’re trying to achieve ?

A google search show me that there is an openssl package on cygwin, and i also got a link to this issue on stackoverflow. Do you get a similar problem ?

Also why are you trying to compile the ocaml static website ? is it to contribute to it ? is it to have a local copy that you can browse offline ? is it you want to learn how to make something equivalent ? or you want to learn how this one is built ?

  • if you want to contribute to it, you can do it even if you’re not able to make the built.
  • if you want a local copy, you can do it with “wget”.
  • if you want to make another static website, there are plenty of static website generators ready and easy to use.
  • if you want to learn how this one is built, then you are lucky, because it will push you to have a look inside to search what is the problem.
1 Like

Dear Nicolas,
Thank you for your response. I am very new to this area, and I sincerely appreciate your guidance and the reference to Simon Tatham’s essay—I will go through it carefully to improve how I report issues.

1 Like

Hello Florent,
Thank you for reaching out! I appreciate your insights on using OCaml with Cygwin.
Basically I am working on compiling ocaml.org on Windows as part of issue Compile ocaml.org on Windows · Issue #2780 · ocaml/ocaml.org · GitHub. My goal is to contribute to this issue.
At the moment, I am facing challenges related to OpenSSL compilation.
After cloning the ocaml.org repo when I tried to install the dependencies then I’m getting an error that cannot build openssl 0.7.0.
I’m using powershell/cmd for writing the instructions.

Please provide insights!

1 Like

Please post the text of the error you are encountering :slight_smile:

1 Like

Hello Shon,
here is the error message
[ERROR] The compilation of ssl.0.7.0 failed at “dune build -p ssl -j 7 @install”.

=== ERROR while compiling ssl.0.7.0 ==========================================#
context 2.3.0 | win32/x86_64 | ocaml-base-compiler.5.0.0 | https://opam.ocaml.org#bc512a2d7545dee0dc96628bd52cddc17739991c
path ~\AppData\Local\opam\5.0.0.opam-switch\build\ssl.0.7.0
command ~\AppData\Local\opam\5.0.0\bin\dune.exe build -p ssl -j 7 @install
exit-code 1
env-file ~\AppData\Local\opam\log\ssl-22800-f56081.env
output-file ~\AppData\Local\opam\log\ssl-22800-f56081.out

output

ssl_stubs.c:1321:3: warning: implicit declaration of function ‘ASN1_TIME_to_tm’; did you mean ‘ASN1_TIME_set’? [-Wimplicit-function-declaration]
[
]
| ^~~~~~~~~~~~~~~
| ASN1_TIME_set
ssl_stubs.c:1321:19: warning: implicit declaration of function ‘X509_get0_notBefore’; did you mean ‘X509_get_notBefore’? [-Wimplicit-function-declaration]
1321 | ASN1_TIME_to_tm(X509_get0_notBefore(cert), &t);
| ^~~~~~~~~~~~~~~~~~~
| X509_get_notBefore
ssl_stubs.c: In function ‘ocaml_ssl_get_expiration_date’:
ssl_stubs.c:1333:19: warning: implicit declaration of function ‘X509_get0_notAfter’; did you mean ‘X509_get_notAfter’? [-Wimplicit-function-declaration]
1333 | ASN1_TIME_to_tm(X509_get0_notAfter(cert), &t);
| ^~~~~~~~~~~~~~~~~~
| X509_get_notAfter

<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
┌─ The following actions failed
│ λ build ssl 0.7.0
└─
╶─ No changes have been performed
To update the current shell environment, run: (& opam env) -split ‘\r?\n’ | ForEach-Object { Invoke-Expression $_ }
PS C:\ocaml.org>

1 Like

Hello Labdhi,
The try you made with the windows installer to install openssl probably provides something not compatible, compiled with a different compiler.
Are you using WSL under powershell ? Did you installed openssl with the package manager provided by this environment, or did you finally got the git version compiled?
It’s good to provide the error message, but it’s also better if you provide the command that produced the error message at the same time.
I’m not a professional, but from this error message : ssl_stubs.c:1321:3: warning: implicit declaration of function ‘ASN1_TIME_to_tm’; did you mean ‘ASN1_TIME_set’ I guess that this is now the opam bindings for openssl that you are trying to compile (not openssl itself), and it seems that some functions are found but not all. I’m not a professional, but my guess would be that the openssl headers (from the openssl lib) don’t seem to match the ocaml bindings to openssl. If this guess is right you could check which version of the openssl lib you installed, and if it’s compatible with its ocaml bindings.
If you’re using opam, conf-libssl has probably been already installed, which means you probably finally got your openssl intalled, but I don’t see if this conf virtual package checks for the version of this lib.


The page ssl.0.7.0 points to savonet/ocaml-ssl, where I can only see a release 0.6.0. I don’t know where is 0.7.0 in order to check what are the compatible versions of the openssl lib.

1 Like

Hi Florent,
I’m not using WSL under powershell.I downloaded the openssl from shining light production and also tried to use the one from git by setting the path in environmental variable.I’ll try using another version of openssl which is compatible with ocaml.

If you’re not using Cygwin, nor WSL, what are you using to get the required environment for the task you’re willing to achieve ? How did you install opam ?
If you want to contribute to this static website, you need some basic knowledge first, and a compatible environment for the project you want to contribute.
Are you using a package manager for C libs ?
Opam is a package manager for ocaml libs. If conf-ssl passed, it means that it probably found something else than the shining light one.
If you compiled the git version of openssl, you probably used gcc. If you use gcc, how did you installed it ? If you installed gcc with a package manager, why don’t you use it to install openssl too ?


Ok, I just found 0.7.0, it was in Tags, not in releases tab. And found this information :

Bump OpenSSL minimum requirement to 1.1.0

conf-openssl doesn’t seem to have anything for your os indepexts.