Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

arguments file to gcc

Tags:

linux

gcc

g++

On Linux, is there a way to pass arguments to gcc from a file. That is to gave file like compile.args

% cat compile.args
-g3
-ggdb
 -pedantic
 -pedantic-errors
 -Wall
 -Werror
 -O0
 vec1.cpp
 -o vec1

and then give this file to g++/gcc. I can do this using cat compile.args | xargs g++, is they any other way? Does gcc support this?

thanks.

like image 837
eran Avatar asked Dec 20 '25 05:12

eran


2 Answers

Yes, just run gcc @compile.args

like image 103
Basile Starynkevitch Avatar answered Dec 22 '25 20:12

Basile Starynkevitch


For verbosity, also something like this should work (depending on running shell)

g++ `cat compiler.args|xargs`

or

COMPILE_ARGS=`cat compiler.args|xargs` g++ ${COMPILE_ARGS}
like image 29
rasjani Avatar answered Dec 22 '25 18:12

rasjani



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!