Adding compiler flags to the Makefile

1,199 views
Skip to first unread message

Ladshaw, Austin P

unread,
Nov 24, 2015, 12:44:54 PM11/24/15
to moose...@googlegroups.com
Hello all,

In my project I use some additional, non-MOOSE c++ files and I want to add the compiler flag -Wc++11-extensions to the Makefile to suppress some warning messages I always get when compiling. However, I don't really understand what the auto generated Makefile is doing or where to put any additional flags.

Can I add a specific flag in the Makefile for a sub-directory of files? Where and how do I accomplish that in the Makefile?

Thanks,
Austin

--
Austin Ladshaw, EIT
Graduate Research Assistant
Georgia Institute of Technology
Cell: (770) 500 - 7141
http://www.linkedin.com/in/austinladshaw/

Andrew....@csiro.au

unread,
Nov 25, 2015, 4:46:57 AM11/25/15
to moose...@googlegroups.com
I'd like to know the answer to this too. Could someone put the answer on mooseframework.org?

a


Ph: +61 7 3327 4497. Fax: +61 7 3327 4666
Queensland Centre for Advanced Technologies
PO Box 883, Kenmore, Qld, 4069
> --
> You received this message because you are subscribed to the Google
> Groups "moose-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to moose-users...@googlegroups.com.
> Visit this group at http://groups.google.com/group/moose-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/moose-
> users/54724346.12804212.1448387092337.JavaMail.root%40mail.gatech.edu.
> For more options, visit https://groups.google.com/d/optout.

Derek Gaston

unread,
Nov 25, 2015, 5:42:37 PM11/25/15
to moose...@googlegroups.com
I'll let Cody answer this: but just be aware that it's "Thanksgiving" holiday over here in the states... so he may not be quick to respond for the next few days ;-)

Derek

Peterson, JW

unread,
Nov 30, 2015, 6:59:28 PM11/30/15
to moose-users
On Tue, Nov 24, 2015 at 10:44 AM, Ladshaw, Austin P <alad...@gatech.edu> wrote:
Hello all,

In my project I use some additional, non-MOOSE c++ files and I want to add the compiler flag -Wc++11-extensions to the Makefile to suppress some warning messages I always get when compiling. However, I don't really understand what the auto generated Makefile is doing or where to put any additional flags.

Can I add a specific flag in the Makefile for a sub-directory of files? Where and how do I accomplish that in the Makefile?

I would just add them to the environment variable libmesh_CXXFLAGS, i.e.

export libmesh_CXXFLAGS="-Wc++11-extensions"

The Makefile should pick this up and append your flag to whatever is already there.  If you want to use this all the time, add the line above to e.g. your .bash_profile file.

Let me know if that doesn't work...

--
John

Cody Permann

unread,
Nov 30, 2015, 8:15:44 PM11/30/15
to moose-users
John's answer is the best for flags.
--
You received this message because you are subscribed to the Google Groups "moose-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to moose-users...@googlegroups.com.
Visit this group at http://groups.google.com/group/moose-users.

Ladshaw, Austin P

unread,
Dec 1, 2015, 10:33:52 AM12/1/15
to moose...@googlegroups.com
Editing my .bash_profile is really not an option for what I want. I want to add flags to the Makefile and commit those changes to my git repository so other people who work on this project will also have those flags automatically in place when they update their copy of the project. If I only update my .bash_profile, then those changes will only be on this computer for this user.

I want to add compiler flags to the make file when building my project. How do I do that?

If I add the line John suggested to the Makefile, that actually caused more warnings to appear.

Austin


From: "Cody Permann" <codyp...@gmail.com>
To: "moose-users" <moose...@googlegroups.com>
Sent: Monday, November 30, 2015 8:15:33 PM
Subject: Re: Adding compiler flags to the Makefile

For more options, visit https://groups.google.com/d/optout.

Ladshaw, Austin P

unread,
Dec 1, 2015, 11:17:13 AM12/1/15
to moose...@googlegroups.com
I figured it out myself. Here is what you do...

Open the Makefile under your project. Go under the "# dep apps" sub-header of the "MODULES" header. Add the following lines after "APPLICATION_NAME", each on a new line...

export EXTERNAL_FLAGS += -your -flags -go -here
export libmesh_CXXFLAGS += -your -flags -go -here

NOTE: That you need to duplicate your flags for both arguments, so you could create a dummy variable holding your flags and do the following...

DUMMY = -your -flags -go -here
export EXTERNAL_FLAGS += $(DUMMY)
export libmesh_CXXFLAGS += $(DUMMY)

Either way should work. It works for me, but I had to dig around through the MOOSE framework to figure this out.

Austin


From: "Austin P Ladshaw" <alad...@gatech.edu>
To: moose...@googlegroups.com
Sent: Tuesday, December 1, 2015 10:33:50 AM

For more options, visit https://groups.google.com/d/optout.

Peterson, JW

unread,
Dec 1, 2015, 11:47:35 AM12/1/15
to moose-users
On Tue, Dec 1, 2015 at 9:17 AM, Ladshaw, Austin P <alad...@gatech.edu> wrote:
I figured it out myself. Here is what you do...

Open the Makefile under your project. Go under the "# dep apps" sub-header of the "MODULES" header. Add the following lines after "APPLICATION_NAME", each on a new line...

export EXTERNAL_FLAGS += -your -flags -go -here
export libmesh_CXXFLAGS += -your -flags -go -here

NOTE: That you need to duplicate your flags for both arguments, so you could create a dummy variable holding your flags and do the following...

DUMMY = -your -flags -go -here
export EXTERNAL_FLAGS += $(DUMMY)
export libmesh_CXXFLAGS += $(DUMMY)

Either way should work. It works for me, but I had to dig around through the MOOSE framework to figure this out.

If you have a compiler flag that you want all users of your app to use, adding it to an application-level Makefile is probably fine.  Just be aware that compiling MOOSE and applications with different compiler flags can have strange unintended consequences, although this particular flag is pretty benign.

Also, it's not surprising there were *more* warnings, "-Wc++11-extensions" turns on more warnings.  Did you mean to add "-Wno-c++11-extensions"?

--
John
Reply all
Reply to author
Forward
0 new messages