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

Compilation error with OpenFOAM 2.1.x

Register Blogs Community New Posts Updated Threads Search

Like Tree9Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 16, 2012, 09:58
Default Compilation error with OpenFOAM 2.1.x
  #1
New Member
 
Martin Vymazal
Join Date: Dec 2009
Posts: 16
Rep Power: 16
Martin_ is on a distinguished road
Hello,

I would like to compile OpenFOAM (from git repository), but I'm getting a compilation error right at the start:

Code:
fileMonitor.C:308:13: warning: use of old-style cast [-Wold-style-cast]
fileMonitor.C:308:13: warning: use of old-style cast [-Wold-style-cast]
fileMonitor.C:308:13: warning: use of old-style cast [-Wold-style-cast]
fileMonitor.C:325:22: warning: use of old-style cast [-Wold-style-cast]
fileMonitor.C:325:22: warning: use of old-style cast [-Wold-style-cast]
fileMonitor.C:325:22: warning: use of old-style cast [-Wold-style-cast]
fileMonitor.C:333:17: error: ‘read’ was not declared in this scope
make: *** [Make/linux64GccDPOpt/fileMonitor.o] Error 1
+ wmake libso OpenFOAM
I guess I need to include a header or qualify the function with namespace name. I tried to search for function 'read' in the C++ documentation on OpenFOAM web, but there is tens of them and I have no clue which one to choose (I'm new to OpenFOAM). Could you please help me?

I updated the sources today. My compiler is gcc 4.7

I have 2 more questions:
- what do I have to set/configure to use a different compiler (clang/intel)?
- it looks like my only friend to search for keywords in the source code is 'grep'. Is there a way of using OpenFOAM from within Qtcreator/KDevelop or some other ide so that the code browsing is easier?

Thank you very much.

Best regards,

Martin Vymazal
Martin_ is offline   Reply With Quote

Old   April 16, 2012, 15:25
Default
  #2
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Greetings Martin and welcome to the forum!

Knowing which operating system you are using also helps. Mainly because we don't know which packages you might need to install.
And AFAIK gcc 4.7 is currently untested with OpenFOAM. Every major release of gcc has needed some sort of adjustment, sometimes due to gcc, others to the linking system.

For a full log of the list of errors, the usual recommendation made is to run like this:
Code:
./Allwmake > make.log 2>&1
This way the whole build process is logged into "make.log". And the first error is usually the one to be blamed.
As for the compiling error, that might not be the main reason for the failed compilation. This is why I mention that the first error is usually the one to be blamed.

As for changing compiler, see "OpenFOAM-2.1.x/etc/bashrc" the variable "WM_COMPILER".

As for IDE: http://openfoamwiki.net/index.php/Ho...M_with_Eclipse

Best regards,
Bruno
MaLa likes this.
__________________
wyldckat is offline   Reply With Quote

Old   April 16, 2012, 15:45
Default
  #3
New Member
 
Martin Vymazal
Join Date: Dec 2009
Posts: 16
Rep Power: 16
Martin_ is on a distinguished road
Hello Bruno,

thank you for your reply. I redirected the error output in a log file in a similar fashion as you mentioned. The error I posted previously is the very first error in that log file. I can post the whole log, but there's really nothing more to see.

My system is Archlinux. I agree that the new gcc can be a problem, but I don't really see why an error regarding an undeclared function 'read' would be related to a missing package in my linux distribution. Do you have an idea where is this function 'read' supposed to come from (i.e. do you know where is it declared)?

Best regards,

Martin Vymazal

Last edited by Martin_; April 16, 2012 at 16:45.
Martin_ is offline   Reply With Quote

Old   April 16, 2012, 16:07
Default
  #4
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
According to the source code of the file where the error occurs, that function should be defined somewhere in these included files:
Code:
#   include <sys/inotify.h>
#   include <sys/ioctl.h>
#   include <errno.h>
Knowing the Linux version usually helps us (well, mostly me) to try and reproduce the same error, but I've had bad experiences trying to install ArchLinux... More easily I could test Fedora 17, but it's still alpha... which can also lead to bad experiences
__________________
wyldckat is offline   Reply With Quote

Old   April 17, 2012, 08:26
Default
  #5
Senior Member
 
Robert Sawko
Join Date: Mar 2009
Posts: 117
Rep Power: 22
AlmostSurelyRob will become famous soon enough
@wyldcat_: Thank you for redirecting me here. This is to confirm that I have exactly the same problem.

@Martin_: Have you managed to solve this issue perhaps? There's an OpenFOAM package in AUR. Have you tried it?
AlmostSurelyRob is offline   Reply With Quote

Old   April 19, 2012, 18:47
Default
  #6
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Greetings to all!

I got curious about Arch Linux and Gcc 4.7.0 that is has and I managed to install the latest stable 2011.08.19 x86_64. I used the net install ISO and installed all of the essential tools needed for building OpenFOAM 2.1.x, without the need to do any changes to the code.

Attached are two lists:
  • "list.txt", which has the output of the command:
    Code:
    pacman -Q
  • "list_e.txt", which has the output of the command:
    Code:
    pacman -Qe
I suggest that you guys compare to your own "installed packages" lists and figure out what packages you're missing

By the way, I didn't try building ParaView, simply because I didn't bother installing X.org

Best regards,
Bruno
Attached Files
File Type: txt list.txt (2.2 KB, 40 views)
File Type: txt list_e.txt (1.3 KB, 20 views)
__________________
wyldckat is offline   Reply With Quote

Old   April 21, 2012, 08:54
Default
  #7
Senior Member
 
Robert Sawko
Join Date: Mar 2009
Posts: 117
Rep Power: 22
AlmostSurelyRob will become famous soon enough
Thanks for doing the cross-check and providing your pacman output.

I can confirm that I have all the relevant packages. The only differences from out pacman -Q commands were dash and xinetd. I also thought that it might be something with my environmental variables because I am sourcing university profile that allows me to run some other applications, but removed that temporarily and I am currently recompiling and I am still seeing the same errors: 'read' was not declared. It's really frustrating.

Also, I can confirm that so far the libOSSpecific.o fix didn't show any negative behaviour. My other compilation seems to be working fine.
AlmostSurelyRob is offline   Reply With Quote

Old   April 21, 2012, 10:35
Default
  #8
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Hi Robert,

Mmm... OK, there are only a few things that come to my mind:
  • Perhaps it's the installed Arch Linux architecture that is different from the one I used, namely x86_64. What does this output on your command line:
    Code:
    uname -m
  • Try building "OSspecific" manually:
    Code:
    cd src
    cd OSspecific/POSIX
    wclean libo
    wmake libo
    This should rebuild it (1st clean, then make).
  • If your system was upgraded to the latest release of Arch Linux, perhaps something has been left behind...
Best regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Old   April 21, 2012, 12:01
Default
  #9
Senior Member
 
Robert Sawko
Join Date: Mar 2009
Posts: 117
Rep Power: 22
AlmostSurelyRob will become famous soon enough
Hello!

I am happy to report that it works. In the end, it was missing dependencies. What I did was to vimdiff the file and I was actually installing the few missing packages as I was scanning the file comparison. I was missing some gcc packages so compared with your file I was missing

gc
gcc-ada
gcc-go
gcc-objc

The errors were appearing on the first compilation but my comment above was a bit precipitate because they vanished on the second compilation.

It's all fine. Thank you for your help.
AlmostSurelyRob is offline   Reply With Quote

Old   April 22, 2012, 19:06
Default
  #10
New Member
 
Martin Vymazal
Join Date: Dec 2009
Posts: 16
Rep Power: 16
Martin_ is on a distinguished road
Hello Robert & Bruno,

I managed to compile OF 2.1.x following these steps:

1) run ./Allwmake in OpenFOAM root directory
2) when the error message about undefined 'read' function appears, stop compilation and do as Bruno said:

