Ruby fails to build static under mswin linker error: multiple definitions of _Init_ext
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
attached is the full output of the configure.bat and nmake commands run with arguments
#4 [ruby-core:53100] Updated by Ryexander (Benjamin Powers) over 4 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.
#5 Updated by nobu (Nobuyoshi Nakada) over 4 years ago
- Status changed from Assigned to Closed
- % Done changed from 0 to 100