# Extconf.rb \>\> mkmf

**URL:** <https://www.ruby-forum.com/t/extconf-rb-mkmf/119980>\
**Category:** Ruby\
**Created:** [November 12, 2007, 5:16pm UTC](https://www.ruby-forum.com/t/extconf-rb-mkmf/119980 "2007-11-12T17:16:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![flnative](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/5daacb/32.png) [@flnative](https://www.ruby-forum.com/u/flnative)\
**Post date:** [November 12, 2007, 5:16pm UTC](https://www.ruby-forum.com/t/extconf-rb-mkmf/119980/1 "2007-11-12T17:16:01Z")

</div>

hi @all

I would like to extend my rubyapp with a c++ program. I used the  
features of mkmf (require ‘mkmf’) and saved it into the extconf.rb. So  
already the whole program is running, but I want to compile the c-file  
with g++ instead of gcc compiler.

How can I change this options?  
Thanks for your posting!

---

<div class="post-metadata">

**Author:** ![flnative](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/5daacb/32.png) [@flnative](https://www.ruby-forum.com/u/flnative)\
**Post date:** [November 13, 2007, 7:06pm UTC](https://www.ruby-forum.com/t/extconf-rb-mkmf/119980/2 "2007-11-13T19:06:54Z")

</div>

On Nov 12, 2007, at 8:15 AM, K. R. wrote:

> hi @all
> 
> I would like to extend my rubyapp with a c++ program. I used the  
> features of mkmf (require ‘mkmf’) and saved it into the extconf.rb. So  
> already the whole program is running, but I want to compile the c-file  
> with g++ instead of gcc compiler.
> 
> How can I change this options?

I had a similar problem and came up with this ugly hack (hopefully  
there’s a more official way to do this) which works at least under  
MacOS X and FreeBSD:

# XXX hack to get C++ standard library properly linked into shared

object

# $libs = append\_library($libs, “supc++”) # doesn’t work

if Config::CONFIG[“arch”] =~ /-darwin\d/  
CONFIG[‘LDSHARED’]=“g++ -dynamic -bundle -undefined suppress -  
flat\_namespace”  
else  
CONFIG[‘LDSHARED’] = “g++ -shared”  
end

–Young
