Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a C++ compiler flag to extconf.rb

Tags:

c++

c

ruby

I'm writing a Ruby extension, for which I have a standard mkmf configuration script, but I need to add a special include flag (--std=c++0x) to all of the C++ compilation steps. I don't want it in the C compilation steps, 'cause it throws warnings. How should I do this?

require 'mkmf'
create_makefile('thing')

For instance, I tried $CXXFLAGS << '-I..', but CXXFLAGS isn't defined, yet. If I use $CXXFLAGS = '-I..', it's just overwritten later.

like image 270
Andres Jaan Tack Avatar asked Sep 17 '10 12:09

Andres Jaan Tack


1 Answers

This works for me.

$CXXFLAGS += " -std=c++11 "
like image 167
ArafatK Avatar answered Sep 29 '22 02:09

ArafatK