Code:
cd src
cd OSspecific/POSIX
wclean libo
wmake libo
3) run again ./Allwmake in OpenFOAM root as in 1). This time, no errors appeared

I was not able to skip step 1) and directly start with 2). I guess the Allwmake does something (set links, environment variables?) that enables the library in 2) to compile.

In my system, installing/not installing the packages

gc
gcc-ada
gcc-go
gcc-objc

didn't make any difference. The 'read' function error is always present. I tested this on 2 machines with Archlinux (laptop and desktop).

I also tried to compile paraFoam. At one point, I got the following error:
Code:
In file included from
OpenFOAM/ThirdParty-2.1.x/ParaView-3.12.0/Qt/Core/pqAnimationScene.cxx:57:0:

OpenFOAM/ThirdParty-2.1.x/ParaView-3.12.0/Qt/Core/pqServerManagerSelectionModel.h:75:30: error: calls to overloaded operators cannot appear in a constant-expression
make[2]: *** [Qt/Core/CMakeFiles/pqCore.dir/pqAnimationScene.cxx.o] Error 1
make[1]: *** [Qt/Core/CMakeFiles/pqCore.dir/all] Error 2
make: *** [all] Error 2
This can be fixed by editing line 75 of the file

OpenFOAM/ThirdParty-2.1.x/ParaView-3.12.0/Qt/Core/pqServerManagerSelectionModel.h:

