# How do I get rake to compile native extension during gem ins

**URL:** <https://www.ruby-forum.com/t/how-do-i-get-rake-to-compile-native-extension-during-gem-ins/77952>\
**Category:** Ruby\
**Created:** [December 1, 2006, 9:55pm UTC](https://www.ruby-forum.com/t/how-do-i-get-rake-to-compile-native-extension-during-gem-ins/77952 "2006-12-01T21:55:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jyzhang](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/838e76/32.png) [@jyzhang](https://www.ruby-forum.com/u/jyzhang)\
**Post date:** [December 1, 2006, 9:55pm UTC](https://www.ruby-forum.com/t/how-do-i-get-rake-to-compile-native-extension-during-gem-ins/77952/1 "2006-12-01T21:55:42Z")

</div>

Hi, I have a little problem and I don’t know how to solve.

I created a little native extension that I want to package as a gem.  
The problem is that because of the nature of the extension, I created a  
custom Rakefile to compile it, instead of using mkmf (extconf.rb) like  
the example in the pickaxe book. The rake script will fail to compile  
if a special tool isn’t available on the system (which is the desired  
outcome).

Now, the problem is that I want to package the whole thing as a gem,  
and during gem install, I want this Rakefile to run and build on the  
target system.

My files look something like this:

/directory-of-gem  
/ext  
source\_files.c  
other\_files  
Rakefile

Now, I couldn’t figure out how to package the gem so that I get to run  
the Rakefile inside the /ext directory. Is this even possible to do?

Thanks,

J.Y.Z.
