Skip to content

Instantly share code, notes, and snippets.

@ravicious
Created March 30, 2020 11:37
Show Gist options
  • Save ravicious/39903bf91b2e344ce7120bace8c60ec3 to your computer and use it in GitHub Desktop.
Save ravicious/39903bf91b2e344ce7120bace8c60ec3 to your computer and use it in GitHub Desktop.
Fixing problem with libruby-static.a when installing older Ruby versions on macOS

For a long time I had this problem where installing a Ruby through ruby-build or ruby-install would fail with an error saying "Undefined symbols for architecture x86_64".

linking static-library libruby-static.a
ar: `u' modifier ignored since `D' is the default (see `U')
verifying static-library libruby-static.a
ld: warning: ignoring file libruby-static.a, building for macOS-x86_64 but attempting to link with file built for macOS-x86_64
Undefined symbols for architecture x86_64:
  "_ruby_init", referenced from:
      _main in main.o
  "_ruby_init_stack", referenced from:
      _main in main.o
  "_ruby_options", referenced from:
      _main in main.o
  "_ruby_run_node", referenced from:
      _main in main.o
  "_ruby_sysinit", referenced from:
      _main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [libruby-static.a] Error 1

Today I finally found something on StackOverflow and someone suggested doing brew unlink binutils.

I don't remember why I linked binutils in the first place, but I just installed Ruby 2.1.7 without any problems!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment