From: Alex Young Date: 2011-04-14T14:38:13+09:00 Subject: Re: Building extensions into static libraries Luis Lavena wrote in post #992613: > On Apr 13, 12:20pm, Alex Young wrote: >> >> neither do I know where else to look. >> > > That that is why I asked what you're targeting/aiming at. > > If you want to generate an static library of your extension, then you > can't rely on mkmf. > > mkmf is aimed to generated shared libraries to be loaded by Ruby. > Ok, some more details: I'm trying to embed a ruby interpreter into a static-linked binary, along with some additional binary extensions from rubygems. This works for the extensions in stdlib, whose Makefiles get a STATIC_LIB entry of $(TARGET).a thanks to mkmf.rb. I don't see how, though. The top-level Makefile following a ./configure in the ruby source tree contains this: EXTCONF = extconf.rb ... extconf: $(MINIRUBY) -run -e mkdir -- -p "$(EXTCONFDIR)" $(RUNRUBY) -C "$(EXTCONFDIR)" $(EXTCONF) $(EXTCONFARGS) I can't see where EXTCONFARGS is set, or I'd just copy that. I don't see any obvious settings in the existing extconf.rb files either. > For that to work you will need to create a Makefile (or adapt the one > generated by mkmf) to generate a static library. Going by the stdlib extensions, I don't think that's the case, but you'd know better than me. > $ gcc -c mylib.c -o mylib.o > > $ ar rcs libmylib.a mylib.o I might be able to get away with sidestepping the extensions' Makefiles and just do a $ find ext/ -name "*.o" | xargs ar rcs libwhatsit.a but I imagine that would break horribly for reasons I haven't thought of. -- Alex -- Posted via http://www.ruby-forum.com/.