C Programming in Linux

Source: Internet
Author: User
Linux c Programming-Linux general technology-Linux programming and kernel information. The following is a detailed description. It is always impossible to compile C ++ programs in WINDOWS in LINUX. It is reported that cout cannot be found.

1. After checking the information, you must add using namespace std after inlcude;

2/after this is added, it is still difficult to get up and find out that I still use GCC to compile... changed to g ++ and then OK.

Command: g ++-o filename. cpp
Or: g ++ filename. cpp-o filename
Or: g ++ filename. cpp generates the default executable file a. out.

You can compile it into an existing directory, but you cannot create a new directory at the same time.

3/failed to run, and later found that $./filename is enough


1/indent the program code: indent filename. cpp, which produces a filename. cpp ~ File, which is the backup of the file before indentation. Indent-kr filename. cpp is another style of indentation.

2/The main () function must be the number of returned integers (No parameter is allowed ). The return value is 0. The error code is greater than 0.

3. compile and generate the target file: g ++ filename-c. This will generate the target file of filename. o. Or g ++-c filename.

4/link the target file: g ++ filename. o-o filename, generate the executable file filename, or g ++ filename. o to generate the default executable file a. out.

5. Compile the link to generate both the target file and the executable file :?? It does not seem to work. Note: Multi-file programs can compile links in batches. For example, g ++ file1.cpp file2.cpp-c generates the target file of the two.

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.