CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

No such file or directory: #include <features.h>

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 29, 2020, 16:59
Default No such file or directory: #include <features.h>
  #1
Member
 
Join Date: Dec 2020
Posts: 38
Rep Power: 5
ulugbey is on a distinguished road
Hi,

I want to write a simple code in OpenFoam

Code:
// A hello world program in C++
#include<iostream>
using namespace std;
int main()
        {
                cout << "Hello World!";
                return 0;
        }
when I try to compile this code using
Code:
g++ hello_world.cpp
It throws an error
Quote:
In file included from /root/OpenFOAM/ThirdParty-v1712/platforms/linux64/gcc-6.3.0/include/c++/6.3.0/x86_64-pc-linux-gnu/bits/c++config.h:507:0,
from /root/OpenFOAM/ThirdParty-v1712/platforms/linux64/gcc-6.3.0/include/c++/6.3.0/iostream:38,
from hello_world.cpp:2:
/root/OpenFOAM/ThirdParty-v1712/platforms/linux64/gcc-6.3.0/include/c++/6.3.0/x86_64-pc-linux-gnu/bits/os_defines.h:39:22: fatal error: features.h: No such file or directory
#include <features.h>
^
compilation terminated.
Do you have an idea why I get this error?

Best regards.
ulugbey is offline   Reply With Quote

Old   December 30, 2020, 16:04
Default
  #2
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 679
Rep Power: 14
Tobermory will become famous soon enough
This is a little odd. Did you list the WHOLE of your code?
Code:
// A hello world program in C++
#include<iostream>
using namespace std;
int main()
        {
                cout << "Hello World!";
                return 0;
        }
or do you have other lines in your hello_world.cpp? The compiler/linker is complaining that it can't include header file features.h, since it doesn't know where it is, but I don't see a
Code:
#include <features.h>
line in your code ... unless you only shared part of the code, in which case the problem is in the bit you didn't share!
Tobermory is offline   Reply With Quote

Old   December 30, 2020, 17:02
Default
  #3
Member
 
Join Date: Dec 2020
Posts: 38
Rep Power: 5
ulugbey is on a distinguished road
I shared the whole code. There is not another part.

Last edited by ulugbey; December 30, 2020 at 19:47.
ulugbey is offline   Reply With Quote

Old   January 1, 2021, 06:26
Default
  #4
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 679
Rep Power: 14
Tobermory will become famous soon enough
Ok - that IS wierd, but a quick google search shows that it's a fairly common problem that's not associated with OpenFOAM - there's something wrong/incomplete with your g++ installation, see e.g.:

https://stackoverflow.com/questions/...ow-do-i-get-it

Try checking/reinstalling your g++ installation. Good luck.
Tobermory is offline   Reply With Quote

Old   January 1, 2021, 09:11
Default
  #5
Member
 
Join Date: Dec 2020
Posts: 38
Rep Power: 5
ulugbey is on a distinguished road
Thanks,

Your suggestion helped to solve the problem.

I implemented
Code:
sudo apt-get install g++-multilib
It works now!
ulugbey is offline   Reply With Quote

Old   January 1, 2021, 12:37
Default
  #6
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 679
Rep Power: 14
Tobermory will become famous soon enough
Great job - well done!
Tobermory is offline   Reply With Quote

Reply

Tags
c++, coding, openfoam 1712

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to calculate mass flow rate on patches and summation of that during the run? immortality OpenFOAM Post-Processing 104 February 16, 2021 08:46
polynomial BC srv537 OpenFOAM Pre-Processing 4 December 3, 2016 09:07
centOS 5.6 : paraFoam not working yossi OpenFOAM Installation 2 October 9, 2013 01:41
OpenFoam install script Error during paraFoam installation SePe OpenFOAM Installation 10 June 19, 2010 15:15
OpenFOAM on MinGW crosscompiler hosted on Linux allenzhao OpenFOAM Installation 127 January 30, 2009 19:08


All times are GMT -4. The time now is 18:12.