Install Therubyracer Failure

Published: 03 Jul 2016 Category: web_dev

I try to install therubyracer via gem on Windows 10, but keep getting an error associated with -rdynamic flag, which results in failure to build the native extensions:

You can find -rdynamic flag in extconf.rb and Makefile:


$CPPFLAGS += " -rdynamic" unless $CPPFLAGS.split.include? "-rdynamic"
$CPPFLAGS += " -fPIC" unless $CPPFLAGS.split.include? "-rdynamic" or RUBY_PLATFORM =~ /darwin/


CPPFLAGS =  -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT $(DEFS) $(cppflags) -Wall -g -rdynamic

Somebody figures it out by changing gcc compiler to version 4.2 (mine is 4.9.3). For some reason the newer gcc version don’t just ignore the -rdynamic flag, which is only present for compiling on Linux and is not actually compatible with Windows and OS X.

More detailed explanation is that: -rdynamic passes the flag -export-dynamic to ELF linker, on targets that support it

Executable formats in OS X and Windows are not ELF, thus the option -rdynamic is not supported building for these operating systems.

One solution is using an older gcc compiler, like gcc-4.2.