Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] How to use CDT lib/java source
  • From: Ming Cheng <chengm349@xxxxxxxxxxx>
  • Date: Tue, 12 Nov 2019 05:27:07 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; 1; spf=none; dmarc=none; dkim=none; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed;; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4eOqX2J5NkFj8VVLDgKkp19/agSu7Saox7zA3utyF30=; b=l+mTJj1KcGGW5iDxLi0MYDahtTd6E0oixOtmvZOepcQGw2Fe3OWNSYIAUSXTPWae98BsTcRI9ptIjtdMuhyqmh5E038MiXv6tpPFiFlRqXv2mJ5nZippCJ+fORgd2W1wbGJ3vu+0BOZzK+pOkFJGV52Bb+eSBew2DWedjzdSXxy6O6cbq5EJCi6P8da4M+HCXPUHHr82w8yZAKJAXc+6lhlCbG+XWp41o7w+3a6kkC43QozrGHiPzDuF9eoS5lXyLl5n5Iq2eBCMingAFGVcLAnXNbEyNdk5UGutcprSIw6kLXwkCrGW87hk7GXGqRyrxmCL9fNP/zYyCUv07NJlFA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901;; cv=none; b=Il0X5TkaL03l2aZEYKn5I1MO1yclBixmSKClPIVNhaB/i8X4ZfyLnd02rHinDtP41EVtuE2EnbO7MLOy6UwgngNF/xloYLd/wm17RNfG6s9wdFNSIYhDYt5EzNcAqEe0JsIboA6zM6vqtuhws+Twzg0PpY1KmiIARLJrOgk9zMNny04ZTmltfva6UYrBMROgnjL6fHu2qWgRPQQWTxD35QCIgaUHDUvxZtJqINeVasXRBH7hzVbWo8Wnh0BMhsqbwO1DWGUz1ROPEGnr1v5LDMWua9/TECFdS06/ngAdezRLRboeXoI9Kbdl7s3IpPxMeE/uNQstZ9dAHl6OpjlerA==
  • Delivered-to: cdt-dev@xxxxxxxxxxx
  • List-archive: <>
  • List-help: <>
  • List-subscribe: <>, <>
  • List-unsubscribe: <>, <>
  • Thread-index: AQHViWZ0R32gYYOp2UKg+91RKq/2Xqdt3aUAgBfy7ceAAUh/AIAAAuOU
  • Thread-topic: [cdt-dev] How to use CDT lib/java source

Hi Marc-André,


git status core/org.eclipse.cdt.core.native

On branch master

Your branch is up-to-date with 'origin/master'.

nothing to commit, working tree clean


So it could be my env factor.


We may leave the compilation error first if I can get all needed jars. I am not sure I understood Jonah completely correct but my understanding is that I can get all needed jars under <ecplise installation folder>/plugins. For example org.eclipse.cdt.core_5.2.1.201102110609.jar, org.eclipse.cdt.ui_5.2.2.201102110609.jar.


