Question

I have a mixed java/C++ project which I want to develop on a new PC. It employs the OpenCV graphics library. On the original PC everything is working fine, but when I copy the project over to the new PC I get errors indicating that eclipse does not know about the existence of my compiler. For example next to a line using namespace std; it says symbol std could not be resolved.

I then loaded a sample project from the OpenCV library, which includes both java and C++ elements. It compiled and ran perfectly. I then looked in the properties of that sample project and noticed that "GNU C" and "GNU C++" were listed as languages within the "includes" tab (see picture below). In the corresponding part of the preferences for may non-compiling project it says just "c,cpp". Also the set of tabs is different. I suspect that this is a clue to what has gone wrong, but I have no idea what determines the list of languages that appears in this box or what tabs appear. Any ideas?

enter image description here

this project fails

EDIT: In the properties of the sample project, in C/C++ Build > Tool chain editor, next to "current toolchain" it says "no toolchain" and next to "current builder" it says "gnu make builder". In the same location of my own project, the current toolchain is "android GCC" and the current builder is "android builder". The current toolchain dropdown selection list only contains "android GCC" and nothing else. The current builder drop down list contains both "android builder" and "gnu make builder". If I change the current builder to Gnu make builder, the choice of current toolchain remains fixed as "android GCC" and on the paths and symbols screen the list of languages remains "c,cpp".

Was it helpful?

Solution

It is due to the wrong Project type and toolchain selected while creating / importing the project. I don't know how to get the 'Other toolchain' option in Tool Chain Editor.

However you can delete the current C/C++ project settings and re-import the project and apply the C/C++ nature correctly.

Please follow the following steps:

  1. From your project root directory, delete .cproject file.
  2. Remove the project from eclipse. Ensure 'Delete project contents on Disks' is not selected.
  3. Again import the project using Import -> Android Project -> Exisiting Android Code Into Workspace.
  4. Right click your project then select New -> Other -> C/C++ -> Convert to a C/C++ Project -> Specify “Project type” = Makefile project, “Toolchains” = Other Toolchain.

Then verify whether GNU C, GNU C++ options are listed in Paths and Symbols.

OTHER TIPS

Instead of "import existing project", use "Create project from existing source", then right click the project and go to Android Tools -> Add Native Support.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top