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

Build with MSVC-14 (Visual Studio 2015) / Windows 10 not possible #7263

Closed
vicuna opened this issue May 23, 2016 · 7 comments
Closed

Build with MSVC-14 (Visual Studio 2015) / Windows 10 not possible #7263

vicuna opened this issue May 23, 2016 · 7 comments

Comments

@vicuna
Copy link

vicuna commented May 23, 2016

Original bug ID: 7263
Reporter: gerd
Status: resolved (set by @damiendoligez on 2016-09-27T13:50:24Z)
Resolution: fixed
Priority: normal
Severity: block
Version: 4.02.3
Target version: 4.04.0 +dev / +beta1 / +beta2
Fixed in version: 4.04.0 +dev / +beta1 / +beta2
Category: platform support (windows, cross-compilation, etc)
Tags: patch
Monitored by: @gasche @hcarty

Bug description

The suggested Win 7 SDK (in README.win32) does not install under Win 10. Because of that I tried it with something newer, namely MSVC 14 Express For Desktop with Win 10 SDK.

However, this leads to a problem:

$ make -f Makefile.nt world
cd byterun ; make -f Makefile.nt all
make[1]: Entering directory '/home/gerd/tmp/ocaml-4.02.3/byterun'
flexlink -merge-manifest -stack 16777216 -exe -o ocamlrun.exe prims.obj ws2_32.lib
libcamlrun.lib
** Cannot resolve symbols for descriptor object:
___iob_func
_sprintf

Steps to reproduce

Find attached my script for setting the environment variables.

Additional information

This could be an incompatibility of the libraries distributed with flexlink, because I find there the symbols __imp__sprintf and __imp____iob_func. See also this Stack Overflow article: http://stackoverflow.com/questions/30412951/unresolved-external-symbol-imp-fprintf-and-imp-iob-func-sdl2

File attachments

@vicuna
Copy link
Author

vicuna commented May 23, 2016

Comment author: gerd

In deed, when I rebuild flexdll_msvc.obj and flexdll_initer_msvc.obj, the error vanishes:

cl /nologo /MD -D_CRT_SECURE_NO_DEPRECATE /GS- /DMSVC -c /Fo"flexdll_msvc.obj" flexdll.c
cl /nologo /MD -D_CRT_SECURE_NO_DEPRECATE /GS- /DMSVC -c /Fo"flexdll_initer_msvc.obj" flexdll_initer.c

@vicuna
Copy link
Author

vicuna commented May 23, 2016

Comment author: gerd

msvcrt.lib is no longer sufficient. You also need to link in ucrt.lib and vcruntime.lib (https://msdn.microsoft.com/en-us/library/abx4dbyh.aspx)

I changed MKEXE in config/Makefile as follows:
MKEXE=$(FLEXLINK) -exe ucrt.lib vcruntime.lib

@vicuna
Copy link
Author

vicuna commented May 23, 2016

Comment author: gerd

Also, there is now snprintf, and you get an error if you try to #define it:

cl -nologo -D_CRT_SECURE_NO_DEPRECATE -Feobjinfo_helper.exe -Ox -MD
objinfo_helper.c
objinfo_helper.c
C:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\ucrt\stdio.h(1925): warning C4005: "snprintf": Makro-Neudefinition
c:\cygwin\home\gerd\tmp\ocaml-4.02.3\byterun\caml\misc.h(163): note: Siehe vorherige Definition von "snprintf"
C:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\ucrt\stdio.h(1927): fatal error C1189: #error: Macro definition of snprintf conflicts with Standard Library function declaration

Solution: commented "#define snprintf caml_snprintf" out in byterun/caml/misc.h

@vicuna
Copy link
Author

vicuna commented May 23, 2016

Comment author: gerd

With these fixes I could complete the build.

@vicuna
Copy link
Author

vicuna commented Jul 1, 2016

Comment author: @dra27

This is a bug (of sorts) in the binary distro of FlexDLL - there's a move (prompted by VS2015 support) towards the "binary" distribution of FlexDLL being flexlink.exe and the .c files.
README.win32.adoc in 4.03.0 includes more comprehensive instructions.

@vicuna
Copy link
Author

vicuna commented Sep 27, 2016

Comment author: @damiendoligez

In 4.04, I've added a note to README.win32.adoc to say that you must recompile FlexDLL from source if you're using VS2015. The snprintf thing was fixed by @dra in commit 12a9af9.

This seems to be enough to fix it all, although the FlexDLL makefile still gives some error messages when trying to get the OCaml version number.

@vicuna vicuna closed this as completed Sep 27, 2016
@vicuna
Copy link
Author

vicuna commented Sep 27, 2016

Comment author: @dra27

The problem with the FlexDLL Makefile should be harmless as long as you're building OCaml 4.03.0 or later. It's also fixed in master (and so 0.36)

@vicuna vicuna added this to the 4.04.0 milestone Mar 14, 2019
@vicuna vicuna added the bug label Mar 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant