Whenever I am building my package it uses /usr/bin/g++
(system compiler). I want to build my package with C++11 constructs. I have tried -std=c++11
option but with system compiler it says unrecognized option. I want to build my package from a different gcc
compiler which will get downloaded as part of my package dependency.
So, how can I specify the location of gcc
compiler in Makefile?
There are multiple ways to achieve what you are looking for:
Setting the environment variable CXX
just for the process that will run make
:
$ CXX=/path-to-your-compiler/g++ make
Exporting the environment variable CXX
in your shell:
$ CXX=/path-to-your-compiler/g++ $ export CXX $ make
Setting CXX
at make
's command-line:
$ make CXX=/path-to-your-compiler/g++
Inside your makefile:
CXX := /path-to-your-compiler/g++
Note that setting the variable at make
's command line overrides the other values, and variables set inside the makefile override the ones obtained from the environment (unless the command-line option -e
or --environment-overrides
is provided).
Inside your makefile, you can still override any value set by other means by using the override
directive:
override CXX := /path-to-your-compiler/g++
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.