NetBeans not able to include files

4

1

I have been having this problem for a long time now. NetBeans is almost impossible to use with C/C++, maybe because it was not made for it in first place.

Anyways what happens is this: I have this setup for C/C++

alt text

But, the programs are displayed like this:

alt text

It is not able to find any header file!! I know it is a C++ program, the same thing happens with #include <cstdio>. As a result, it is not able to find the definition of printf and fails.

Same thing happens with a .c file.

Also, gcc works fine from the command line.


the problem exists still:

$ find / -name stdlib.h
/usr/include/bits/stdlib.h
/usr/include/c++/4.4.3/tr1/stdlib.h
/usr/include/stdlib.h
/usr/share/syslinux/com32/include/stdlib.h
/usr/arm-gp2x-linux/include/stdlib.h

alt text

Did someone face this problem before? What do I need to do to make this work?

Lazer

Posted 2010-05-18T19:20:21.120

Reputation: 13 841

Answers

4

You should go on the tab "Code Assistance" and check the include paths. Happened to me that the paths referenced something like

/usr/lib/gcc/i486-linux-gnu/4.3/include

but i upgraded to gcc 4.4, so i had to change that to

/usr/lib/gcc/i486-linux-gnu/4.4/include

hope that helps

EDIT

Seems from your screenshots that Netbeans doesn't look in all your include paths. Please make sure that all your include paths are contemplated under "Code Assistance"

Mr Shunz

Posted 2010-05-18T19:20:21.120

Reputation: 2 037

I tried that. not working still. I've added screenshots in the question. Please have a look. thanks! – Lazer – 2010-05-19T14:20:37.953

1@eSKay: you said that gcc compiles fine from the command line. Does it compile directly from netbeans too? Try compiling with full debug info and choose "reparse project" from CodeAssistance menu. Some times this helps. – Mr Shunz – 2010-05-20T08:59:27.697

1

I had the same problem with NB 6.9 and solved by updating all my C++ plugin's (Tools > Plugin).

jdcondor

Posted 2010-05-18T19:20:21.120

Reputation: 11

0

Mine works. These are my settings:

In Options -> C/C++ -> Code Assistance Tab -> C compiler tab ->

I have the following in the "include directories"

/usr/local/include
/usr/lib/gcc/x86_64-linux-gnu/4.4.3/include
/usr/lib/gcc/x86_64-linux-gnu/4.4.3/include-fixed
/usr/include

The last one /usr/include is the one that should have stdio.h and stdlib.h.

I was able to get the C++ code assistance to work by adding /usr/include/c++/4.4.3 in the c++ code assistance tab.

Edit: Your find command seems to have found all the relevant directories. Looks like you might just have to add them to the code assistance tab.

James T

Posted 2010-05-18T19:20:21.120

Reputation: 8 515

How to include directories and it's subdirectories at once? – Vivek Kumar – 2014-12-28T10:27:42.503

0

I had the same problem in Netbeans IDE 7.3 and Ubuntu 12.04 LTS, and I solved by removing this line

/usr/local/include

in Options -> C/C++ -> Code Assistance Tab -> C compiler tab

and Options -> C/C++ -> Code Assistance Tab -> C++ compiler tab

in this directory I dont have any header file.

I hope can help.

Walter Béjar Chacón

Posted 2010-05-18T19:20:21.120

Reputation: 1

Its important to note that there are 2 tabs (as Walter specified). Be sure the "C++ complier" tab has the include directories. Try to build your project. Most of the warnings/errors may be cleared after that. – lepe – 2015-05-27T07:37:03.167

0

I've the same problem with NetBeans 7.2.1. In fact when I created a C/C++ project, the main file was in .C extension (main.c).

I just select extension cpp instead and it works.

looninho

Posted 2010-05-18T19:20:21.120

Reputation: 1

0

I added /usr/include/c++/4.8/ to the include directories and it works.

Geoffrey

Posted 2010-05-18T19:20:21.120

Reputation: 1