Project

General

Profile

Actions

Bug #7960

closed

Ruby fails to build static under mswin linker error: multiple definitions of _Init_ext

Added by Ryexander (Benjamin Powers) about 11 years ago. Updated about 11 years ago.

Status:
Closed
Target version:
ruby -v:
1.9.3
Backport:
[ruby-core:52894]

Description

after the depend errors were fixed I obtained r39490 and attempted to build it

after nearly completing it failed with

ruby200.dll : fatal error LNK1169: one or more multiply defined symbols found

searching through the output found only one line with a "already defined"

ruby200-static.lib(dmyext.obj) : error LNK2005: _Init_ext already defined in ext
init.obj

attached is the full output of the configure.bat and nmake commands run with arguments


Files

ruby-2.0.0-r39490_build_output.txt (21.3 KB) ruby-2.0.0-r39490_build_output.txt Ryexander (Benjamin Powers), 02/26/2013 05:51 AM

Updated by ko1 (Koichi Sasada) about 11 years ago

  • Assignee set to usa (Usaku NAKAMURA)
  • Target version changed from 2.0.0 to 2.1.0

Updated by usa (Usaku NAKAMURA) about 11 years ago

  • Status changed from Open to Assigned
  • Assignee changed from usa (Usaku NAKAMURA) to nobu (Nobuyoshi Nakada)

Updated by Ryexander (Benjamin Powers) about 11 years ago

I've been trying to resolve this on my own. is dmyext.c even required when linking exts statically? it semes to be just a prototype for extentions which gets redefined in extinit

Updated by Ryexander (Benjamin Powers) about 11 years ago

infact I think I'm right, it's right here in the 2.0 change log

ext/extmk.rb (command_output): dmyext is needed as DLDOBJS if no static linked extensions.

this would seem to imply that if there were statically linked extensions it is not needed

the error happens as it is linking in the shared dll and considering that dmyext is included in both the static lib and the shared lib inside $(DMYEXT) and $(DLDOBJS) respectively

relevant lines from common.mk 

$(LIBRUBY_A):	$(OBJS) $(MAINOBJ) $(DTRACE_OBJ) $(DTRACE_GLOMMED_OBJ) $(DMYEXT) $(ARCHFILE)

$(LIBRUBY_SO):	$(OBJS) $(DLDOBJS) $(LIBRUBY_A) $(PREP) $(LIBRUBY_SO_UPDATE) $(BUILTIN_ENCOBJS)

i'm pretty sure that the inclusion of dmyext is what is causing the error. It's needed to define the Init_ext function if there are not statically linked extensions but if there are statically linked extensions the function gets defined in the generated extinit.c file.
as the 2 resulting object are defined in 2 seperate .obj files ans linked separately this is causing the error.
I'm guessing GCC can handle this but MSVC can't

not sure how to solve it though. I suspect it needs to be removed as a link somewhere under the condition of there being statically linked extensions.

that or there is a way to define the Init_ext in extinit.c function so that the error doesn't happen.

or I could be utterly wrong. that's a possibility too.

Actions #5

Updated by nobu (Nobuyoshi Nakada) about 11 years ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r39552.
Benjamin, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


Makefile.sub: static-linked-ext

  • win32/Makefile.sub (EXTOBJS, EXTOBJS, config.h): definitions for
    static-linked-ext. [Bug #7960]
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0