I’m trying to write a Ruby extension, and I’ve been successfully compiling my nmatrix.so shared object file all day. But then, suddenly, it starts producing nmatrix.bundle instead, without any .so file at all.
It’s not giving me any linker errors, so I can’t imagine why this would be. I also didn’t change anything in my Makefile or extconf.rb. I’ve been consistently using Ruby 1.9.3p0 through rvm.
I’ve tried doing a git stash save with my work for the day and compiling something I know should work without linker errors (something that produced a .so) earlier. Unfortunately, that too produces a .bundle file.
Clearly I have done something — perhaps installed something inadvertently — which has changed some critical GCC setting. This is totally possible, as I spent most of the day trying to get LAPACK and ATLAS to build, and also installed homebrew at some point.
I have discovered that there is a work-around. I change these two lines:
DLLIB = $(TARGET).bundle
# ...
LDSHARED = $(CC) -dynamic -bundle
to
DLLIB = $(TARGET).so
# ...
LDSHARED = $(CC) -dynamic
And then the library compiles and loads correctly. However, I haven’t the faintest what I changed in extconf.rb (or elsewhere) which would have caused it to auto-generate this Makefile with .bundle files instead of .so.
The question is: how exactly did I cause this, and what do I do to restore it?
It seems as if the problem comes from use of the LLVM gcc, which doesn’t play well with Xcode 4.2.
I have regular gcc installed, so I reinstall Ruby as follows:
Most directions seem to say use
rvm install 1.9.3 --enable-sharedinstead, but that additional flag seems to be the source of the problem.In any case, it seems that I can now load
.bundlefiles.