Develop and debug arm Linux programs with Eclipse integrated development environment __linux

Source: Internet
Author: User
Tags administrator password gdb debugger
Installing the cross-compiler (ARM-LINUX-GCC) and the Integrated development environment (eclipse)

1. Install ARM-LINUX-GCC, whether you are downloading from the Internet, or the development of the CD inside, can be, the version is not limited, my is arm-linux-gcc-4.3.2.

Enter ARM-LINUX-GCC installation package directory, my location is in/home/cfan/temps this directory



Open a terminal, CD to current directory

CD home/cfan/temps/



New installation directory, recommended to install to/usr/local/arm

Enter command: sudo mkdir/usr/local/arm needs to enter an administrator password after execution.


Extract and copy files: sudo tar zxvf arm-linux-gcc-4.3.2.tgz-c/

Waiting for decompression, you can see the directory inside the/usr/local/arm/this directory 4.3.2/.




2. Modify the environment variable of ARM-LINUX-GCC, plainly is you enter ARM-LINUX-GCC when the system knows where to call.

In the terminal executes sudo gedit/etc/profile, modifies the user environment variable, notices this is the user environment variable, only then can use ARM-LINUX-GCC, but cannot use sudo arm-linux-gcc, Because Sudo uses system environment variables rather than user environment variables.

In the last line of the pop-up text editor, enter:

Export path= $PATH:/usr/local/arm/4.3.2/bin


This path to see their own ARM-LINUX-GCC the actual path of the program to modify, some in the Arm/xxxx/usr/bin directory, save closed.

Reboot or logout of the system, in the terminal input arm-linux-gcc-v if you can return the relevant information, then the installation is complete, otherwise, Baidu for a moment, solve the problem earlier.





3. Download and install the Eclipse integrated development environment.

Eclipse is an open source and free integrated development environment, and it works well, I use the version of 4.2.0, but before installation, you need to install the Java Virtual Machine first.

Eclipse Download Address: http://www.eclipse.org/downloads/


Javajre Download Address: http://www.oracle.com/technetwork/java/javase/downloads/index.html


Download the version you want




After you download the two software, unzip it, and then copy the eclipse's directory to its own defined location, which can be put anywhere, I put it under the directory of home/cfan/tools/, the same as my Java in this directory, and then modify the user environment variables.

Enter in the terminal: sudo gedit/etc/profile, also added on the last side

Java_home=/home/cfan/tools/java/jre/
Path= $JAVA _home/bin: $PATH

and save, this path should also be modified according to the actual situation.


You need to reboot or reset the same, and then enter Java-version in the terminal to see version information.




4. Chinese eclipse will teach you how to use Eclipse to develop arm-linux programs and arm Linux drivers, eliminating makefile and endless commands to reduce learning difficulties.

Download the Chinese package, this step can not be downloaded after the decompression overlay to eclipse features and plugins directory on it.

Chinese package download Address: http://download.csdn.net/detail/cp1300/4790834

In the terminal, enter:./eclipse, provided that you can open eclipse by first CD to Eclipse's directory.


Believe that a lot of students want to get started Linux is a headache for Linux development environment, the previous use of command compilation, such as compiling main.c using the command arm-linux-gcc-o main main.c, very inconvenient to use, now have the Eclipse integrated development environment, Make the development simple.

First, make sure that the computer is properly installed with Eclipse and arm Linux GCC, I'm using Ubuntu 12.04 to install Eclipse, and arm Linux GCC, which has a lot of installation methods on the Web, and there's a whole bunch of them in the csdn that they're trying to install, Can learn a lot of things.

1. First build a PC project,

2. Select project Type and tool chain, we choose C Project/executable file/Empty project, use Linux GCC tool chain.

3. Create a new. c File after the project is completed

4. Enter a simple test procedure.

5. Click Save, then compile (shortcut key ctrl+b)

6. Compile complete without errors, you can run the

7. The final output, you can also use debug to debug the program, the method is very simple, here is not for example

Build Arm Linux Project,

1. Ensure arm Linux GCC is installed correctly and set environment variables

Input arm-linux-gcc-v in the terminal if the correct output of relevant information, you can do the following operation, otherwise please check the online data to set.

2. Also new C project

3. Select the executable file, and it is important to select the tool chain

Choose Cross gcc here, then you need to set up the ARM Linux GCC tool chain

4. This step is important to set up the ARM-LINUX-GCC tool chain, above a set compiler prefix arm-linux-

The following is a set of compiler path, that is, ARM-LINUX-GCC tools such as the path, according to their actual situation changes

5. Create new. c files after the same project is completed

6. Input simple code, in the left include inside can see the related arm-linux system header file directory

programs for remote debugging embedded Linux (target machines) with Eclipse and Gdbserver under LinuxDownload Eclipse and download the plugins, such as CDT, or download directly: Eclipse IDE for C + + Linux Developers (includes Incubatingcomponents), the Eclipse official web site, This version of the required plug-ins are installed. Then cross-compile the chain and arm-linux-gdb to ensure normal use.
First , open Eclipse New project, write the simplest hello.c program, the following figure: second, in the project name right click, choose Properties, in the c/c++build-->setting, the toolsetting command are changed to ARM-LINUX-GCC, ARM-LINUX-GCC and Arm-linux-as altogether change these three, compile after the change, the following figure:


Select Item-> menu bar "Run"->debug configurations ... Double-click c + + Applecation to create a new configuration, eclipse will initialize most of the configuration based on the currently selected project, just modify the Debugger configuration page and select Enter Debugger Configuration page
Debugger:
Select Gdbserver Debugger
Debugger Options:
GDB Debugger This, just fill in the arm-linux-gdb here,Sometimes you will find that there is no gdbserver choice, this time at the bottom of the click on the Selectother to select the process luncher as shown, there will be gdbserver options, and thenConnection tab: Type select Tcp,hostname or IP address to fill in the IP of the arm end, the port number by default, this port number will be completed when the arm side runs Gdbserver



All configuration complete, point apply apply, and then turn off configuration menu

Four, start debugging, use the command gdbserver192.168.1.3:1234 on the arm end./A then you can debug in the Linux side, here to note the debugging arm to mount the Linuxnfs folder, in the Mounted folder to debug

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.