Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am compiling quite big project from source. The compilation always ends with: error: invalid conversion from ‘const char*’ to ‘char*’ [-fpermissive]

I have already compiled this project one year ago. So I know a solution to this. Actualy I found more solutions:

  1. Adding a typecast to appropriate line of cpp code (It went to endless number of changes in each file. So I found next solution.)
  2. Modifying a makefile to compile that file with -fpermissive option. (I had to modify a lot of lines in each makefile. So I find even better solution.)
  3. "g++" or "gcc" was stored in a variable so I added -fpermissive to these variables.

This is the best solution I have. It is sufficient to add this option to each makefile once. Unfortunately this software has big number of subdirectories. So I need to modify more than 100 makefiles. It took me whole day one year ago.

Is there a way how to do this faster.

What about this? alias gcc='gcc -fpermissive' I am not familiar with aliases. But it should be easy to try this. Is the syntax correct? And is this one correct? alias g++='g++ -fpermissive' ? And do I need to export the alias somehow? Will the make program respect the alias?

Should I maybe change ./configure script? Or the ./ Or other file?

share|improve this question

Aliases are most easily set up by placing the relevant line in your ~/.bashrc file. When you issue a command, BASH will search your $PATH for the first instance of an executable of that name. Aliases in your ~/.bashrc file will always be found first so if you have an alias with the same name as an actual command (e.g. gcc) the alias will be executed.

So, in your case, add these lines to your ~/.bashrc (yes the syntax is correct):

alias gcc='gcc -fpermissive'
alias g++='g++ -fpermissive'

Alternatively, you can make different aliases so that you can choose whether or not you want the -fpermissive flag:

alias gcc_per='gcc -fpermissive'
alias g++_per='g++ -fpermissive'

That way, you can use gcc to run /usr/bin/gcc or gcc_per to run /usr/bin/gcc -fpermissive according to your needs. Obviously, you can set the alias to whatever you want, the name is up to you.

Once you have added the relevant lines to your ~/.bashrc, either source it (source ~/.bashrc) or just open a new terminal and you new aliases are set up and ready to go.

share|improve this answer
From what I can tell, make will not respect the alias, though. – Jonas Dec 3 '15 at 8:41

Old question, I know, but for future reference:

Aliasing gcc and g++ in the .bashrc will not working within make. You can however overwrite make's variables CC and CXX from within the .bashrc:

export CC="gcc -fpermissive"
export CXX="g++ -fpermissive"

That of course requires you to use $(CC) and $(CXX) in explicit rules in your makefile, but you should do that anyway. They are used in the implicit rules by default.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .