Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
427 views
in Technique[技术] by (71.8m points)

c++ - Where does the value of CXX in a makefile come from?

Code Snippet:

target_test : test.cc 
    $(CXX) $(CPPFLAGS) $(CFLAGS) test.cc

I know that CXX is a variable (containing the compiler command to call), but I was wondering where this variable comes from. The variable is not defined in the makefile and is not an environment variable. Can anyone explain where the value of CXX comes from?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Make has several predefined variables among which is CC. Initially, it is set at cc which is a symlink to the installed C compiler:

$ readlink -f `which cc`
/usr/bin/gcc-4.6

Also:

$ readlink -f `which c++`
/usr/bin/g++-4.6

You can change it if you want.

You can use make -p -f /dev/null to get a list of all implicit rules and variables. I cannot show the output right now because I have a non-standard install and the output is not in English.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...