Well known make
Generally need Makefile
To compile the relevant source code , But it can also be done without Makefile
You can compile some simple source code .
In the algorithm competition , The source program of a problem usually has only one file , Use at this time Makefile
Very cumbersome , But it takes time to input a long compilation instruction
g++ a.cpp -o a
Sometimes , Use newer standards in order to use new features C++ standard , Or add debugging information or open Wall
, At this time, you should enter
g++ a.cpp -std=c++17 -g -Wall -o a
It seems very long and time-consuming . Fortunately, ,make
There is a default compilation configuration , stay MacOS
in , I just need to input
make a
# make magically runs 'c++ a.cpp -o a'
It will call... By default c++
The compiler compiles the source code a.cpp
, I don't need to enter that long string of compilation commands .
But because I want to change the default configuration , That is to say C++ 17
standard , Add others C++ flag
( such as -g -Wall -Dqwq
), Or add static library and dynamic library links , Even change the compiler to g++
. These can be modified by adding environment variables .
edit ~/.bash_profile
( perhaps ~/.bashrc, ~/.zshrc
, It depends on the terminal you use ), Add the following environment variables
export CC="gcc"
export CXX="g++"
export LDFLAGS="-L/opt/homebrew/opt/llvm/bin"
export CPPFLAGS="-I/opt/homebrew/opt/llvm/include"
export CXXFLAGS="-std=c++17 -g -Wall"
export CFLAGS="-std=c17 -g -Wall"
Come down here ,
CC
To configureC
compilerCXX
To configureC++
compilerLDFLAGS
Configure dynamic link library addressCPPFLAGS
To configure Flag, YesC
andC++
All in forceCXXFLAGS
To configure Flag, Only onC++
take effectCFLAGS
To configure Flag, Only onC
take effect
again source
After downloading the configuration file or restarting the terminal , Input again make a
compile a.cpp
Will get
make a
# make runs 'g++ -std=c++17 -g -Wall -I/opt/homebrew/opt/llvm/include -L/opt/homebrew/opt/llvm/bin a`.cpp -o a'
If it is a.c
It is
make a
# make runs 'gcc -std=c17 -g -Wall -I/opt/homebrew/opt/llvm/include -L/opt/homebrew/opt/llvm/bin a.c -o a'
This is exactly what we need , So when compiling a single file with the command line , We just need to enter make <sourceCode>
That's all right. !
The above method applies to Linux
and MacOS
,Windows
Should be in System environment variable Add the above environment variable name and corresponding value , Restart the terminal .
Of course , Configured compiler gcc
and g++
Also make sure that in the environment variable , Or input gcc
or g++
The absolute path of can also .
make Small tip More articles about
- Small tip: Use CSS Convert the image to blur ( Ground glass ) effect
At the height of last summer , Once wrote “ Small tip: Use CSS Convert the picture to black and white ” One article , The mode and content of this article actually follow a similar route .CSS3 → SVG → IE filter → canvas. Some time ago ,iOS7 It's not that the melon is not ripe ...
- [ turn ] Small tip: Use CSS Convert the image to blur ( Ground glass ) effect --- Zhang Xin Xu
by zhangxinxu from http://www.zhangxinxu.com This paper addresses :http://www.zhangxinxu.com/wordpress/?p=3804 At the height of last summer , ...
- CSS Small tip Arrangement
CSS Small tip Arrangement 1. utilize css Add arrows at the beginning and end of the list : /* left arrow */ ol a[rel="prev"]:before { content: "\00AB&quo ...
- Small tip:CSS vw Give Way overflow:auto The page scroll bar does not jump when it appears —— Zhang Xin Xu
Small tip:CSS vw Give Way overflow:auto The page scroll bar does not jump when it appears This article was published in 2015 year 01 month 25 Japan , Sunday ,23:08, Classified in css relevant . read 46274 Time , Today, 91 Time by ...
- Small tip: A simple character overlap and graphic generation ---- Zhang Xin Xu
introduction Character overlap is nothing strange . Such as 1 Pixel dislocation simulates shadow effect : perhaps powerFloat The bordered triangle shown in : And many others . But technology is not tofu , You can eat when you are old , You can eat it if it stinks : Then I still have a saying here ...
- Small tip: Use CSS Convert the picture to black and white ( gray 、 Ash placing )[ turn ]
Small tip: Use CSS Convert the picture to black and white ( gray . Ash placing ) This article was published in 2012 year 08 month 19 Japan , Sunday ,20:41, Classified in css relevant , SVG relevant . read 159943 Time , Today, 146 Time ...
- 【 Small TIP】 Record all kinds of errors 【 Updating 】
It's best to pass the program again , In order to improve the ability of code , It will be used here TIP Record the mistakes made in the past . Constantly updating . * Has been transferred to flash .. [150214]WA: Check whether the array is turned down . [150212]WA: If there is a multiplication sign in the program , Need to stay ...
- A couple of accelerations Swift The development of small tip
It's Friday again , Don't wave on weekends , Let's learn something together Swift! This week brings you some more Swift Tips , It's all weird tricks , I don't know , but Swift What attracts me most is its simplicity and ease of use . The main contents are : private(set) ...
- Small tip:CSS vw Give Way overflow:auto The page scroll bar does not jump when it appears
Original address :http://www.zhangxinxu.com/wordpress/?p=4552 One . The Millennium puzzle of horizontal center layout and scroll bar beating At present web the , Most of the page layout is horizontal center layout , The main body should be wide ...
- Small tip: pure CSS Give Way overflow:auto The page scroll bar does not jump when it appears
This article is reproduced in Zhang Xinxu's blog , Original address :http://www.zhangxinxu.com/wordpress/?p=4552 One . The Millennium puzzle of horizontal center layout and scroll bar beating At present web the , Most of the page layout is water ...
Random recommendation
- Unix How does timestamp conversion work in Excel Bulk changes ?
Recently, I came across a Unix The problem of timestamp conversion ."date_time":1393031347 What is this? , You know what? ? If you are right about Unix If you know the time stamp, you can see it at a glance . But we are in the spirit of science popularization ...
- HTML5 New structure tag
introduction In this section , I will tell you three parts , Respectively introduced HTML5 The call of the times , Follow HTML4 The difference between , as well as HTML5 The new structure tag brought by . HTML5 The call of the times HTML4 And HTML5 The difference between HTML5 New structure ...
- onmouseleave And onmouseout difference
1.onmouseleave.onmouseenter, The event is triggered when the mouse enters the specified element area , Blistering is not supported , Areas that do not contain child elements . 2.onmouseout.onmouseover. The mouse enters the specified element to trigger the event , ...
- BAE Environment struts2 + spring + hibernate(SSH)( One ) Get ready
1. First select version control SVN perhaps Git , But because of Git stay windows The environment is needed , So priority SVN. 2. To install a SVN client windows Next use TortoiseSVN: Download now Be careful :BA ...
- Different css The style adapts to different screen sizes to achieve adaptive width
@media screen and ( Judgment properties ){ CSS Style selector } for example : <div class="silder_photo"></div> < ...
- On Shanzhai mobile phone and Android To unite to marriage 【6】MTK Baseband chip of mobile phone
MTK The core of hardware technology , Because of its baseband chip . To reduce costs , At the same time, reduce the area of mobile phone motherboard , In addition to CPU outside , It's also integrated with a lot of peripheral controllers .Feature Phone The function of , It basically depends on the peripheral functions supported by the baseband chip ...
- Lianhe county city , use ajax, While using ul simulation select The drop-down
Reception code js // use jquery Show the mouse on the province ul Drop down display $("#province").hover(function(){ ...
- 【solr These four themes 】 stay Tomcat Deploy Solr4.x
1. install Tomcat (1) Download and unzip to /opt/tomcat stay # cd /opt/jediael # tar -zxvf apache-tomcat-7.0.54.tar.gz # mv apa ...
- Elasticsearch - Brief introduction
Elasticsearch brief introduction 1. What is? Elasticsearch ElasticSearch It's based on Lucene Search server for . It has a distributed multi User capable full-text search engine , Can achieve real-time ...
- ( primary ) About udp Of socket Discussion on the time-consuming problem of sending data
Reprint please indicate the source :http://www.cnblogs.com/lihaiping/p/6811791.html This study note , For problem discussion only , If there is a difference , Can be discussed . Recently, I was looking at the relevant code of streaming media distributor , Its ...