and replacing
Code:
ClearAndSelect = Clear | Select
by
Code:
ClearAndSelect = static_cast<int>(Clear) | static_cast<int>(Select)
as described here.

After that, paraFOAM compiled and I was able to run a sample test case and visualize results.

Best regards,

Martin Vymazal
Martin_ is offline   Reply With Quote

Old   May 1, 2012, 12:04
Default
  #11
Senior Member
 
Robert Sawko
Join Date: Mar 2009
Posts: 117
Rep Power: 22
AlmostSurelyRob will become famous soon enough
I am sorry. My above post is not valid.

I would like to confirm Martin_'s observation. It is not a dependency issue. The truth is that I have done these things in the same time and compiled successfully. Now I have made a double check and it is the compilation of OSSpecific that is the necessary step for successful compilations not the dependencies that I outlined.

@Martin_: Many thanks for your assiduity.
AlmostSurelyRob is offline   Reply With Quote

Old   May 2, 2012, 06:23
Default
  #12
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
FYI: OpenFOAM 2.1.x has had some additional updates that make things more compatible with Gcc 4.7, so I advise you guys to update!
The updates:
In a nutshell - how to update:
Code:
git pull
./Allwmake
__________________
wyldckat is offline   Reply With Quote

Old   May 3, 2012, 15:58
Default
  #13
New Member
 
Andrew Fischer
Join Date: Dec 2010
Posts: 1
Rep Power: 0
wizzrobe is on a distinguished road
Guys,

Just ran into this error myself on Archlinux. I was responding to a request for help with the AUR package.

The read() function used in src/OSspecific/POSIX/fileManager.C, which throws that error, is defined in the <unistd.h> header file. That file is not in the includes for fileManager.C. All I can imagine is that something else pulls it in somehow when you recompile it get it to work.

For now I'm simply patching that file manually to add "#include <unistd.h>" in the AUR package, along with assorted other fixes, so it builds in one pass.

Obviously some significant changes in gcc 4.7.

EDIT: I haven't tried the latest git clones; looking at the github the same patch I made is in there so Im sure they're fine. This is all based off of the stable 2.1 download. Maybe I have to add an OpenFOAM-git AUR package version.

Last edited by wizzrobe; May 3, 2012 at 16:21.
wizzrobe is offline   Reply With Quote

Old   October 23, 2012, 21:53
Default
  #14
New Member
 
Chris Fisichella
Join Date: Oct 2012
Posts: 28
Rep Power: 13
fisichel is on a distinguished road
Hi,
I tried Bruno's suggestion to
Code:
cd src
cd OSspecific/POSIX
wclean libo
wmake libo
libOSspecific compiled.
I then went back to OpenFOAM-2.1.1/src and requested:
Code:
wmake libso OpenFOAM
It sent back:
Code:
/usr/bin/ld: cannot find -lPstream
Any ideas? I am having trouble compiling OpenFOAM on Debian Linux 6.0.3. So far, I have used apt-get to obtain openMPI, I think I successfully built paraview. I was not successful with scotch, so I decided to move along to openFOAM. Now, I'm stuck. Any help will be appreciated.
Thanks,
Chris
fisichel is offline   Reply With Quote

Old   October 24, 2012, 03:32
Default
  #15
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Greetings Chris and welcome to the forum!

Since you're trying to build OpenFOAM 2.1.1 and using Debian 6.0.3, I believe that the following instructions should work for you: http://openfoamwiki.net/index.php/In...u#Ubuntu_10.04

Best regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Old   October 25, 2012, 20:34
Default Stuck on step 3
  #16
New Member
 
Chris Fisichella
Join Date: Oct 2012
Posts: 28
Rep Power: 13
fisichel is on a distinguished road
Hi Bruno,

Thanks for the link. The apt-get line was good except for openmpi-bin,

Step 3 is not working too well for me. I'm following the 32 bit instructions since
Code:
uname -m 
i686
the next step is to source the OpenFOAM shell file. The error message I get is:

