Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0003768OCamlOCaml generalpublic2005-08-20 12:502012-03-26 11:04
Reporteradministrator 
Assigned Toxleroy 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionno change required 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0003768: Multiple symbol definitions while bulding OCaml on Windows
DescriptionFull_Name: Dmitry Bely
Version: 3.08.4
OS: Windows XP (mingw toolchain)
Submission from: dsl-084-058-035-093.arcor-ip.net (84.58.35.93)


Trying to reduce the size of OCaml executables I used the following gcc
compiler/linkers options combination:

BYTECCCOMPOPTS=-O2 -mms-bitfields -Wall -Wno-unused -ffunction-sections
-fdata-sections
### Additional link-time options for $(BYTECC). (For static linking.)
BYTECCLINKOPTS=-Wl,--gc-sections

(same for the native code)

Everything went fine but some problems (IMHO bugs in OCaml sources) have
appeared:

gcc -mno-cygwin -shared -o dlllabltk.dll -Wl,--out-implib,dlllabltk.a
cltkCaml.d.o
cltkUtf.d.o cltkEval.d.o cltkEvent.d.o cltkFile.d.o cltkMain.d.o cltkMisc.d.o
cltkTimer.d.o cltkVar.d.o cltkWait.d.o cltkImg.d.o ../../../byterun/ocamlrun.a
c:/tcl/lib/tk84.lib c:/tcl/lib/tcl84.lib -lwsock32

cltkUtf.d.o(.data$cltclinterp+0x0):cltkUtf.c: multiple definition of
`_cltclinterp'
cltkCaml.d.o(.data$cltclinterp+0x0):cltkCaml.c: first defined here
cltkEval.d.o(.data$cltclinterp+0x0):cltkEval.c: multiple definition of
`_cltclinterp'
cltkCaml.d.o(.data$cltclinterp+0x0):cltkCaml.c: first defined here
cltkEvent.d.o(.data$cltclinterp+0x0):cltkEvent.c: multiple definition of
`_cltclinterp'
cltkCaml.d.o(.data$cltclinterp+0x0):cltkCaml.c: first defined here
cltkFile.d.o(.data$cltclinterp+0x0):cltkFile.c: multiple definition of
`_cltclinterp'
cltkCaml.d.o(.data$cltclinterp+0x0):cltkCaml.c: first defined here
cltkMain.d.o(.data$cltclinterp+0x0):cltkMain.c: multiple definition of
`_cltclinterp'
cltkCaml.d.o(.data$cltclinterp+0x0):cltkCaml.c: first defined here
cltkMisc.d.o(.data$cltclinterp+0x0):cltkMisc.c: multiple definition of
`_cltclinterp'
cltkCaml.d.o(.data$cltclinterp+0x0):cltkCaml.c: first defined here
cltkTimer.d.o(.data$cltclinterp+0x0):cltkTimer.c: multiple definition of
`_cltclinterp'
cltkCaml.d.o(.data$cltclinterp+0x0):cltkCaml.c: first defined here
cltkVar.d.o(.data$cltclinterp+0x0):cltkVar.c: multiple definition of
`_cltclinterp'
cltkCaml.d.o(.data$cltclinterp+0x0):cltkCaml.c: first defined here
cltkWait.d.o(.data$cltclinterp+0x0):cltkWait.c: multiple definition of
`_cltclinterp'
cltkCaml.d.o(.data$cltclinterp+0x0):cltkCaml.c: first defined here
cltkImg.d.o(.data$cltclinterp+0x0):cltkImg.c: multiple definition of
`_cltclinterp'
cltkCaml.d.o(.data$cltclinterp+0x0):cltkCaml.c: first defined here
Creating library file: dlllabltk.a
collect2: ld returned 1 exit status
make[2]: *** [dlllabltk.dll] Error 1
make[1]: *** [all] Error 2
make: *** [otherlibraries] Error 2

This is because

CAMLTKextern Tcl_Interp *cltclinterp; /* The Tcl interpretor */

in camltk.h is preprocessed as

__declspec(dllexport) Tcl_Interp *cltclinterp; /* The Tcl interpretor */

This is _definition_, not _declaration_, so any inclusion of camltk.h generates
another definition of cltclinterp (strange how it worked before and why ld did
not complain when standard set of options was used).

There are also other "multiple definition" problems in OCaml libraries
(specifically win32graph and win32caml). Here is the patch that hopefully fixes
them all. Btw, errors while building win32graph don't stop the make process!

--- camltk.h.orig 2003-07-10 13:18:02.000000000 +0400
+++ camltk.h 2005-08-20 14:00:36.140625000 +0400
@@ -17,7 +17,7 @@
 /* $Id: camltk.h,v 1.11 2003/07/10 09:18:02 xleroy Exp $ */
 
 #if defined(_WIN32) && defined(CAML_DLL) && defined(IN_CAMLTKSUPPORT)
-#define CAMLTKextern CAMLexport
+#define CAMLTKextern CAMLextern CAMLexport
 #else
 #define CAMLTKextern CAMLextern
 #endif
--- draw.c.orig 2005-02-03 19:40:12.000000000 +0300
+++ draw.c 2005-08-20 14:28:49.046875000 +0400
@@ -21,8 +21,6 @@
 #include "memory.h"
 
 HDC gcMetaFile;
-int grdisplay_mode;
-int grremember_mode;
 GR_WINDOW grwindow;
 
 static void GetCurrentPosition(HDC hDC,POINT *pt)
--- open.c.orig 2005-05-26 13:15:22.000000000 +0400
+++ open.c 2005-08-20 14:34:56.000000000 +0400
@@ -303,7 +303,10 @@
 
 CAMLprim value caml_gr_resize_window (value vx, value vy)
 {
+#if 0
+ /* is it gr_check_open()? */
   caml_gr_check_open ();
+#endif
 
   /* FIXME TODO implement this function... */
 
--- startocaml.c.orig 2005-02-02 18:41:30.000000000 +0300
+++ startocaml.c 2005-08-20 14:09:35.531250000 +0400
@@ -23,7 +23,7 @@
 #include <direct.h>
 #include "inria.h"
 
-PROCESS_INFORMATION pi;
+extern PROCESS_INFORMATION pi;
 #define BUFSIZE 4096
 STARTUPINFO startInfo;

- Dmitry Bely














TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0007158)
xleroy (administrator)
2012-03-26 11:04

I've been sleeping on this PR for far too long. I suspect the problem went away, perhaps since the introduction of FlexDLL which is a lot more lenient about DLL imports and exports. I'm tentatively marking this PR as resolved.

- Issue History
Date Modified Username Field Change
2005-11-18 10:14 administrator New Issue
2005-12-15 14:43 doligez Status acknowledged => assigned
2005-12-15 14:43 doligez Assigned To => xleroy
2012-03-26 11:04 xleroy Note Added: 0007158
2012-03-26 11:04 xleroy Status assigned => resolved
2012-03-26 11:04 xleroy Resolution open => no change required
2012-03-26 11:04 xleroy Description Updated View Revisions


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker