Developers cross-compiling and debugging under Ubuntu using Eclipse IDE for C + +

Source: Internet
Author: User


1. Download JDK and Eclipse

First we download the Eclipse IDE for C + + developers,

Address

http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/mars/2/ Eclipse-cpp-mars-2-linux-gtk-x86_64.tar.gz

After downloading, open Eclipse directory open to the eclipse, prompting "Version 1.5.0of the JVM is not suitable for this product. version:1.7 or greater isrequired. ".

We need a higher version of the JDK.

Download jdk-7u67-linux-x64.rpm website.

2. Installing and configuring the JDK

2.1 Installation

After downloading jdk-7u67-linux-x64.rpm, since Ubuntu does not support RPM installation, we will convert RPM to Deb installation

sudo apt-get installs alien #alien默认没有安装, so install it first

sudo alien xxxx.rpm #将rpm转换位deb, when done, generates a xxxx.deb with the same name

sudo dpkg-i xxxx.deb #安装

2.2 Configuration

Since Ubuntu comes with a gij JVM implementation, it will appear when the terminal types "java-version": Java Version "1.6.0" ... and other relevant information. This means that the JVM is already implemented in the system, and the Gij JVM is the default JVM implementation (used by other Ubuntu tools or software). At this point, you need to use the "update-alternatives" tool provided by Debian to complete the multi-version implementation choice.

sudo update-alternatives--display java

The discovery system only lists the GIJJVM, because Jdk7 is manually decompressed and installed.

We need to enter the following directives:

{

[Email protected]:/usr/bin$ sudo update-alternatives--install/usr/bin/java java/usr/java/jdk1.7.0_67/bin/java 2048

[Email protected]:/usr/bin$ sudo update-alternatives--install/usr/bin/javac javac/usr/java/jdk1.7.0_67/bin/javac 2048

Update-alternatives:using/usr/java/jdk1.7.0_67/bin/javacto Provide/usr/bin/javac (javac) in Auto mode

[Email protected]:/usr/bin$ sudo update-alternatives--install/usr/bin/javah javah/usr/java/jdk1.7.0_67/bin/javah 2048

Update-alternatives:using/usr/java/jdk1.7.0_67/bin/javahto Provide/usr/bin/javah (javah) in Auto mode

[Email protected]:/usr/bin$ sudo update-alternatives--install/usr/bin/javaws javaws/usr/java/jdk1.7.0_67/bin/ Javaws 2048

[Email protected]:/usr/bin$ sudo update-alternatives--install/usr/bin/javap javap/usr/java/jdk1.7.0_67/bin/javap 2048

}

In fact, as long as the installation of Java, Javac is OK. The 2048 at the end of the line is the priority level.

Then enter sudo update-alternatives--config java to select the JDK you just installed


Check configuration update-alternatives--display java

2.3 Configuring Environment variables

Gedit ~/.BASHRC

Add at the end of the open file

Export java_home=/usr/java/jdk1.7.0_67

Export JRE_HOME=${JAVA_HOME}/JRE

Export Classpath=.:${java_home}/lib:${jre_home}/lib

Export Path=${java_home}/bin: $PATH

2.4 Problems encountered

Issue 1, after installation knock Java-version appears: Error occurred duringinitialization of VM java/lang/prompt information

Solve:

This problem occurs because:

The tools.pack in Java_home/lib has not been decompressed into Tools.jar.

The rt.pack in Java_home/jre/lib has not been decompressed into Rt.jar.

The workaround is to:

switch to root user, otherwise it will fail ~ (su root), can not find unpack200 words, in Java_home/bin also has

Enter into the Java_home/lib, unzip the tools.pack into Tools.jar, execute:

unpack200 Tools.pack Tools.jar

Enter into the Java_home/jre/lib and unzip the rt.pack into Rt.jar:

unpack200 Rt.pack Rt.jar

2.5 Check the Java version:

Java-version found that the Java version 1.7.0 has been OK.

3. Start Eclipse

3.1 Initialization

Before opening eclipse in the terminal, you need to initialize the environment variable before opening eclipse

3.2 Issues that need to be addressed

Open eclipse in the terminal and find an error:

I nternal error:sha-1 not available.

Hint, SHA-1 This algorithm cannot be found, but this is an algorithm provided by the JDK system. Included in the Java_home/jre/lib/jsse.jar.

Open the desired directory view, the result is only one jsse.pack, and no jsse.jar. This is why the exception was thrown, using unpack200 to extract the corresponding jar package.

unpack200 Jsse.pack Jsse.jar

Note Switch to root user, otherwise it will fail ~ (su root), can not find unpack200 words, in Java_home/bin also has

4. Install Eclipseremote System Explorer (RSE)

4.1. Download RSE

Address: Http://download.eclipse.org/tm/downloads/drops/R-3.3.2-201202061000/

Download Rse-runtime-3.3.2.zip (Recommended for most users)

4.2. Install to eclipse (version 3.4 or above)

Unzip the RSE package and copy the contents directly to the Eclipse root directory.

4.3. Open Eclipse and configure

New-"Project-" rse-"connection


Choose SSH


Fill in IP, name ( This IP is the development board via dhclent eth0 instruction request, PC gives it assigned IP)

Switch the eclipse's working directory to RSE

Find 10.10.0.52, right-click into properties, then enter IP address

Right-click the connection and enter the remote user name and password to complete the synchronization

5. Add Makefile Engineering and commissioning

5.1 Adding a project

Into the new project, select Makefile Project with existing code in the C + + option


Find the appropriate makefile, and join will automatically generate the project.

5.2 Commissioning

Here take Telechips's launcher as an example

Select Debug Configuration for Debug as ...

In the Main tab,c/c++application fills in the location of our application on the PC side, selecting Connection as the 10.10.0.52,remote Absolute File Path that was just rse set For C/c++application Select the location of the far end (note: Is the location of the application, not its directory location).


On the Arguments tab, add-plugin tslib

Add telechips gdb to the main sub tab of the Debugger tab

On the Gdbserver Settings Sub-tab of the Debugger tab, write Gdbserver and prot port 2345


Done, now you can debug, remember to save the configuration (the bottom right corner of the Apply save, debug Debugging).


If it is the main launcher, remember to kill off the original running launcher~

6, using RSE remote control files

Step 1 Switch The working directory of Eclipse to RSE

Step 2 Select Sftp in the 10.10.0.52 option in the remote system and click Root. Then enter the remote user name and password in the popup box.

Step 3 You can then modify and copy and delete remote files directly.


Developers cross-compiling and debugging under Ubuntu using Eclipse IDE for C + +

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.