Now I am trying to modify UMLet for my needs and it’s encouraging that ( it can support Ecplise. Your further suggestion are warmly welcome any time.


Thanks for your time and effort.


Sent from Mail for Windows 10


From: cdt-dev-bounces@xxxxxxxxxxx <cdt-dev-bounces@xxxxxxxxxxx> on behalf of Marc-Andre Laperle <malaperle@xxxxxxxxx>
Sent: Tuesday, November 12, 2019 12:59:16 PM
To: CDT General developers list. <cdt-dev@xxxxxxxxxxx>
Subject: Re: [cdt-dev] How to use CDT lib/java source

Some replies inline.

On Nov 11, 2019, at 4:52 AM, Ming Cheng <chengm349@xxxxxxxxxxx> wrote:

Hi Marc-André
I for CDT from git:// When I tried to build it, I got following error:
“Failed to execute goal org.eclipse.tycho:tycho-packaging-plugin:1.4.0:build-qualifier (default-build-qualifier) on project org.eclipse.cdt.core.native: Working tree is dirty.
git status core/org.eclipse.cdt.core.native:
Changes not staged for commit:
modified:    core/org.eclipse.cdt.core.native/
You are trying to use tycho-buildtimestamp-jgit on a directory that has uncommitted changes (see details above).
Either commit all changes/add files to .gitignore, or enable fallback to default timestamp provider by configuring
jgit.dirtyWorkingTree=warning for tycho-packaging-plugin”
Although I did not touch the folder.

You can try doing a 'git reset —hard' to make sure nothing is modified.
Otherwise, I often build with this command:

  mvn clean install -Dmaven.test.skip=true -Djgit.dirtyWorkingTree-cdtDefault=ignore

It skips the tests and the dirty working tree check.
The built jars will be in org.eclipse.cdt/releng/org.eclipse.cdt.repo/target/repository/plugins

Is there anyway I can get a complete CDT jar file Eclipse?

I don’t think there is such a single jar. Like Eclipse, CDT is made of several modules. The one you likely need from CDT is org.eclipse.cdt.core_$version$.jar. Then you’ll need all its dependencies, like org.eclipse.core.resources.jar, etc. If your UML tool is an Eclipse plugin, then you can add org.eclipse.cdt.core as a dependency and it will resolve the other dependencies. Otherwise, you'd have to put all the jars dependencies on the classpath manually…quite a daunting task.

Following your kind suggestion, if I want to create my first ASTNode of main(),
How to achieve the effect of “new IASTFunctionDefinition()”.  ?    It seem new Function is not the way because IFunction is not IASTNode.
I think I should create a ICPPASTTranslationUnit first. Some internet sample shows
ITranslationUnit tu = (ITranslationUnit)
ITranslationUnit tu = (ITranslationUnit)
  1. ITranslationUnit tu = (ITranslationUnit) CDTUITools.getEditorInputCElement(editor.getEditorInput());
  2. ITranslationUnit tu= (ITranslationUnit) CoreModel.getDefault().create(file);
I don’t have (need) UI Editor, and assume I just start my UML tool, so neither a src file; so how to create a tu? BTW how many different ways to create tu?

Probably one of these is your best bet:

CoreModel.getDefault().createTranslationUnitFrom(ICProject cproject, IPath path)
CoreModel.getDefault().createTranslationUnitFrom(ICProject cproject, URI locationURI)

But as you see, this needs a ICproject. Is your UML tool running as a plugin part of Eclipse or not? If not, it will be quite a bit more difficult as you have to load everything necessary to create a workspace and projects outside the Eclipse runtime. I assume it’s possible with a lot of fiddling of many jars and startup boiler plate code but I don’t know for sure and it might be very difficult without good knowledge of how Eclipse works. So I hope your UML tool is running within Eclipse otherwise you might hit a dead end unless you are *very* motivated.

It might be simpler to look into template engines such as Freemarker which might be enough for your needs and way less setup and need of Eclipse knowledge.


Sent from Mail for Windows 10

From: cdt-dev-bounces@xxxxxxxxxxx <cdt-dev-bounces@xxxxxxxxxxx> on behalf of Marc-Andre Laperle <malaperle@xxxxxxxxx>
Sent: Sunday, October 27, 2019 11:40:06 AM
To: CDT General developers list. <cdt-dev@xxxxxxxxxxx>
Subject: Re: [cdt-dev] How to use CDT lib/java source
Hi Ming,

One way would be to use the AST writing capabilities of CDT. This allows you to create nodes, insert them, etc then generate the code from this new AST. There are several places in the CDT codebase that use that, namely the refactorings which are mostly in org.eclipse.cdt.internal.ui.refactoring.* packages, see
There are also smaller spots in “quick fix” in package org.eclipse.cdt.codan.internal.checkers.ui.quickfix, see

I found this presentation about CDT refactoring, there are a few slides about creating AST nodes (node factory), ASTRewrite and generating changes that might useful to you:

About how to use this within your tool, it will depend a lot on how close your tool is to being an Eclipse plugin running in a workspace with a C/C++ project. If some of those conditions are not met, you will have a few more hurdles, like having to add all cdt.core dependencies on the classpath, figuring out if you can do AST writing on an external file (non-workspace), etc.

Either way, it sounds like an interesting project and something that you could write about in a blog or developer FAQ if you do manage to get it working.


On Oct 23, 2019, at 1:58 AM, Ming Cheng <chengm349@xxxxxxxxxxx> wrote:

Hi The team,
I want to develop C++ source code generator according to user’s diagram something like UML tool but very limited just for my needs. So my questions are:
  1. Can I call CDT lib’s API to generate C++ class/functions?
  2. What’s the ABC steps so I can follow them to merge the lib into my tool to see some very basic features?
Ming Cheng.
Warm Regards
Sent from Mail for Windows 10
cdt-dev mailing list
To change your delivery options, retrieve your password, or unsubscribe from this list, visit

cdt-dev mailing list
To change your delivery options, retrieve your password, or unsubscribe from this list, visit

Back to the top