Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse Indigo CDT: Function could not be resolved

This feels silly, but its been 2 days...somewhere after upgrading from Ubuntu 10.04 to 10.11 and from Eclipse Helios to Eclipse Indigo, I got stuck with the following problem:

Problem Description:

I'm trying to use a function in math.h called isinf(), but the problem also occurs with things like isnan().
The program compiles fine on the command line using make and fine in eclipse using build.
But if I open the program file in eclipse it reports that it cannot reolve the isinf() function call.
If I just insert the program contents into a new project and new source file, the error appears immediately.
This problem did not occur under 11.04 with Eclipse Helios CDT

Questions:

Why are these errors only reported when the program file is opened and not on when the program is compiled; why are the errors not detected make is run from the command line?
Is there a solution/workaround available?

Version Info

Linux Ubuntu 10.11 64-bit
Eclipse CDT Indigo, Service Release 1, Build id: 20110916-0149
(Also using Eclipse EE Indigo – if that makes a difference)
GNU Make 3.81
gcc 4.6.1-9Ubuntu3

To Duplicate:

Please find the two files you'll need to replicate below:

Step 0. Verify that everything is fine outside of Eclipse
Copy the attached source file and make file
create a directory e.g. Mkdir FunTest
Save the source file a 'Test.cpp' and the makefile as 'makefile'
Open a command prompt and navigate to the directory e.g. FunTest
Enter 'make'
Enter ./TestOut
Program responds “is not infinite”

Step 1. Create the project in Eclipse
Open Eclipse
Select File|New|MakeFile Project with Existing Code
Click Browse – navigate to the directory (FunTest) and click ok
Select 'Linux GCC' from the Toolchain selector
Click Finish

Step 2. Find the Error
Click Build All (Ctrl-B) – project builds without errors
Open the project in the project explorer to display the file in the directory
Double click on the file “Test.cpp”
Note the error icon next to line testing for infinity
Note the 2 error messages:

Semantic error: Function _isinff could not be resolved 
Semantic error: Function _isinfl could not be resolved

Test.cpp:

include <math.h>

int main(int argc, char **argv)
{

int TestNum = 10;

if (isinf(TestNum) == 0)
    printf("Not infinite\n");


return 0;

}

makefile:

# Specify the compiler
CC = g++

# Specify the compiler flags
CFLAGS += -c

# Specify the files making up the application
SOURCES = Test.cpp
OBJECTS = $(SOURCES:.cpp=.o)
EXECUTABLE = TestOut

all: $(EXECUTABLE)

$(EXECUTABLE): $(OBJECTS)
    $(CC) $(LDFLAGS) $(OBJECTS) $(LDLIBS) -o $@

.cpp.o:
    $(CC) $(CPPFLAGS) $(CFLAGS) $< -o $@

install:
    @echo "Build complete!"
like image 527
myk Avatar asked Nov 01 '11 13:11

myk


3 Answers

I have experienced similar problems of the CDT reporting errors even though the code compiled fine within Eclipse Indigo.

Project > Properties > Settings > Binary Parsers > "GNU Elf Parser"

helped in my case. I had the "Elf Parser" checked.

like image 155
Fabian Avatar answered Nov 06 '22 15:11

Fabian


That looks like a problem that many others have had with eclipse CDT before. Sometimes shutting eclipse down and then starting it back up again is enough to help. If that isn't the case, take a look at what I have below:

Compilation ok, but eclipse content assist having problems

like image 40
Adam Miller Avatar answered Nov 06 '22 13:11

Adam Miller


Check your includes: if you're using include<math.h> change it to include<cmath>. The same for stdio.h and stdlib.h, you should replace by cstdio and cstdlib. Another option may be change you project to a C project instead of a C++.

like image 26
tbellardi Avatar answered Nov 06 '22 14:11

tbellardi