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

Multiple symbol definitions while bulding OCaml on Windows #3768

Closed
vicuna opened this issue Aug 20, 2005 · 1 comment
Closed

Multiple symbol definitions while bulding OCaml on Windows #3768

vicuna opened this issue Aug 20, 2005 · 1 comment
Assignees
Labels

Comments

@vicuna
Copy link

vicuna commented Aug 20, 2005

Original bug ID: 3768
Reporter: administrator
Assigned to: @xavierleroy
Status: closed (set by @xavierleroy on 2015-12-11T18:04:23Z)
Resolution: not a bug
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)

Bug description

Full_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
@vicuna
Copy link
Author

vicuna commented Mar 26, 2012

Comment author: @xavierleroy

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.

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