0

I create projects using C99 in NetBeans. But when I try to include the library math.h, sqrt() and cbrt() won't work. I am on Ubuntu and using Apache NetBeans IDE 11.2. It is updated to NetBeans 8.2 Patch 2.

The steps I do are : File > New Project > C/C++ > C/C++ Application > Finish. The option Create Main File is checked and it is in C99. I then add #include at the beggining of my code, and at each line I use sqrt() I get an error code : Unable to resolve identifier sqrt.

My code is the following :

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(int argc, char** argv) {
    double x = 1.5;
    double z;
    z = sqrt(x);

    return (EXIT_SUCCESS);
}

And I get an error at line 9.

The reason why I want to edit default project properties is because when I add -lm to my project properties, the error remains but at least to project can run. If it is not in project properties, the project will not run.

  • [1] I cannot reproduce your problem. I can create a C99 project in NetBeans, then use `sqrt()` and `cbrt()` without needing to add the option `-lm` in _Project Properties_. [2] Can you first verify that you really have a C99 project (i.e. **project > Properties > Build > C Compiler > Basic Options > C Standard > C99**) [3] Please update your question with full details of how you created the project, the version of NetBeans you are using, complete sample code and the actual error you are getting. Provide enough detail to ensure that others can attempt to reproduce your problem. – skomisa Jan 21 '20 at 03:17
  • @skomisa I checked and the project is in C99. I am on Linux and using Apache NetBeans IDE 11.2. It is updated to NetBeans 8.2 Patch 2. The steps I do are : File > New Project > C/C++ > C/C++ Application > The option Create Main File is checked and it is in C99 > Finish. – Alexandre Simard Jan 21 '20 at 17:10

0 Answers0