I have installed Eclipse Indigo for C/C++ Linux developers on Ubuntu 10.04 x86.
When I use common predefined macro __BASE_FILE__
Eclipse says Symbol '__BASE_FILE__' could not be resolved
, but compilation is OK. I have to use it so often in my code and Eclipse fills my screen with red lines and bug icons
How can I fix this?
asked Nov 16, 2011 at 7:44
1
Not sure if this addresses your specific problem, but I also had semantic errors. They just came out of the blue after having a working project.
Anyway, I fixed it with a single option in workspace settings by setting:
«Build configuration for indexer: Use active build configuration»
The other option was «Use the build configuration specified in the project’s indexer settings» and this is the one that wasn’t working. I think it may have been corrupted after an eclipse crash.
answered Apr 9, 2012 at 23:13
talofttaloft
2513 silver badges3 bronze badges
4
Window -> Preferences -> C/C++ -> Code Analysis -> Syntax and Semantic Errors: OFF
This won’t solve the cause of the problem but at least will stop the false errors from being shown.
answered Aug 26, 2013 at 15:39
WindRiderWindRider
11.8k6 gold badges50 silver badges57 bronze badges
3
The simplest solution is to reset the indexer:
Window / Preferences / C/C++ / Indexer.
uncheck «Enable indexer» ->>OK
rebuild all, may show lots of errors
check «Enable indexer» ->>OK
rebuild all
This error can be produced by forced closing of eclipse by power failure.
answered Jun 12, 2014 at 11:16
ZazunZazun
691 silver badge1 bronze badge
2
You need to rebuild the index of your project.
Right-click on the project, then Index->Rebuild.
answered Feb 5, 2016 at 18:57
mczrafmczraf
1611 silver badge2 bronze badges
Deleting the .metadata folder , and then Import project .
This way is OK!
answered Sep 6, 2016 at 14:16
TanghuihuaTanghuihua
611 silver badge1 bronze badge
0
Updated:
You have to add proper paths to Project->Propoerties->C/C++ General->Paths and Symbols. If it does not help, you can configure Eclipse Code Analyser (which generates the ‘errors’) in Project->Properties->C/C++ General->Code Analysis. Under the error description you have problem with, try Customize Selected->Scope->Exclusion Patterns.
answered Nov 16, 2011 at 7:51
ondriskoondrisko
3202 silver badges11 bronze badges
0
IMO the correct solution is to define the symbol in Project -> Properties->C/C++ General -> Paths and Symbols -> Symbols tab. Since you can assume the symbol will always be supplied by the compiler, you just tell Eclipse to consider it defined.
I had the same problem just recently, where Eclipse complained about undefined macro, that i always supply using -D<MACRO_NAME>
compiler option.
answered Dec 7, 2012 at 13:39
compostuscompostus
1,17810 silver badges13 bronze badges
I think it has something to do with the workspace/.metadata.
I had the problem of semantic errors reported but Hello World compiles and runs.
I deleted the project, created another one, same error reporting. Reinstalled CDT, same thing. Deleted the workspace, shut down Eclipse, restarted, created new hello world, same thing. Deleted the workspace again, shut down Eclipse again, this time noticed that Eclipse had recreated the workspace folder during shutdown when it couldn’t find it. Deleted the workspace with Eclipse shut down. Restarted Eclipse, created HW project, errors show for about a second and then gone. Deleted project, created another one, errors show for a sec, then poof.
If you actually had projects in your workspace (mine was a clean install), I bet that you could just delete the .metadata folder within the workspace, and it would fix it.
answered Feb 16, 2014 at 18:05
2
I personally agree with compostus’ answer.
It’s good to solve the real problem that eclipse’s code analyzer have.
But when I try this steps:
define the symbol in Project -> Properties->C/C++ General -> Paths and Symbols
I don’t find symbol tab or any place to add a symbol. what I want to do is putting macros like -DANDROID or #define ANDROID 1 to eclipse so that the code analyzer can find this definition.
I’m under Mac OSX mountain lion.
answered Dec 29, 2012 at 6:49
flukefluke
6608 silver badges15 bronze badges
2
adding as another answer, hopefully this will help someone.
I have a ~simple workspace (1 c++ shared-object (linux’s version of a DLL, 3 c++ executables, and a pydev python project)
I checked out all the code to a new machine, and it builds fine but had numerous ‘semantic errors’ on std-c and std-C++ code and includes.. I went through all the discovery / indexer setting to no avail.
==> deleting the entire .metadata folder fixed this.
Since i had nothing non-trivial set up in the workspace (all in the project files / makefiles), eclipse happily created a fresh workspace, and i simply had to do a file->import-> existing projects
answered Jun 3, 2014 at 17:31
If on Ubuntu, go to Window > Preferences > In Search box type «Indexer» > Select Indexer in left column.
Under heading «Indexer Options» tick the following options (all but those involving the skipping of files):
- Index files source files not included in project
- Index unused Headers Index all header variants
- Index source and header files openend in editor
- Allow heuristic resolution of includes
Under heading «Indexing Strategy» tick both options which are:
- Automatically update the index
- Update index immediately after every file-save
Under heading «Build Configuration for the indexer» select the following option:
- User active build configuration
answered Oct 11, 2014 at 14:45
danielbkerdanielbker
3941 gold badge3 silver badges18 bronze badges
1
try this:
Preferences —> c/c++ —> Indexer —> Index all header variants
check this option.
answered Feb 17, 2016 at 10:34
This is a file indexing issue.
Solution — Right click on the project, Index->Freshen all files.
(Applies to Eclipse CDT.Oxygen)
answered Jul 9, 2018 at 10:33
In my case, I eventually discovered that the indexer was having problems because a colleague had “helpfully” duplicated a whole load of declarations in two header files that were only included together in a small subset of C files in the project. Removing the duplications (and making one header include the other) allowed the indexer to function correctly again.
It was particularly a problem with duplicated enumerations, for some reason. I do not know why this is so.
answered Jun 10, 2020 at 18:42
Donal FellowsDonal Fellows
130k18 gold badges145 silver badges213 bronze badges
I used #pragma once in my code. This configuration caused me to have the problem:
—fileA.h—
#pragma once
#define MYMACRO(X) func(X)
—fileB.h—
#include "fileA.h"
—fileB.cpp—
#include "fileB.h"
MYMACRO(5) <---- warning here
I replaced #pragma once with #ifndef #define HEADER_FILE_H #endif, and that fixed the problem.
answered Mar 18, 2014 at 14:29
Not sure if this works for the OPs issue, but I had semantic errors in eclipse Luna and was able to resolve them by following instructions in this thread: Eclipse shows unresolved inclusion but it compiles
The compiler finds the header, but Eclipse not.
You could help Eclipse and set the path to the header files under:
Project -> Properties -> C/C++ Build -> Settings -> Compiler ->
Includes
In my situation, eclipse had determined one of my include directories, but did not determine that there were sub-include directories within it.
answered Aug 6, 2015 at 17:16
Aaron SwanAaron Swan
1,1281 gold badge12 silver badges20 bronze badges
I had a similar issue but my compile was fine but Eclipse showed errors on lines that used a #define from another include file. I fixed by checking «Index all header variants». I think the classis #ifndef FILENAME in include file was process multiple times in Indexer and so 2nd time the FILENAME was defined so all #defines in .h file were not «seen» by the preprocessor. Go to Window | Preferences | C/C++ | Indexer.
answered Dec 9, 2015 at 22:26
I have the same problem. Compiler preprocesses ok, but static analyzer doesn’t. In my source file:
#define PLATFORM_INC_FILES
#include <platform.h>
int coflags=O_BINARY; // Undefined symbol
In platform.h (an OS dependent header to help creating portable code):
#ifdef PLATFORM_INC_FILES
#include <stdio.h>
...
It looks like static analyzer doesn’t take the .c #define statements into account when preprocessing included headers. By defining it at the symbols dialog, errors dissapear, but that is a project scope symbol definition, resulting in every source to include every system header in my case.
Hope it gets fixed soon…
Using Eclipse Mars and MinGW on MSIS2.
answered Feb 15, 2016 at 15:03
The problem occurs this way: I insert a new variable name into the code somewhere e.g. «newone» in this example:
int a;
foo()
{
a=17;
newone=23;
}
The file is saved (so the indexer is reindexing).
Then I added the definition:
int a, newone;
foo1()
{
newone=0;
}
foo()
{
a=17;
newone=23;
}
The indexer will still shows the error at the line » newone=23;» but not at the other lines of code containing «newone».
Solution: first define your variables, then use it.
M.
answered Jul 12, 2017 at 7:39
In the past, I would define the ANDROID symbol in:
Project -> Properties->C/C++ General -> Paths and Symbols -> #Symbols tab
However, the latest version of Eclipse no longer has a # Symbols there, or anywhere else.
It seems there is no longer any way of defining symbols in Eclipse.
Eclipse has so many bugs and problems.
I finally gave up and switched to using Gedit and the terminal to compile.
answered May 18, 2013 at 2:09
NOTE: it apparently is a recurrent question on StackOverflow, but — for what I have seen — either people never find a way or their solution does not work for me
The problem:
I am using Eclipse Juno ADT. Everything was working fine until I tried to update the NDK. I replaced my ndk
folder (that was the ndk-r8d
) by the new version (i.e. ndk-r8e
) and, in my Paths and Symbols
configuration, I changed the includes to go from g++ 4.6 to 4.7.
It seemed to break my index: I could compile my code, but Eclipse was giving semantic errors, exactly like in [1] and [2]. The errors mainly come from symbol used by OpenCV4Android, such as distance
, pt
, queryIdx
and trainIdx
.
When I tried to backup to my old configuration, the index was still broken! I cannot find a way to change this.
What I have tried
- Clean up the project
- Rebuild, refresh, and all the other options in the «Index» submenu (when «right-clicking» on the project)
- Disable / enable the indexer in the preferences
- Verify that symbols such as
trainIdx
only appear in my OpenCV4Android include in thePaths and Symbols
section. - Change the order of my includes in the
Paths and Symbols
section. I basically tried to put the OpenCV include in the beginning and in the end.
Some observations
What is not working
I assume that it is the CDT index because of the following:
- In command line, I can build my project using
ndk-build clean
andndk-build
. - When I start Eclipse, I have no error until I open a C++ file (from the
jni
folder). - I can always build the project, but as long as I have opened a C++ file, I can’t run the application anymore because of a lot of
Field '<name>' could not be resolved.
- If I don’t open the C++ files, Eclipse doesn’t report any error and can build and deploy the Android application successfully.
Interesting fact
The following code reports errors on line
, queryIdx
, pt
:
cv::line(mRgb, keypointsA[matches[i].queryIdx].pt, keypointsB[matches[i].trainIdx].pt, cv::Scalar(255, 0, 0, 255), 1, 8, 0);
If I write it as follows, it works:
cv::DMatch tmpMatch = matches[i];
cv::KeyPoint queryKp = keypointsA[tmpMatch.queryIdx];
cv::KeyPoint trainKp = keypointsB[tmpMatch.trainIdx];
cv::line(mRgb, queryKp.pt, trainKp.pt, cv::Scalar(255, 0, 0, 255), 1, 8, 0);
It is not that all of the OpenCV functions are unresolved: only pt
, queryIdx
and trainIdx
are.
Any comment will be really appreciated.
Solution 1
Not sure if this addresses your specific problem, but I also had semantic errors. They just came out of the blue after having a working project.
Anyway, I fixed it with a single option in workspace settings by setting:
«Build configuration for indexer: Use active build configuration»
The other option was «Use the build configuration specified in the project’s indexer settings» and this is the one that wasn’t working. I think it may have been corrupted after an eclipse crash.
Solution 2
Window -> Preferences -> C/C++ -> Code Analysis -> Syntax and Semantic Errors: OFF
This won’t solve the cause of the problem but at least will stop the false errors from being shown.
Solution 3
The simplest solution is to reset the indexer:
Window / Preferences / C/C++ / Indexer.
uncheck «Enable indexer» ->>OK
rebuild all, may show lots of errors
check «Enable indexer» ->>OK
rebuild all
This error can be produced by forced closing of eclipse by power failure.
Solution 4
Deleting the .metadata folder , and then Import project .
This way is OK!
Solution 5
You need to rebuild the index of your project.
Right-click on the project, then Index->Rebuild.
Comments
-
I have installed Eclipse Indigo for C/C++ Linux developers on Ubuntu 10.04 x86.
When I use common predefined macro
__BASE_FILE__
Eclipse saysSymbol '__BASE_FILE__' could not be resolved
, but compilation is OK. I have to use it so often in my code and Eclipse fills my screen with red lines and bug iconsHow can I fix this?
-
Seems to be it is bug of the static analyzer, not the indexer. In any case it isn’t working for me. Thanks for your efforts.
-
__BASE_FILE__
is predefined gcc macro. I don’t want to redefine it -
I’m having the same problem with multiple tabs not showing up and I’m runing Eclipse 4.2.1 and latest CDT on Ubuntu 12.04
-
this worked for me. Delete the entire .metadata folder (which is at the root of the workspace), and restart eclipse. file->import to re-add the existing projects of course, i didn’t have anything non-trivial set up in the workspace.
-
worked here as well. Just after reimporting the projects, everything was reported as an error which made my heart sink, but a few cycles of the cpu later, all is good.
-
Hi talot, I couldn’t find out how to access to the «workspace setting»> «Build configuration for indexer: Use active build configuration». Could you please tell me where to find it. thanks
-
@ahmed_khan_89 Window -> Preferences -> C/C++ -> Indexer
-
I almost downvote your answer because it is not the right solution, but after trying around, yours is the best solution. I have a lot of errors reported by calling boost and quince functions, and those errors drive me crazy to the point I have to turn off Eclipse error analysis feature.
-
I downvoted your answer, but if after this, the autocompletion works, I will upvote it. After YEARS, this problem is still annoying me and every time it takes long time to make it work, by performing random clean, build, close project, build index, fresh files etc
-
There’s more possible causes than power failure. This happened to me when I pulled my project repo onto a machine with a newer version of eclipse.
-
I enabled all indexer options, except those for skipping files) in both Window > Preferences and project properties and it fixed the issue.
-
In my case, the other option was selected «Use project indexer setting» or something like that. But in my project settings, the box for «enable project specific indexer settings» was disabled anyway. So it should have picked up the global/active build configuration automatically. But explicitly switching to active build configuration made the pesky red squiggles go away!
-
This worked. But next time I’ll try rt-click on project, index, rebuild.
-
This truly does seem to be the only fix. Years later I am in CCS (based on eclipse) and it was harder to find, but it is the only thing that gets them to go away
Recents
Related
NOTE: it apparently is a recurrent question on StackOverflow, but – for what I have seen – either people never find a way or their solution does not work for me
The problem:
I am using Eclipse Juno ADT. Everything was working fine until I tried to update the NDK. I replaced my
ndk
folder (that was thendk-r8d
) by the new version (i.e.ndk-r8e
) and, in myPaths and Symbols
configuration, I changed the includes to go from g++ 4.6 to 4.7.It seemed to break my index: I could compile my code, but Eclipse was giving semantic errors, exactly like in [1] and [2]. The errors mainly come from symbol used by OpenCV4Android, such as
distance
,pt
,queryIdx
andtrainIdx
.When I tried to backup to my old configuration, the index was still broken! I cannot find a way to change this.
What I have tried
- Clean up the project
- Rebuild, refresh, and all the other options in the “Index” submenu (when “right-clicking” on the project)
- Disable / enable the indexer in the preferences
- Verify that symbols such as
trainIdx
only appear in my OpenCV4Android include in thePaths and Symbols
section.- Change the order of my includes in the
Paths and Symbols
section. I basically tried to put the OpenCV include in the beginning and in the end.
Some observations
What is not working
I assume that it is the CDT index because of the following:
- In command line, I can build my project using
ndk-build clean
andndk-build
.- When I start Eclipse, I have no error until I open a C++ file (from the
jni
folder).- I can always build the project, but as long as I have opened a C++ file, I can’t run the application anymore because of a lot of
Field '<name>' could not be resolved.
- If I don’t open the C++ files, Eclipse doesn’t report any error and can build and deploy the Android application successfully.
Interesting fact
The following code reports errors on
line
,queryIdx
,pt
:cv::line(mRgb, keypointsA[matches[i].queryIdx].pt, keypointsB[matches[i].trainIdx].pt, cv::Scalar(255, 0, 0, 255), 1, 8, 0);
If I write it as follows, it works:
cv::DMatch tmpMatch = matches[i]; cv::KeyPoint queryKp = keypointsA[tmpMatch.queryIdx]; cv::KeyPoint trainKp = keypointsB[tmpMatch.trainIdx]; cv::line(mRgb, queryKp.pt, trainKp.pt, cv::Scalar(255, 0, 0, 255), 1, 8, 0);
It is not that all of the OpenCV functions are unresolved: only
pt
,queryIdx
andtrainIdx
are.Any comment will be really appreciated.
Answer
In your selected project preferences within the Eclipse environment, go to C/C++ General -> Code Analysis -> Launching. Make sure that both check boxes are unchecked. Close and reopen the project or restart eclipse and rebuild the project.
Attribution
Source : Link , Question Author : JonasVautherin , Answer Author : Jeet
I have installed Eclipse Indigo for C/C++ Linux developers on Ubuntu 10.04 x86.
When I use common predefined macro __BASE_FILE__
Eclipse says Symbol '__BASE_FILE__' could not be resolved
, but compilation is OK. I have to use it so often in my code and Eclipse fills my screen with red lines and bug icons
How can I fix this?
20 Answers
Not sure if this addresses your specific problem, but I also had semantic errors. They just came out of the blue after having a working project.
Anyway, I fixed it with a single option in workspace settings by setting:
«Build configuration for indexer: Use active build configuration»
The other option was «Use the build configuration specified in the project’s indexer settings» and this is the one that wasn’t working. I think it may have been corrupted after an eclipse crash.
Window -> Preferences -> C/C++ -> Code Analysis -> Syntax and Semantic Errors: OFF
This won’t solve the cause of the problem but at least will stop the false errors from being shown.
The simplest solution is to reset the indexer:
Window / Preferences / C/C++ / Indexer.
uncheck «Enable indexer» ->>OK
rebuild all, may show lots of errors
check «Enable indexer» ->>OK
rebuild all
This error can be produced by forced closing of eclipse by power failure.
Deleting the .metadata folder , and then Import project .
This way is OK!
You need to rebuild the index of your project.
Right-click on the project, then Index->Rebuild.
Updated:
You have to add proper paths to Project->Propoerties->C/C++ General->Paths and Symbols. If it does not help, you can configure Eclipse Code Analyser (which generates the ‘errors’) in Project->Properties->C/C++ General->Code Analysis. Under the error description you have problem with, try Customize Selected->Scope->Exclusion Patterns.
IMO the correct solution is to define the symbol in Project -> Properties->C/C++ General -> Paths and Symbols -> Symbols tab. Since you can assume the symbol will always be supplied by the compiler, you just tell Eclipse to consider it defined.
I had the same problem just recently, where Eclipse complained about undefined macro, that i always supply using -D<MACRO_NAME>
compiler option.
I think it has something to do with the workspace/.metadata.
I had the problem of semantic errors reported but Hello World compiles and runs.
I deleted the project, created another one, same error reporting. Reinstalled CDT, same thing. Deleted the workspace, shut down Eclipse, restarted, created new hello world, same thing. Deleted the workspace again, shut down Eclipse again, this time noticed that Eclipse had recreated the workspace folder during shutdown when it couldn’t find it. Deleted the workspace with Eclipse shut down. Restarted Eclipse, created HW project, errors show for about a second and then gone. Deleted project, created another one, errors show for a sec, then poof.
If you actually had projects in your workspace (mine was a clean install), I bet that you could just delete the .metadata folder within the workspace, and it would fix it.
I personally agree with compostus’ answer.
It’s good to solve the real problem that eclipse’s code analyzer have.
But when I try this steps:
define the symbol in Project -> Properties->C/C++ General -> Paths and Symbols
I don’t find symbol tab or any place to add a symbol. what I want to do is putting macros like -DANDROID or #define ANDROID 1 to eclipse so that the code analyzer can find this definition.
I’m under Mac OSX mountain lion.
adding as another answer, hopefully this will help someone.
I have a ~simple workspace (1 c++ shared-object (linux’s version of a DLL, 3 c++ executables, and a pydev python project)
I checked out all the code to a new machine, and it builds fine but had numerous ‘semantic errors’ on std-c and std-C++ code and includes.. I went through all the discovery / indexer setting to no avail.
==> deleting the entire .metadata folder fixed this.
Since i had nothing non-trivial set up in the workspace (all in the project files / makefiles), eclipse happily created a fresh workspace, and i simply had to do a file->import-> existing projects
If on Ubuntu, go to Window > Preferences > In Search box type «Indexer» > Select Indexer in left column.
Under heading «Indexer Options» tick the following options (all but those involving the skipping of files):
- Index files source files not included in project
- Index unused Headers Index all header variants
- Index source and header files openend in editor
- Allow heuristic resolution of includes
Under heading «Indexing Strategy» tick both options which are:
- Automatically update the index
- Update index immediately after every file-save
Under heading «Build Configuration for the indexer» select the following option:
- User active build configuration
try this:
Preferences —> c/c++ —> Indexer —> Index all header variants
check this option.
This is a file indexing issue.
Solution — Right click on the project, Index->Freshen all files.
(Applies to Eclipse CDT.Oxygen)
In my case, I eventually discovered that the indexer was having problems because a colleague had “helpfully” duplicated a whole load of declarations in two header files that were only included together in a small subset of C files in the project. Removing the duplications (and making one header include the other) allowed the indexer to function correctly again.
It was particularly a problem with duplicated enumerations, for some reason. I do not know why this is so.
I used #pragma once in my code. This configuration caused me to have the problem:
—fileA.h—
#pragma once
#define MYMACRO(X) func(X)
—fileB.h—
#include "fileA.h"
—fileB.cpp—
#include "fileB.h"
MYMACRO(5) <---- warning here
I replaced #pragma once with #ifndef #define HEADER_FILE_H #endif, and that fixed the problem.
Not sure if this works for the OPs issue, but I had semantic errors in eclipse Luna and was able to resolve them by following instructions in this thread: Eclipse shows unresolved inclusion but it compiles
The compiler finds the header, but Eclipse not.
You could help Eclipse and set the path to the header files under:
Project -> Properties -> C/C++ Build -> Settings -> Compiler ->
Includes
In my situation, eclipse had determined one of my include directories, but did not determine that there were sub-include directories within it.
I had a similar issue but my compile was fine but Eclipse showed errors on lines that used a #define from another include file. I fixed by checking «Index all header variants». I think the classis #ifndef FILENAME in include file was process multiple times in Indexer and so 2nd time the FILENAME was defined so all #defines in .h file were not «seen» by the preprocessor. Go to Window | Preferences | C/C++ | Indexer.
The problem occurs this way: I insert a new variable name into the code somewhere e.g. «newone» in this example:
int a;
foo()
{
a=17;
newone=23;
}
The file is saved (so the indexer is reindexing).
Then I added the definition:
int a, newone;
foo1()
{
newone=0;
}
foo()
{
a=17;
newone=23;
}
The indexer will still shows the error at the line » newone=23;» but not at the other lines of code containing «newone».
Solution: first define your variables, then use it.
M.
In the past, I would define the ANDROID symbol in:
Project -> Properties->C/C++ General -> Paths and Symbols -> #Symbols tab
However, the latest version of Eclipse no longer has a # Symbols there, or anywhere else.
It seems there is no longer any way of defining symbols in Eclipse.
Eclipse has so many bugs and problems.
I finally gave up and switched to using Gedit and the terminal to compile.
I have the same problem. Compiler preprocesses ok, but static analyzer doesn’t. In my source file:
#define PLATFORM_INC_FILES
#include <platform.h>
int coflags=O_BINARY; // Undefined symbol
In platform.h (an OS dependent header to help creating portable code):
#ifdef PLATFORM_INC_FILES
#include <stdio.h>
...
It looks like static analyzer doesn’t take the .c #define statements into account when preprocessing included headers. By defining it at the symbols dialog, errors dissapear, but that is a project scope symbol definition, resulting in every source to include every system header in my case.
Hope it gets fixed soon…
Using Eclipse Mars and MinGW on MSIS2.
ПРИМЕЧАНИЕ: это, по-видимому, повторяющийся вопрос о StackOverflow, но — для того, что я видел — либо люди никогда не находят пути, либо их решение не работает для меня
Проблема:
Я использую Eclipse Juno ADT. Все работало нормально, пока я не попытался обновить NDK. Я заменил мою папку ndk
(которая была ndk-r8d
) новой версией (т.е. ndk-r8e
), а в моей конфигурации Paths and Symbols
я изменил входящие значения, начиная с g++ 4.6 до 4.7.
Казалось, что я разбил свой индекс: Я мог скомпилировать свой код, но Eclipse давал семантические ошибки, как в [1] и [ 2]. Ошибки в основном происходят из символа, используемого OpenCV4Android, например distance
, pt
, queryIdx
и trainIdx
.
Когда я попытался сделать резервную копию старой конфигурации, индекс все еще был сломан! Я не могу найти способ изменить это.
Что я пробовал
- Очистить проект
- Перестроить, обновить и все другие параметры в подменю «Индекс» (при щелчке правой кнопкой мыши по проекту)
- Отключить/включить индекс в настройках
- Убедитесь, что символы, такие как
trainIdx
отображаются только в моем OpenCV4Android, включают в разделPaths and Symbols
. - Измените порядок моих включений в разделе
Paths and Symbols
. Я в основном пытался включить OpenCV в начале и в конце.
Некоторые наблюдения
Что не работает
Я предполагаю, что это индекс CDT из-за следующего:
- В командной строке я могу построить свой проект с помощью
ndk-build clean
иndk-build
. - Когда я запускаю Eclipse, у меня нет ошибки, пока я не открою файл С++ (из папки
jni
). - Я всегда могу создать проект, но до тех пор, пока я открыл файл С++, я больше не могу запускать приложение из-за большого количества
Field '<name>' could not be resolved.
- Если я не открываю файлы С++, Eclipse не сообщает об ошибке и может успешно создавать и развертывать приложение Android.
Интересный факт
Следующий код сообщает об ошибках в line
, queryIdx
, pt
:
cv::line(mRgb, keypointsA[matches[i].queryIdx].pt, keypointsB[matches[i].trainIdx].pt, cv::Scalar(255, 0, 0, 255), 1, 8, 0);
Если я напишу его следующим образом, он работает:
cv::DMatch tmpMatch = matches[i];
cv::KeyPoint queryKp = keypointsA[tmpMatch.queryIdx];
cv::KeyPoint trainKp = keypointsB[tmpMatch.trainIdx];
cv::line(mRgb, queryKp.pt, trainKp.pt, cv::Scalar(255, 0, 0, 255), 1, 8, 0);
Не все функции OpenCV не решены: только pt
, queryIdx
и trainIdx
.
Любые комментарии будут действительно оценены.