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

Native code build failure on Windows/MSVC 7.1 #3821

Closed
vicuna opened this issue Oct 24, 2005 · 2 comments
Closed

Native code build failure on Windows/MSVC 7.1 #3821

vicuna opened this issue Oct 24, 2005 · 2 comments
Assignees
Labels

Comments

@vicuna
Copy link

vicuna commented Oct 24, 2005

Original bug ID: 3821
Reporter: administrator
Assigned to: @xavierleroy
Status: closed (set by @xavierleroy on 2007-11-01T16:51:50Z)
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)

Bug description

Full_Name: Dmitry Bely
Version: 3.08.4
OS: Windows XP
Submission from: munitions2.xs4all.nl (194.109.217.74)

E.g.:

C:\Work\Ocaml\ocaml-3.08.4>make -f Makefile.nt opt.opt
...
make[1]: Leaving directory `/cygdrive/c/Work/Ocaml/ocaml-3.08.4/asmrun'
boot/ocamlrun ./ocamlopt -I stdlib -o ocamlc.opt utils/misc.cmx utils/tbl.cmx
utils/config.cmx utils/clflags.cmx utils/terminfo.cmx utils/ccomp.cmx
utils/warnings.cmx utils/consistbl.cmx parsing/linenum.cmx parsing/location.cmx
parsing/longident.cmx parsing/syntaxerr.cmx parsing/parser.cmx parsing/
lexer.cmx parsing/parse.cmx parsing/printast.cmx typing/ident.cmx
typing/path.cmx typing/primitive.cmx typing/types.cmx typing/btype.cmx
typing/oprint.cmx typing/subst.cmx typing/predef.cmx typing/datarepr.cmx
typing/env.cmx typing/typedtree.cmx typing/ctype.cmx typing/printtyp.cmx
typing/includeclass.cmx typing/mtype.cmx typing/includecore.cmx
typing/includemod.cmx typing/parmatch.cmx typing/typetexp.cmx typing/stypes.cmx
typing/typecore.cmx typing/typedecl.cmx typing/typeclass.cmx typing/typemod.cmx
bytecomp/lambda.cmx bytecomp/printlambda.cmx bytecomp/typeopt.cmx
bytecomp/switch.cmx bytecomp/matching.cmx bytecomp/translobj.cmx
bytecomp/translcore.cmx bytecomp/translclass.cmx bytecomp/translmod.cmx
bytecomp/simplif.cmx bytecomp/runtimedef.cmx bytecomp/meta.cmx
bytecomp/instruct.cmx bytecomp/bytegen.cmx bytecomp/printinstr.cmx
bytecomp/opcodes.cmx bytecomp/emitcode.cmx bytecomp/bytesections.cmx
bytecomp/dll.cmx bytecomp/symtable.cmx bytecomp/bytelink.cmx
bytecomp/bytelibrarian.cmx bytecomp/bytepackager.cmx driver/pparse.cmx
driver/errors.cmx driver/compile.cmx driver/main_args.cmx driver/main.cmx
asmrun/meta.obj asmrun/dynlink.obj
LINK : fatal error LNK1561: entry point must be defined
Error during linking
make: *** [ocamlc.opt] Error 2

Looks like MSVC 7.1 is more strict than MSVC 6.0 and requres /subsystem:console
linker option where it previously didn't. Worse, it looks like it cannot be
specified via #pragma comment(linker , "/subsystem:console") as before; compare

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/html/_predir_comment.asp
(MSVC 6.0)
with
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclang/html/_PREDIR_comment.asp
(MSVC 7.1 a.k.a. MS Visual Studio .Net 2003)

At least, adding #pragma comment(linker , "/subsystem:console") to
byterun/main.c did not help. Adding "-ccopt /link -ccopt /subsystem:console" to
each ocamlopt invocation solves the problem but is very boring. I hope you know
the better solution.

  • Dmitry Bely

P.S. You don't need to bought the whole MS Visual Studio .Net to reproduce the
problem; all this should apply to the Microsoft Visual C++ Toolkit 2003 that is
freely available from http://msdn.microsoft.com/visualc/vctoolkit2003/ (just the
same compiler but without IDE)

@vicuna
Copy link
Author

vicuna commented Nov 2, 2005

Comment author: administrator

Looks like the problem only appears when Ocaml is compiled against DLL C
runtime library (i.e. with /MD instead of /MT everythere in
config/Makefile). In the former case Microsoft linker probably assumes
"/subsystem:console" option by default. I don't know if you consider
impossibility to use /MD as a bug, but currently I fixed this the following
way:

Index: asmlink.ml

--- asmlink.ml (revision 14)
+++ asmlink.ml (working copy)
@@ -255,17 +255,26 @@
(Ccomp.quote_files (List.rev file_list))
| "msvc" ->
if not !Clflags.output_c_object then

  •      Printf.sprintf "%s /Fe%s %s %s %s %s %s %s %s"
    
  •        !Clflags.c_linker
    
  •        (Filename.quote output_name)
    
  •        (Clflags.std_include_flag "-I")
    
  •        (Filename.quote startup_file)
    
  •        (Ccomp.quote_files (List.rev file_list))
    
  •        (Ccomp.quote_files 
    
  •          (List.rev_map Ccomp.expand_libname !Clflags.ccobjs))
    
  •        (Filename.quote runtime_lib)
    
  •        c_lib
    
  •        (String.concat " " (List.rev !Clflags.ccopts))
    
  •      let subsys_opt =
    
  •        try
    
  •          ignore (List.find 
    
  •                    (fun s -> let ls = String.lowercase s in
    
  •                       ls = "/link" || ls = "-link") !Clflags.ccopts);
    
  •          "/subsystem:console"
    
  •        with Not_found -> 
    
  •          "/link /subsystem:console" in
    
  •        Printf.sprintf "%s /Fe%s %s %s %s %s %s %s %s %s"
    
  •          !Clflags.c_linker
    
  •          (Filename.quote output_name)
    
  •          (Clflags.std_include_flag "-I")
    
  •          (Filename.quote startup_file)
    
  •          (Ccomp.quote_files (List.rev file_list))
    
  •          (Ccomp.quote_files 
    
  •             (List.rev_map Ccomp.expand_libname !Clflags.ccobjs))
    
  •          (Filename.quote runtime_lib)
    
  •          c_lib
    
  •          (String.concat " " (List.rev !Clflags.ccopts))
    
  •          subsys_opt
       else
         Printf.sprintf "%s /out:%s %s %s"
           Config.native_partial_linker
    
  • Dmitry Bely

@vicuna
Copy link
Author

vicuna commented Nov 1, 2007

Comment author: @xavierleroy

Since OCaml 3.10, /link /sybsystem:console is added by default to MSVC command-line. This should address this issue.

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

2 participants