From: Luis Lavena Date: 2011-04-14T06:55:45+09:00 Subject: Re: Building extensions into static libraries On Apr 13, 12:20 pm, Alex Young wrote: > > That doesn't seem to be doing what I'm after: > >   $ gem unpack mongrel >   Unpacked gem: '/home/zander/projects/scratch/mongrel/mongrel-1.1.5' > >   $ cd mongrel-1.1.5 >   $ ruby ext/http11/extconf.rb --enable-static >   checking for main() in -lc... yes >   creating Makefile > >   $ grep -i static Makefile >   LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a >   LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static >   EXTSTATIC = >   STATIC_LIB = >   static:    $(STATIC_LIB) > > I'm expecting there to be *something* present for STATIC_LIB, which I > want to give me a .a rather than a .so.  To be perfectly clear, I simply > don't know if what I'm trying to do here is actually possible, but > 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. For that to work you will need to create a Makefile (or adapt the one generated by mkmf) to generate a static library. As long one of the symbols is exported, you can generate a static library, take this example: /* mylib.c */ #include extern void foo(); void foo() { printf("foo, exported\n"); } In the command line: $ gcc -c mylib.c -o mylib.o $ ar rcs libmylib.a mylib.o Above generates me a static library of mylib, you can check with nm the symbols contained in there $ gcc -shared mylib.o -o mylib.dll That will generate a dynamic library using the compiled symbols. Does that help? -- Luis Lavena