Code:
fisichel@debian:~$ source $HOME/OpenFOAM/OpenFOAM-2.1.1/etc/bashrc WM_NCOMPPROCS=2 WM_MPLIB=SYSTEMOPENMPI WM_ARCH_OPTION=32
Cannot open configuration file /home/fisichel/OpenFOAM/ThirdParty-2.1.1/platforms/linuxGcc/openmpi-1.5.3/share/openmpi/mpicc-wrapper-data.txt
Error parsing data file mpicc: Not found
Cannot open configuration file /home/fisichel/OpenFOAM/ThirdParty-2.1.1/platforms/linuxGcc/openmpi-1.5.3/share/openmpi/mpicc-wrapper-data.txt
Error parsing data file mpicc: Not found
fisichel@debian:~$
I noticed I have mpicc-wrapper-data.txt at:
Code:
fisichel@debian:~$ find . -name mpicc-wrapper-data.txt -print
./121023_OpenFOAM/ThirdParty-2.1.1/openmpi-1.5.3/ompi/tools/wrappers/mpicc-wrapper-data.txt
That 121023_OpenFOAM directory is from my installation before I tried asking on this thread. I tried compiling each module separately after ./Allwmake did not work.

I think there is an easy solution to this, but I don't want to muck up the installation. Have you run into this before? If so, could you offer some advice?
Thanks,
Chris
fisichel is offline   Reply With Quote

Old   October 27, 2012, 11:43
Default
  #17
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Hi Chris,

Quote:
Originally Posted by fisichel View Post
The apt-get line was good except for openmpi-bin,
The instructions from that page require that you install this package, otherwise they will not work as intended.

Nonetheless, if you do not wish to use the system's Open-MPI, then you can try and use the custom build of Open-MPI 1.5.3 which you apparently already have. For that, you'll need to remove "WM_MPLIB=SYSTEMOPENMPI" from the source line, which would result in this:
Code:
source $HOME/OpenFOAM/OpenFOAM-2.1.1/etc/bashrc WM_NCOMPPROCS=2 WM_ARCH_OPTION=32
Keep in mind that you use this line, then you should also change the one that probably has already been placed at the end of the file "$HOME/.bashrc" (notice the dot before "bashrc").

Additionally, to play it safe, it's best to start a new terminal window/tab, so that you'll have a clean shell environment.

Last but not least, I've finished testing today with Debian 6.0.3 x86_64 in a virtual machine and have adapted the instructions here: http://openfoamwiki.net/index.php/In...ian#Debian_6.0

Best regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Old   October 28, 2012, 19:42
Default
  #18
New Member
 
Chris Fisichella
Join Date: Oct 2012
Posts: 28
Rep Power: 13
fisichel is on a distinguished road
Hi Bruno,

I was not clear. After checking, I realized I did not install openmpi-bin, but then I did make sure I installed it. After, I had problems.

I went back to the OpenFOAM source installation. It worked. I explicitly changed the OpenFOAM-2.1.1/etc/bashrc entry for architecture to 32 bit, so I could have an invocation of ./Allwmake that did not have any extra parameters. I have not run any test problems yet, so I might still not be out of the woods.

There was an error in the build of scotch. It said it was ignoring the error.

I'm going to wipe the drive and try it again just to make sure the process works. I will check out your experiences, too.

Thanks,
Chris
fisichel is offline   Reply With Quote

Old   November 6, 2012, 19:08
Default
  #19
New Member
 
Chris Fisichella
Join Date: Oct 2012
Posts: 28
Rep Power: 13
fisichel is on a distinguished road
Hi Bruno,

My compilation ended up not working. I started in with the tutorials and paraview did not work. I reinstalled Debian 6.0.3 (32 bit) on one machine and 6.0.6 (64 bit) on another machine. The instructions provided in the link worked for both installations. Thanks for making that available. I hope others find it as useful as I did.

Thanks,
Chris
wyldckat likes this.
fisichel is offline   Reply With Quote

Old   December 23, 2012, 04:33
Default
  #20
New Member
 
Chris Fisichella
Join Date: Oct 2012
Posts: 28
Rep Power: 13
fisichel is on a distinguished road
Hi Bruno,

When you have a chance, I would recommend changing the instructions for the Debian build to include building OpenMPI. SYSTEMOPENMPI is not working correctly: "dummy Pstream library. This dummy library cannot be used in parallel mode."

FYI,
Chris
fisichel is offline   Reply With Quote

Reply


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
OpenFOAM compilation MrAnderson OpenFOAM 3 October 16, 2017 18:04
OpenFOAM 1.6.x, 1.7.0 and 1.7.x are not fully prepared to work with gcc-4.5.x wyldckat OpenFOAM Bugs 18 October 21, 2010 05:51
Cross-compiling OpenFOAM 1.6 on Linux for Windows 32 and 64bits with Mingw-w64 wyldckat OpenFOAM Announcements from Other Sources 7 January 19, 2010 15:39
OpenFOAM Training in Europe and USA hjasak OpenFOAM 0 August 8, 2008 05:33
OpenFOAM Debian packaging current status problems and TODOs oseen OpenFOAM Installation 9 August 26, 2007 13:50


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