Use vim gcc/g++ to compile CPP (c + +) files under Mac and run

Source: Internet
Author: User

First confirm GCC and g++ versions, whether they are consistent

Command: gcc-v;g++-V

And then vim

Write C + + files, such as: #include <iostream> ...

Remember when you last save, Exit+:sav+cppname.cpp.

The ". cpp" suffix guarantees that the compiler recognizes the C + + file, so that when you compile, if you are GCC, you know that you automatically know which class libraries (C + +) to call, and note that there is no suffix or error written ". C", the class library is not found at compile time

Then: Wq

Command: LS, there is a XXX.cpp C + + source file under the current directory

g++ Xxxx.exe-o XXX.cpp

Then LS, you will see the current directory XXXX.exe

Compiled files, directly using:./xxxx.exe run on it.

Finally, CTRL + C, exit



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.