Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot build OCaml 3.12.1 Win32/MSVC #5383

Closed
vicuna opened this issue Oct 24, 2011 · 5 comments
Closed

Cannot build OCaml 3.12.1 Win32/MSVC #5383

vicuna opened this issue Oct 24, 2011 · 5 comments
Labels

Comments

@vicuna
Copy link

vicuna commented Oct 24, 2011

Original bug ID: 5383
Reporter: avlasov
Assigned to: @protz
Status: closed (set by @xavierleroy on 2013-08-31T10:46:18Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 3.12.1
Fixed in version: 3.13.0+dev
Category: ~DO NOT USE (was: OCaml general)
Monitored by: @protz

Bug description

The OCamk 3.12.1 Win32/MSVC build is failed, using Microsoft VS 2005 (I was following instructions from README.win32).
When building 'make -f Makefile.nt world', the following error happens:

../../../ocamlcomp.sh -o ocamlbrowser.exe -I ../../../otherlibs/win32unix -I ../
../../otherlibs/str -I ../../../otherlibs/systhreads -I ../labltk -I ../lib -I .
./support -I ../../../parsing -I ../../../utils -I ../../../typing
../../../toplevel/toplevellib.cma
unix.cma str.cma threads.cma -custom -ccopt "-link /subsystem:wi
ndows" labltk.cma jglib.cma
list2.cmo useunix.cmo setpath.cmo lexical.cmo file
select.cmo searchid.cmo searchpos.cmo shell.cmo help.cmo viewer.cmotyp
echeck.cmo editor.cmo main.cmo winmain.obj
camlprim8e0eac.c
** Cannot resolve symbols for ../../../otherlibs/systhreads\libthreads.lib(st_st
ubs_b.obj):
_TryEnterCriticalSection

The problem actually can be easily fixed by inserting '#define _WIN32_WINNT 0x0400' before '#include <windows.h>' in the file otherlibs\systhreads\st_win32.h.

For some reason st_stubs.obj has been compiled earlier, while TryEnterCriticalSection normally require _WIN32_WINNT >= 0x0400 to be defined.

@vicuna
Copy link
Author

vicuna commented Dec 21, 2011

Comment author: @protz

Hi,

Thanks for reporting this. Can you provide any explanation as to why this is failing now?

  • Is it a Makefile issue (wrong compilation order)?
  • Is it something else?

I'm not familiar with MSVC but it seems weird that we should be defining something private (starting with _).

Thanks,

jonathan

@vicuna
Copy link
Author

vicuna commented Dec 21, 2011

Comment author: avlasov

Defining _WIN32_WINNT is a standard Microsoft way to specify the minimum system required.
In this case, for TryEnterCritcalSection the minimum version required is Windows 2000, so one should define _WIN32_WINNT as 0x0400 or later.
See http://msdn.microsoft.com/en-us/library/windows/desktop/ms686857%28v=vs.85%29.aspx for details.

Actually, another file in OCaml 3.12.1 source code otherlibs\win32unix\winworker.h already defines _WIN32_WINNT as 0x0400.

If the appropriate _WIN32_WINNT version is not defined, then compiling files referencing TryEnterCriticalSection should normally fail, since it is not in the original WIN32, but was added later.

@vicuna
Copy link
Author

vicuna commented Dec 21, 2011

Comment author: @protz

That's a good justification, thanks :-). Could you possibly submit a patch against latest HEAD, using diff --git?

Cheers,

jonathan

@vicuna
Copy link
Author

vicuna commented Jan 19, 2012

Comment author: @xavierleroy

To be fixed as suggested by the reporter. Thanks.

@vicuna
Copy link
Author

vicuna commented Jan 30, 2012

Comment author: @protz

Fixed in r12100 (trunk) and r12101 (version/3.12).

@vicuna vicuna closed this as completed Aug 31, 2013
@vicuna vicuna added the bug label Mar 20, 2019
dra27 pushed a commit to dra27/ocaml that referenced this issue Feb 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant