Embedded Linux development environment familiar---first Hello word! __linux

Source: Internet
Author: User
1. Preface: I have a little knowledge of Linux environment

The beginning of embedded Linux, the whole environment and the understanding of the operation of the whole environment is very important. Usually programming in the integrated development environment, such as VC6.0, after writing code, direct button click "Compile", click "Run", are the interface of operation. But you guys are developing programs. Do apes think about how the "compile" and "run" of the integrated development environment works. What a process. Integrated development environment is really convenient, directly through the point of the button to complete the desired operation, but hide the inherent logic of the operation.

and Linux development, you can make your vision more depth, the whole process does not integrate development environment, their own editing code, write their own compilation process, their own to run, no longer through the button point can be completed, you develop the process is an integrated environment. So under the Linux development, you can have a more in-depth understanding of the internal mechanism of development to the operation.

Below, the author and everyone together to learn the first step of embedded Linux learning-familiar with the Linux development environment, the output of my first Hello word. 2. Understanding the compilation process

Generally speaking of "compiling", the process flow of compiling is as follows:

C program Source (. c)--preprocessing--(. i files)-compiling-assembly file (. s)-assembly- object file (. o)-Link-"(executable file)

Executable files can be run directly to the file, for embedded Linux development, the executable file also needs to be converted into binary (. bin), in order to burn write to the controller. The following is developed for this process and is exported under Linux:
Start
Myhello word! 2.C Program source file editing

Editing Environment: Windows
Editor: Source Insight

Write the source program, no matter what system, as long as in any one of the code editor, can be written. It is easier to write code in the Source Insight editor of Windows. Create a myhello.c source file

Write code for the MYHELLO.C source file and save it. Main is the function portal, in order to get a better understanding of the connection between the compiled files, add the Hellofunction () function call, and then create a header file and a source file to declare and define the Hellofunction () function.

#include "stdio.h"
#include "HelloPrint.h"
int main ()
{
    printf ("start\n");
    Hellofunction ();
    return 0;
}

3. In the same vein, create a helloprint.c source file to define the Hellofunction () function.

#include "stdio.h"
#include "HelloPrint.h"
void Hellofunction ()
{
    printf ("Myhello word!\n");
}

4. Similarly, create a helloprint header file HelloPrint.h to declare the Hellofunction () function.

#ifndef  __helloprint_h
#define  __helloprint_h

void  hellofunction (void);

#endif
2. Write your own compilation process-makefile files

Makefile file is the entire compilation process of a collection file, the program source files in advance of the compilation process to write to the makefile file, as long as the command line to enter the Make command, the system automatically executes makefile file contents, convenient operation . At the same time, makefile will automatically according to the target file whether changes, dependent files are updated, choose whether to compile, so for a large number of program files, can reduce the compilation time . Makefile documents are prepared in a specific form, and there is a lot of information on the web.

The contents of the makefile file are as follows. Where the hello file is the final executable file to be generated, MYHELLO.C and helloprint.c are compiled raw materials, using the GCC compiler tool.

HELLO:MYHELLO.C   helloprint.c 
    gcc-o Hello    myhello.c helloprint.c clean
:
    rm Hello
3.linux Complete compilation, run

The above code is done under Windows, of course, it can be written under Linux, but Windows is easier to write. After you have written the above code and makefile files, you need to upload them to Linux on the virtual machine.

Upload Tool: CuteFTP (you can also pull files with the VMware Tools tool in the virtual machine)

ssh telnet tool: SecureCRT (log on to the Linux server and complete command line operations in SECURECRT Software under Windows), You can also operate the command line directly on the Linux terminal.      

CuteFTP complete upload copy to Linux under the file has the following several:

SECURECRT Login to the virtual machine Linux Server interface as follows, and complete the relevant instructions operation. And the following results are compiled as follows:

After you can see the make instruction, the related files listed are more than the executable file Hello, which is the last thing you want. After the hello is executed, the execution results can occur. The first Hello word output appears. Make clean is used to perform clean content in makefile and delete executable files.

See if the pro are familiar with the Linux development environment. Familiarity with the environment is important for developing entry. These are also embedded Linux Development Foundation, but the program has not been burned to the controller, so the next one will be through a simple s3c2440 bare Board program development to learn the basic development process.

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.