Author Topic: How do you set a default compiler option ?  (Read 2041 times)

patrickkox

  • Junior Community Member
  • Posts: 6
  • Hero Points: 0
How do you set a default compiler option ?
« on: April 06, 2015, 03:54:34 pm »
 Hi,
I'm learning to program in C++ by using the "Programming : Principles and Practice using C++" book by bjarne Stroustrup.

he uses his own header file "std_lib_facilities.h" in his exercises and examples.
The problem is that there is C++11 code used and the compiler (G++) doesn't compile unless the option std=gnu++11 is provided.

I've found that this can be set under the build section (GNU C Options) but only works for the current project.

So I was wondering if there is some method to set this as the default option for this compiler ?

Tnx.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 4652
  • Hero Points: 373
Re: How do you set a default compiler option ?
« Reply #1 on: April 07, 2015, 12:35:09 pm »
You can create your own custom project type and add that compile option.  Project>New>Customize...>New... Make sure you copy settings from the project type you want to modify (like GNU/C++). Then you can use your custom project type every time you create a project.

patrickkox

  • Junior Community Member
  • Posts: 6
  • Hero Points: 0
Re: How do you set a default compiler option ?
« Reply #2 on: April 07, 2015, 04:05:05 pm »
Clark,
Thank you for the information.

Unfortunatly I seem to be having problems with the bug that's discussed here.

I'm running SlickEdit 2014 : v19.0.1.1 64-bit on Linux (Debian GNU Linux 8.0 [jessie])
So I guess I'll have to wait for the next release where this is fixed.

Tnx
Patrick

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 4652
  • Hero Points: 373
Re: How do you set a default compiler option ?
« Reply #3 on: April 07, 2015, 04:16:33 pm »
You can download 19.0.2 RC4 now and it has the fix you need.

patrickkox

  • Junior Community Member
  • Posts: 6
  • Hero Points: 0
Re: How do you set a default compiler option ?
« Reply #4 on: April 07, 2015, 05:42:51 pm »
Sorry, I saw the post with the information where to get the RC4 after replying to your post.

There is one strange thing that I encounter.

When I add the new template with the -std=gnu++14 option added the compiler gives error messages :
- "Unable to remove file '/home/patrick/Programming/C14-Test/Debug/'"
- "*** Errors occurred during this build ***"

and the compiler exits 

Build -> compile : works
Build -> build : fails
all other build options also fail.

But when I start a new project with the default GNU C/C++ compiler options and set the compiler option under "Build -> GNU C Options -> Compiler -> Other Options" it works perfectly.

Maybe I'm doing something wrong when making the custom project type ?

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 4652
  • Hero Points: 373
Re: How do you set a default compiler option ?
« Reply #5 on: April 07, 2015, 05:50:28 pm »
Unfortunately, when you copy the GNU C/C++ template, your new wizard doesn't let you specify the executable name.  You end up with an Output executable name of %bd which just specifies a path but not an executable. Go to the GNU C Options, Link Tab, and change Output Filename to %bd/whatever.

We will see if we can fix this so the Executable name text box works for copied templates.

patrickkox

  • Junior Community Member
  • Posts: 6
  • Hero Points: 0
Re: How do you set a default compiler option ?
« Reply #6 on: April 08, 2015, 02:07:46 pm »
So if I understand correctly I can do one of the following two ?

1. Add the -std=gnu++11 option in a custom template and set a program name under Gnu C Options.

2. Do no use a custom template and set the -std=gnu++11 option under Gnu C Options

I tried to modify the gnu C/CPP template that comes with SlickEdit and making a new project with that seems to work well, but I get error messages when I try to quit SE  so I guess that causes another problem.

Tnx.
Patrick
« Last Edit: April 08, 2015, 02:09:23 pm by patrickkox »

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 4652
  • Hero Points: 373
Re: How do you set a default compiler option ?
« Reply #7 on: April 08, 2015, 02:19:32 pm »
I was able to add the -std=gnu++11 to my custom project template so I don't need to add it after creating the project. The issue with the executable name not be settable will be fixed in 19.0.2 RC5.

At the moment, you either are setting an executable name with your custom project template or adding the -std=gnu++11 option with the standard project template.

patrickkox

  • Junior Community Member
  • Posts: 6
  • Hero Points: 0
Re: How do you set a default compiler option ?
« Reply #8 on: April 08, 2015, 04:11:56 pm »
Thanks,
I'll wait for RC5 and will manually add the -std=gnu++11 manually until then.

Patrick