CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Installation (http://www.cfd-online.com/Forums/openfoam-installation/)
-   -   Compilation error with OpenFOAM 2.1.x (http://www.cfd-online.com/Forums/openfoam-installation/99932-compilation-error-openfoam-2-1-x.html)

Martin_ April 16, 2012 10:58

Compilation error with OpenFOAM 2.1.x
 
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

wyldckat April 16, 2012 16:25

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

Martin_ April 16, 2012 16:45

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

wyldckat April 16, 2012 17:07

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 :rolleyes:

AlmostSurelyRob April 17, 2012 09:26

@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?

wyldckat April 19, 2012 19:47

2 Attachment(s)
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

AlmostSurelyRob April 21, 2012 09:54

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.

wyldckat April 21, 2012 11:35

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

AlmostSurelyRob April 21, 2012 13:01

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.

Martin_ April 22, 2012 20:06

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

AlmostSurelyRob May 1, 2012 13:04

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.

wyldckat May 2, 2012 07:23

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


wizzrobe May 3, 2012 16:58

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.

fisichel October 23, 2012 22:53

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

wyldckat October 24, 2012 04:32

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

fisichel October 25, 2012 21:34

Stuck on step 3
 
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

wyldckat October 27, 2012 12:43

Hi Chris,

Quote:

Originally Posted by fisichel (Post 388586)
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

fisichel October 28, 2012 21:42

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 November 6, 2012 20:08

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

fisichel December 23, 2012 05:33

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


All times are GMT -4. The time now is 09:15.