Bug #6462


Broken build under MinGW due undefined references

Added by luislavena (Luis Lavena) about 10 years ago. Updated about 10 years ago.

Target version:
ruby -v:
ruby 1.9.3p194


Attempt to compile latest trunk (r35721) result in the following errors:

linking shared-library msvcrt-ruby200.dll
Creating library file: libmsvcrt-ruby200.dll.a
dln.o: In function `rb_w32_check_imported':
C:\Users\Worker\Code\ruby\ruby\build32/../dln.c:1212: undefined reference to `_imp__ImageDirectoryEntryToData@16'
vm_dump.o: In function `dump_thread':
C:\Users\Worker\Code\ruby\ruby\build32/../vm_dump.c:696: undefined reference to `_imp__SymSetOptions@4'
win32/win32.o: In function `StartSockets':
C:\Users\Worker\Code\ruby\ruby\build32/../win32/win32.c:670: undefined reference to `_imp__WSAStartup@8'

Full output:

Build was done with GCC 4.6.3 (mingw-w64) under Windows 7 x64. Base Ruby was 1.9.3-p194

The top output from make was:

CC = gcc
LD = ld
LDSHARED = gcc -shared -s
CFLAGS = -O3 -fno-omit-frame-pointer -fno-fast-math -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Werror=pointer-arith -Werror=write-strings -Werror=declaration-after-statement -Werror=implicit-function-declaration
XCFLAGS = -include ruby/config.h -include ruby/missing.h -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fvisibility=hidden -DRUBY_EXPORT
CPPFLAGS = -DFD_SETSIZE=32767 -D_WIN32_WINNT=0x0501   -I. -I.ext/include/i386-mingw32 -I../include -I..
DLDFLAGS = -Wl,--enable-auto-image-base,--enable-auto-import -Wl,--out-implib=libmsvcrt-ruby200.dll.a msvcrt-ruby200.def -Wl,--stack,0x00200000,--enable-auto-import
SOLIBS = msvcrt-ruby200.res.o -lshell32 -lws2_32 -limagehlp

I'm running git-bisect right now, but things were fine at r35648

I believe this is caused by static-link-ext, so I'm assigning to Nobu

Updated by luislavena (Luis Lavena) about 10 years ago

After git bisect was done, I can confirm that r35709 (SHA1 0e60b2c6a3c5152fc4ff06054a4ae79edadf9276) introduced the breakage:

commit 0e60b2c6a3c5152fc4ff06054a4ae79edadf9276
Author: nobu
Date: Sat May 19 02:37:21 2012 +0000

static-linked-ext: into libruby

  •, (PROGRAM): no extension libraries.
  • (build-ext): pass macros for
  • ext/extmk.rb (command_output): link extension libraries and encoding
    libraries into, not ruby executable.


Updated by luislavena (Luis Lavena) about 10 years ago


The issue seems to be caused by the override of SOLIBS when --enable-shared is used to build Ruby:

By doing that, system libraries defined by LIBS (which later are used as SOLIBS) like ws2_32, shell32 and others are gone.


Actions #3

Updated by nobu (Nobuyoshi Nakada) about 10 years ago

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

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

Bug #6462: EXTSOLIBS

  • (LIBRUBY_SO): link EXTSOLIBS too.
  • ext/extmk.rb (mf.macro): use EXTSOLIBS instead of SOLIBS to get rid
    of discard libraries needed by default. [Bug #6462]

Also available in: Atom PDF