Run eclipse on WSL (Ubuntu), debug the makefile project of C language

I have installed wsl and ubuntu22.04 on my computer, and now I am debugging a set of c programs. The makefile was successful in the wsl environment and ran successfully. Now I need to analyze and debug the program in depth. I need to use single-step tracking and try to use eclipse to manage the program.
1 Install eclipse on wsl
Since eclipse is a java kernel program, jdk must be installed on wsl. I installed openJDK17.
First download the specified version of eclipse: Eclipse IDE for C/C++ Developers, Linux 86_64,  
The download is eclipse-cpp-2023-06-R-linux-gtk-x86_64.tar.gz 380MB
Unzip and install eclipse inside wsl:
tar -zxvf eclipse-cpp-2023-06-R-linux-gtk-x86_64.tar.gz
cd eclipse
./eclipse 

出现错误:
tom@Tom-Hongtao:/mnt/c/d/tools/c编译工具/eclipse$ ./eclipse
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
SWT OS.java Error: Failed to load swt-pi3, loading swt-pi4 as fallback.
Eclipse:
An error has occurred. See the log file
/mnt/c/d/tools/c编译工具/eclipse/configuration/1691131677132.log.
tom@Tom-Hongtao:/mnt/c/d/tools/c编译工具/eclipse$   

This is because libswt-gtk-4-java is not installed in WSL. This is the base library for swt. Just install it.

 
sudo apt install libswt-gtk-4-java

[sudo] password for tom:
Sorry, try again.
[sudo] password for tom:
Reading package lists... Done
Building dependency tree... Done
Unpacking libgtk-3-0:amd64 (3.24.33-1ubuntu2) ...
Selecting previously unselected package libgtk-3-bin.
Preparing to unpack .../08-libgtk-3-bin_3.24.33-1ubuntu2_amd64.deb ...
Unpacking libgtk-3-bin (3.24.33-1ubuntu2) ...
Selecting previously unselected package libswt-gtk-4-jni.
Preparing to unpack .../09-libswt-gtk-4-jni_4.20.0-2_amd64.deb ...
Unpacking libswt-gtk-4-jni (4.20.0-2) ...
Selecting previously unselected package libswt-gtk-4-java.
Preparing to unpack .../10-libswt-gtk-4-java_4.20.0-2_amd64.deb ...
Unpacking libswt-gtk-4-java (4.20.0-2) ...
Setting up libcolord2:amd64 (1.4.6-1) ...
Setting up libepoxy0:amd64 (1.5.10-1) ...
Setting up libwayland-egl1:amd64 (1.20.0-1ubuntu0.1) ...
Setting up libgtk-3-common (3.24.33-1ubuntu2) ...
Setting up libxkbcommon0:amd64 (1.4.0-1) ...
Setting up libwayland-client0:amd64 (1.20.0-1ubuntu0.1) ...
Setting up libwayland-cursor0:amd64 (1.20.0-1ubuntu0.1) ...
Processing triggers for man-db (2.10.2-1) ...
Processing triggers for libglib2.0-0:amd64 (2.72.4-0ubuntu2.2) ...
Setting up libgtk-3-0:amd64 (3.24.33-1ubuntu2) ...
Processing triggers for libc-bin (2.35-0ubuntu3.1) ...
/sbin/ldconfig.real: /usr/lib/wsl/lib/libcuda.so.1 is not a symbolic link


Setting up libgtk-3-bin (3.24.33-1ubuntu2) ...
Setting up libswt-gtk-4-jni (4.20.0-2) ...
Setting up libswt-gtk-4-java (4.20.0-2) ...
tom@Tom-Hongtao:/mnt/c/d/tools/c编译工具/eclipse$

这时就可以运行成功了:
tom@Tom-Hongtao:/mnt/c/d/tools/c编译工具/eclipse$./eclipse

2 run eclipse

 After starting eclipse, a classic eclipse startup window will appear, and then the icon on the taskbar is a little penguin.
To specify a workspace, use this default directory:
The familiar Welcome window appears:
After that, you can open the original c project source code on wsl, and you can directly run the tasks in the makefile, which runs perfectly without errors.
C source package: exip-0.5.4.zip   OpenEXI download | SourceForge.net 
Click Build targets--all, the running result is as follows, which is exactly the same as running in wsl.
3 Run the application in eclipse
Run the task examples, compile and generate exipe and exipd. 
Start exipd first and try: Click the down arrow next to the green triangle icon and select the first running configuration in the list.
These running configurations are .launches/ in the source code directory, each of which is configured with startup parameters and can be run directly.
 
These specific operating parameters can be viewed: Menu bar Run-->Run Configuratuons... 
See on the Main page: The project is exip, the application to start is bin/examples/exipd,   
See on the Arguments page: The startup parameter of the exipd program is -xml -schema=src/grammarGen/xmlSchema/XMLSchema-xsd.exi,src/grammarGen/xmlSchema/xml-xsd.exi src/grammarGen/xmlSchema/XMLSchema-schema- xsd.exi
Successful console information:
==== hhahahhaha======<?xml version="1.0" encoding="UTF-8"?>
<p0:schema xmlns:p0="http://www.w3.org/2001/XMLSchema" blockDefault="#all" elementFormDefault="qualified" http://www.w3.org/XML/1998/namespace:lang="EN" targetNamespace="http://www.w3.org/2001/XMLSchema" version="1.0">
<p0:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/xml.xsd">
</p0:import>
<p0:complexType name="openAttrs">
<p0:complexContent>
<p0:restriction base="xs:anyType">
<p0:anyAttribute namespace="##other" processContents="lax">
</p0:anyAttribute>
</p0:restriction>

。。。。。。

</p0:anyAttribute>
</p0:restriction>
</p0:complexContent>
</p0:complexType>
</p0:element>
</p0:schema>

Successful parsing of the EXI stream: src/grammarGen/xmlSchema/XMLSchema-schema-xsd.exi

4 Debugging the application

When we debug the program, we often add some print statements. At this time, we must first run the task examples, recompile and generate exipe and exipd, and then start the debugger to see the print information.
Click the drop-down arrow next to the debug icon, select the application: exipd (XML schema), and switch to the debug mode to run, you can breakpoint, single-step tracking, etc.
You're done, I really feel that it is much more convenient than vscode to edit c code~~~

Guess you like

Origin blog.csdn.net/u012084827/article/details/132106733