# Forcing mkmf to use static libraries instead of dynamic ones

**URL:** <https://www.ruby-forum.com/t/forcing-mkmf-to-use-static-libraries-instead-of-dynamic-ones/106388>\
**Category:** Ruby\
**Created:** [June 9, 2007, 4:21pm UTC](https://www.ruby-forum.com/t/forcing-mkmf-to-use-static-libraries-instead-of-dynamic-ones/106388 "2007-06-09T16:21:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wincent\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@Wincent\_C](https://www.ruby-forum.com/u/Wincent_C)\
**Post date:** [June 9, 2007, 4:21pm UTC](https://www.ruby-forum.com/t/forcing-mkmf-to-use-static-libraries-instead-of-dynamic-ones/106388/1 "2007-06-09T16:21:05Z")

</div>

I’m building a C extension on Mac OS X and I notice that the Makefile  
created by mkmf prefers dynamic libraries over static ones.

For example, given this line in my extconf.rb file:

have\_library(‘antlr3c’, ‘antlr3ParserNew’)

And these installed libraries:

libantlr3c.a  
libantlr3c.dylib  
libantlr3c.la

The Makefile always choose s the “dylib” version… I can force it to  
choose the static version and link statically to it by deleting or  
moving the other libraries, but I’d like to know: is there a way to  
explicitly specify my preference for the static version of the library  
in my extconf.rb file?

Cheers,  
Wincent

---

<div class="post-metadata">

**Author:** ![Wincent\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@Wincent\_C](https://www.ruby-forum.com/u/Wincent_C)\
**Post date:** [June 11, 2007, 6:37am UTC](https://www.ruby-forum.com/t/forcing-mkmf-to-use-static-libraries-instead-of-dynamic-ones/106388/2 "2007-06-11T06:37:50Z")

</div>

Hi,

At Sat, 9 Jun 2007 23:20:13 +0900,  
Wincent C. wrote in [ruby-talk:254934]:

> The Makefile always choose s the “dylib” version… I can force it to  
> choose the static version and link statically to it by deleting or  
> moving the other libraries, but I’d like to know: is there a way to  
> explicitly specify my preference for the static version of the library  
> in my extconf.rb file?

How can you tell your compiler and/or linker to use the static  
version, even if the dylib version is also available?
