alias gcc='gcc -fpermissive' or modifying ./configure script

2

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 ./configure.in? Or other file?

robo

Posted 2012-12-15T09:47:00.563

Reputation: 21

Answers

2

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.

Jonas Greitemann

Posted 2012-12-15T09:47:00.563

Reputation: 457

2

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.

terdon

Posted 2012-12-15T09:47:00.563

Reputation: 45 216

From what I can tell, make will not respect the alias, though. – Jonas Greitemann – 2015-12-03T08:41:34.847