01. Check the C Programming Environment in Linux

Source: Internet
Author: User

EnterGCC -- versionYou can view the GCC version. GCC is in LinuxC LanguageCompiler.

You can run the commandLs/lib/libc -*View the so file and observe the Lib library version.

Generally, we use VI or Vim to edit the C language source file. Pay attention to W command disk storage and Q exit. You can save the file name in the filename mode.

// File Name: Test. c
// Compilation Method: GCC test. C-o myfirst

# Include < Stdio. h >
Int Main ( Int Argc, Char   ** Argv)
{
Printf ( " Hello, Linux C. \ n " );
Return   0 ;
}

But when you find that the <stdio. h> file is missing during compilation, you willLs/usr/includeCheck if there is any stdio. H,
OrFind/usr/include-name 'stdio. H'Check whether stdio. h exists. You cannot find stdio. Therefore, printf cannot execute it!
The reason is that although you already have the GCC and Lib libraries, the header file developed by Dev does not: RunSudo apt-Get install build-essentialSolve the problem!

This will installDpkg-dev G + + libc6-dev libstdc ++ 6 Linux-libc-dev patchSoftware, through apt-get, you have noticed that I use Debian/ubuntu.

RunGCC test. C-o myfirstCompileProgram, And thenLs-lThe executable file of myfirst is generated../MyfirstExecute the program.

Note that the current directory is not searched in Linux, so you must explicitly specify the path./myfirst

Congratulations, your first Linux program is OK.

 

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.