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

Automated scripts for building gcc 4.4.x and 4.5.x for using with OpenFOAM 1.7 series

Register Blogs Community New Posts Updated Threads Search

Rating: 3 votes, 3.67 average.

Automated scripts for building gcc 4.4.x and 4.5.x for using with OpenFOAM 1.7 series

Posted September 26, 2010 at 11:35 by wyldckat
Updated April 21, 2011 at 22:08 by wyldckat (Added 4th version of the scripts)
Tags gcc, openfoam

This blog post is meant to centralize my efforts for providing gcc build scripts to the OpenFOAM community. It provides build scripts for gcc 4.3.x, 4.4.x and 4.5.x series.

NOTE: If you don't have internet on the computer where you want to run this script, you can still run these scripts, because they will provide you with instructions on which files to download and where to place them!

These scripts are based on the scripts provided with the patches for cross-compiling OpenFOAM 1.7.0 in Linux for Windows, available in this wiki page. These new attached scripts have already been partially integrated into the nucleation project.

The scripts inside the attached build-gcc*.tar.gz files are build-gcc44 and build-gcc45 (build-gcc43 starting with version build-gcc_v4), which will take care of downloading and building binutils and gcc and some of it's direct dependencies (namely gmp, mpfr and mpc for 4.5.x). Keep in mind that these scripts will not take care of all of the necessary steps to get your system ready for building OpenFOAM!
NOTE: The v4 version is the latest version and has some improvements. Nonetheless, I didn't fully test it yet, but it should work as intended

These scripts are hard coded to build gcc 4.4.4 and 4.5.0 (4.5.1 in v2 and v3 - also added 4.3.3 on v4). For more information on how to update those scripts, the instructions provided for the original scripts are suitable - see section "Building mingw cross-compilers" of the previously mentioned wiki page. But if you don't feel like reading instructions, simply open the scripts and change them to your heart's content

These scripts have been tested successfully in Ubuntu 9.10 x86_64, building gcc 4.4.4, 4.5.0 and 4.5.1; also some tests in Ubuntu 10.10 x86_64 with gcc 4.3.3.

The following steps are needed for this to work (might not be complete, since I haven't tested in systems other than Ubuntu):
  1. Check yourself and/or request your system administrator to install these packages (the names are from Debian, so you'll need to find similar names for your system):
    • flex - it should include the binaries flex and flex++, as well as FlexLexer.h.
    • libreadline5-dev - this has the readline library and respective header files.
    • texinfo - this is required during building gcc for documentation... but I can't remember what were the needed files
    • byacc and bison - these are two applications, one needed for building gcc, the other for building OpenFOAM.
  2. Get OpenFOAM 1.7.0/1 or 1.7.x into your system, by following the instructions at www.openfoam.com. Keep in mind that only starting from 1.7.1 and 1.7.x will work properly with gcc 4.5.x!
  3. After getting OpenFOAM's bashrc sourced (search for «source the etc/bashrc» in the project's installation page) into the working environment, edit the file "$WM_PROJECT_DIR/etc/settings.sh" and change the following lines:
    • For gcc 4.4.4 - change:
      Code:
      gcc_version=gcc-4.4.3
      to:
      Code:
      gcc_version=gcc-4.4.4
    • For gcc 4.5.1 - change:
      Code:
      gcc_version=gcc-4.4.3
      to:
      Code:
      gcc_version=gcc-4.5.1
      (Or 4.5.0 )
    • For gcc 4.3.3 ... follow the same idea
    • For either one - change:
      Code:
      : ${compilerInstall:=system}
      to:
      Code:
      : ${compilerInstall:=OpenFOAM}
  4. Source the bashrc file once more, or start a new terminal and source it again.
  5. Download the attached build-gcc_v4.tar.gz (build-gcc_v3.tar.gz if things don't go well) and unpack it in the "$WM_THIRD_PARTY_DIR".
  6. Now run:
    Code:
    cd $WM_THIRD_PARTY_DIR
    ./build-gcc44
    or
    Code:
    cd $WM_THIRD_PARTY_DIR
    ./build-gcc45
    It will download the files mentioned before (binutils, gcc, gmp, mpfr and mpc) and build them in the proper order.
  7. Whenever there is an error, it will tell you in which log file the error is listed. Check it for the things it says it needs or is missing and try to get them. If you can't figure it out, compress and attach the compressed relevant log file.
    If you can get them, then run build-gcc44 or build-gcc45 again.
  8. When you finally have gcc fully built, then you can move on to building OpenFOAM...
    If you use the scripts from build-gcc.tar.gz, you might also want to nuke first the build folder used for building gcc and binutils, which is whoopingly over 1.5GB in disk space! To remove that build folder, run this to check if the folder seems legit:
    Code:
    echo $WM_THIRD_PARTY_DIR/platforms/build-$WM_ARCH$WM_COMPILER
    If so, run:
    Code:
    rm -rf $WM_THIRD_PARTY_DIR/platforms/build-$WM_ARCH$WM_COMPILER
    If you use the build-gcc_v*.tar.gz versions, this is done automatically for you, including removing the source folders that are no longer needed after building; this feature can be changed in the User settings section inside the scripts!

Now, keep in mind that these steps will only get as far as building OpenFOAM and OpenMPI. And this is assuming that you can get the remaining necessary packages that I'm not giving instructions about. If you need a software package that you can't request to be installed in the system, then you will have to download the source code and build it yourself... usually with a group of commands like this:
Code:
./config  --prefix=/the/folder/where/to/install
make
make install
As for ParaView, it requires a larger heap load of packages to be installed and/or built (for example, it's very likely that all would have to be built in RHEL 3/4 ) which is too much work to even bother, or so I believe The best option would be to simply get the ready to use version from www.paraview.org and follow the instructions I've already detailed here: Using the official pre-built ParaView 3.8.0 version with OpenFOAM...


Additional notes about these scripts:
  • They do not take into account if the download of the necessary packages fails during download. In case one or more downloads do fail, try finding another mirror, edit the relevant script and update the relevant URL. You will also have to remove manually the failed file download, which is located in the folder $WM_THIRD_PARTY/download.
  • Building with multilib is disabled by default in these scripts. The basic multilib option allows for gcc built in a 64bit system to build for both 32 and 64bit architectures. The advanced option allows to target various others architectures like ARM. This options is disabled because it will require that the system's multilib packages are also installed, which I believe is a rare necessity for the usual OpenFOAM user.
    If you do need the multilib option, simply search for the "--disable-multilib" options for configure in the build-gcc4? scripts and remove them.
  • These scripts are meant to solely build for your local system. So it should work fine for other architectures other than i?68 and x86_64, but this has not been tested.
  • PPL and CLooG-PPL are not built with these scripts, because I don't believe that OpenFOAM will benefit from these libraries. But if someone does report that they are useful for OpenFOAM, I will integrate them into the scripts.
  • The build-gcc_v2.tar.gz version should now take care of dealing with some additional clean up at the end, as well as be more helpful when things don't build at first try, but allowing you to sort-of continue were things were left off.
  • The version build-gcc_v3.tar.gz has resulted from experimentation with CentOS 3.3, 3.9, 4.0 and 4.8. The CentOS 3.x series requires an updated GNU make which I've added to the script (make version 3.82 to be exact). If you want to use your system's make, find the variable BUILD_MAKE (around line 66) and set it to 0:
    Code:
    BUILD_MAKE=0
    Notice that there is no space and it's meant to be that way!
  • Another thing about the v3 version: I disabled "help information" for building binutils, because it requires to install texinfo. In other words, man won't work for the applications built in the custom binutils.
  • I added the capability to build gcc 4.3.3 to v4 for usage with older OpenFOAM versions. For example, as seen here: Blast from the past: installing OpenFOAM 1.5 in modern Linux boxes

Side note: I've tried creating a beefed up version of these scripts for also building an updated glibc (theoretically useful for older systems), but things didn't work totally as expected... More here: Trying to include glibc in my build-gcc scripts...
NOTE to this "Side note": This glibc thingy I tried seems unnecessary, after building OpenFOAM 1.7.1 in CentOS 3.3, 3.9, 4.0 and 4.8 with the v3 version of these scripts, without any problems!

Good luck!
Bruno
Attached Files
File Type: gz build-gcc.tar.gz (4.6 KB, 509 views)
File Type: gz build-gcc_v2.tar.gz (5.2 KB, 338 views)
File Type: gz build-gcc_v3.tar.gz (5.6 KB, 351 views)
File Type: gz build-gcc_v4.tar.gz (5.7 KB, 620 views)
« Prev     Main     Next »
Total Comments 14

Comments

  1. Old Comment
    Hello Bruno,

    How do you make scotch decomposition method work? The log file indicate that the libscotch.so was not copy to appropriate folder. So I copy them over after finish installation, but metis/scotch still not working. Thank you for your time and help.

    Nam
    ------------------
    have OPENMPI shared library
    ========================================
    Build Scotch decomposition library

    have scotch shared libraries in scotch_5.1/lib
    + cp scotch_5.1/lib/libscotch.so scotch_5.1/lib/libscotcherrexit.so /home/hnguyen/OpenFOAM/OpenFOAM-1.7.1/lib/linux64GccDPOpt
    cp: target `/home/hnguyen/OpenFOAM/OpenFOAM-1.7.1/lib/linux64GccDPOpt' is not a directory
    --------------------------------------------
    permalink
    Posted March 3, 2011 at 19:46 by namCFD namCFD is offline
  2. Old Comment
    Hi Bruno,

    I figured it out. All I had to do was to type 'wmake libso' in the src.

    Thanks,
    Nam
    permalink
    Posted March 4, 2011 at 03:01 by namCFD namCFD is offline
  3. Old Comment
    Hi Bruno,

    I am trying to install OpenFOAM 1.7.1 on Redhat 5 linux. It has Gcc4.1.x. Would the steps given above of ubuntu linux will work in my case. Are the steps of checking the flex, flex++, FlexLexer.h., libreadline5-dev, texinfo, byacc and bison would be the same as given above. I am a new user of linux and know only basic commands and operations. Could you please help me or please give me the systematic steps to install OF1.7.1 on RHEL5 Linux.

    Thanks in advance

    MLD
    permalink
    Posted April 13, 2011 at 01:33 by run_cfd run_cfd is offline
  4. Old Comment
    Hi MLD,

    I suggest that you first try CentFOAM: http://sourceforge.net/apps/mediawik...itle=Main_Page

    Best regards and good luck!
    Bruno
    permalink
    Posted April 13, 2011 at 08:25 by wyldckat wyldckat is offline
  5. Old Comment
    Hi Bruno,

    Thanks for our quick response.

    I have got instructions to go for OF1.7.1. For the time being I agree to go for CentFOAM from my side, if that works well then I can convince them.
    I am trying to follow the steps given in the link you provided in last post, incase of any problem i will write you again. In the mean time, if you don't mind, can I request you to take some time in writing the steps from downloading to installations along with the commands, I am a new user of Linux. Please help me out, I badly needed it.

    Thanks and Best wishes,

    MLD
    permalink
    Posted April 14, 2011 at 01:30 by run_cfd run_cfd is offline
  6. Old Comment
    Hello Bruno,

    In the mean time the CentFOAM was being downloaded, I tried to install OpenFOAM-1.7.1 according as the procedures given on "http://www.openfoam.com/download/source.php". For building the gcc44, I followed the steps (1-8) you gave in this blog. But I got stuck on the step 6 i.e. executing "./build-gcc44". It gave the following Error message:

    [root@ANSYS etc]# cd $WM_THIRD_PARTY_DIR
    [root@ANSYS ~]# ./build-gcc44
    ./build-gcc44: line 39: wmakeCheckPwd: command not found
    Error: Current directory is not $WM_THIRD_PARTY_DIR
    The environment variables are inconsistent with the installation.
    Check the OpenFOAM entries in your dot-files and source them.
    [root@ANSYS ~]#

    Please suggest the possible reason for this error.

    I have few more doubts in previous steps.

    1. As I am installing in the root, my path for installation is "/root/OpenFOAM/OpenFOAM-1.7.1" , whereas the steps involved on the OpenFOAM website and in your blog uses the path "$HOME/OpenFOAM/OpenFOAM-1.7.1". I guess the using both the paths directs to the same folder. Is it So? Anyway I checked using both the paths but got the same error.

    2. When I sourced the bashrc using the step given on OpenFOAM website, i.e. adding the line ". $HOME/OpenFOAM/OpenFOAM-1.7.1/etc/bashrc" at the end of bashrc file and executing the command ". $HOME/.bashrc” the result was nothing. see below the extracts from the terminal:

    [root@ANSYS etc]# cd $HOME/OpenFOAM/OpenFOAM-1.7.1/etc
    [root@ANSYS etc]# . $HOME/.bashrc
    [root@ANSYS etc]#

    How to check whether the execution of this step was correct?
    When I did the foamSystemCheck in the bin it was passed: see below:
    [root@ANSYS bin]# ./foamSystemCheck

    Checking basic system...
    -----------------------------------------------------------------------
    Shell: /bin/bash
    Host: ANSYS
    OS: Linux version 2.6.18-128.el5
    User: root


    System check: PASS
    ==================
    Continue OpenFOAM installation.

    [root@ANSYS bin]#


    3. As in step 6 where this directory "$WM_THIRD_PARTY_DIR" exists actually. or where exactly the build-gcc_v3.tar.gz has to be extracted. I just typed the commands you gave in this procedure.


    Please rescue me out and suggest What mistake i am doing or is there anything wrong with my system resources. I am going to rut out of the deadline, I really need it.
    I will try to install CentFOAM, once I will get the files downloaded. I will follow the steps on the lik suggested by you.

    Thanks in advance,

    MLD
    permalink
    Posted April 14, 2011 at 08:39 by run_cfd run_cfd is offline
  7. Old Comment
    Hi MLD,

    OK, first of all, do not build OpenFOAM directly as root, specially if you still don't know your way around in Linux. I say this because building as root can potentially lead to hazardous mass deletions of the whole system, or unintentionally overwriting system critical files!

    So, follow these instructions to the letter: CentFOAM Manual install


    Secondly, you can run the environment sourcing command directly on the terminal:
    Code:
    . $HOME/OpenFOAM/OpenFOAM-1.7.1/etc/bashrc
    You can also use:
    Code:
    source $HOME/OpenFOAM/OpenFOAM-1.7.1/etc/bashrc
    (This is why I said sourcing command )

    To know if this command has worked, try running this command:
    Code:
    echo $WM_THIRD_PARTY_DIR
    ls $WM_THIRD_PARTY_DIR
    It should show you where it expects for the ThirdParty folder to be and what exists in that folder, if it already exists. If it shows your local folder, then something went wrong.

    Sourcing the "~/.bashrc" file on your local environment sometimes doesn't work. To be 100% certain that this file is sourced is to start a new terminal/console.

    Using one of my build-gcc4x scripts is only necessary if for some reason CentFOAM's ready to use packages don't work!

    Now, when you finally have OpenFOAM working on your own personal area, then you can safely copy or move your OpenFOAM installation to /opt/OpenFOAM or something like that. It will require some additional tuning, but we'll see this tomorrow after you got it running on your area.

    Best regards and good luck!
    Bruno
    permalink
    Posted April 14, 2011 at 19:12 by wyldckat wyldckat is offline
  8. Old Comment
    Hello Bruno,

    Greetings!!!

    Now I succeeded to install (CentFOAM) OpenFoam-1.7.1. available on the link http://sourceforge.net/apps/mediawik...itle=Main_Page. Thanks a lot for your great help!!

    I tried running a case of icoFOAM/cavity, it's working. But I was not able to open paraFoam. When I type the command "paraFoam" in case directory terminal. it gives following error.

    ---------
    [root@sunserver cavity]# paraFoam
    created temporary 'cavity.OpenFOAM'
    /root/OpenFOAM/OpenFOAM-1.7.1/bin/paraFoam: line 139: paraview: command not found
    [root@sunserver cavity]#
    ---------

    I saw one of your thread about same problem. I followed the steps of adding few lines in settings.sh. but didn't worked.
    What may be the problem? Can you suggest any other alternative.

    Thanks and Best wishes,

    MLD
    permalink
    Posted April 19, 2011 at 06:58 by run_cfd run_cfd is offline
  9. Old Comment
    Hi MLD,

    See this blog post of mine: Related issues to ParaView with OpenFOAM - Fixes and solutions
    There you will find various possible solutions, although at least one of these should work:

    Best regards,
    Bruno
    permalink
    Posted April 19, 2011 at 21:47 by wyldckat wyldckat is offline
  10. Old Comment

    OpenFOAM running problems with paraView

    Quote:
    Originally Posted by wyldckat View Comment
    Hi MLD,

    See this blog post of mine: Related issues to ParaView with OpenFOAM - Fixes and solutions
    There you will find various possible solutions, although at least one of these should work:

    Best regards,
    Bruno



    Hi Bruno,

    Greetings!!!

    I succeeded to open paraFoam according as the steps you gave in last post. But now my OpenFOAM stopped working. The icoFoam command is not working now. It gives the following error.
    ................
    [root@sunserver cavity]# icoFoam /root/OpenFOAM/root-1.7.1/run/tutorials/incompressible/icoFoam/cavity
    icoFoam: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.9' not found (required by icoFoam)
    icoFoam: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.11' not found (required by icoFoam)
    icoFoam: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.11' not found (required by /root/OpenFOAM/OpenFOAM-1.7.1/lib/linux64GccDPOpt/libfiniteVolume.so)


    ................

    I saw one of your blog about the same problem "using-official-pre-built-paraview-3-8-0-version-openfoam.html " explained to sahm. I followed the steps given there and I found that the line "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ParaView_DIR/lib/paraview-$ParaView_MAJOR" already present in the file "$WM_PROJECT_DIR/etc/apps/paraview3/bashrc". And the line "export LD_LIBRARY_PATH=/lib64:/usr/lib64:$LD_LIBRARY_PATH" also already present on the path "$HOME/.bashrc". But still I am getting the same error. What may be the problem?

    Thanks for your great helps

    Best Wishes
    -MLD
    permalink
    Posted April 20, 2011 at 08:10 by run_cfd run_cfd is offline
  11. Old Comment

    So many possibilities... so many solutions :)

    Hi MLD,

    OK, the problem is this: with CentFOAM's OpenFOAM version, it comes with it's own "libstdc++.so.6". By following my instructions, you overrided the normal paths for CentFOAM, which lead to this problem.

    So, one solution should be this:
    1. Remove the line "export LD_LIBRARY_PATH=/lib64:/usr/lib64:$LD_LIBRARY_PATH" from "$HOME/.bashrc".
    2. Edit the file "$WM_PROJECT_DIR/etc/bashrc" and find the line that says:
      Code:
      paraview3=`$WM_PROJECT_DIR/bin/foamEtcFile apps/paraview3/bashrc` \
          && _foamSource $paraview3
      unset paraview3
      Now comment it, like this:
      Code:
      #paraview3=`$WM_PROJECT_DIR/bin/foamEtcFile apps/paraview3/bashrc` \
      #    && _foamSource $paraview3
      #unset paraview3
      Save and close the file.
    3. Next, edit the script "$WM_PROJECT_DIR/bin/paraFoam". Go to the line right after the first block of comments and add the lines that were commented in "$WM_PROJECT_DIR/etc/bashrc", although with a little tweak. With the tweak, it should look something like this (bold is the new addition):
      Code:
      # Description
      #     start paraview with the OpenFOAM libraries
      #
      #------------------------------------------------------------------------------
      paraview3=`$WM_PROJECT_DIR/bin/foamEtcFile apps/paraview3/bashrc` \
          && source $paraview3
      unset paraview3
      
      usage() {
      Save and close.
    4. Start a new terminal. Try and see if things now work as intended!
    Best regards and good luck!
    Bruno
    permalink
    Posted April 21, 2011 at 18:46 by wyldckat wyldckat is offline
  12. Old Comment
    Hi Bruno,

    Greeting!!!

    wow!!! Worked great!!! Now my OpenFoam and paraFoam both work together. you are too good!!

    Thanks a lot for all your help!

    Best Wishes,

    MLD
    permalink
    Posted April 22, 2011 at 09:46 by run_cfd run_cfd is offline
  13. Old Comment
    Hi Bruno,

    Greetings!!!

    I am trying to solve a problem which involves a compressible flow in a porous media with heat transfer effects on my OF-171 binery installation.
    Now I feel a need of compiling the OpenFoam1.7.1 source code so that I could have some control on problem solution. Could you please help me in getting and compiling the same.

    With Best Wishes,

    MLD
    permalink
    Posted May 24, 2011 at 02:58 by run_cfd run_cfd is offline
  14. Old Comment
    Hi MLD,

    Uhm... simply follow the official instructions? http://www.openfoam.com/download/source.php

    The other possibility is to roughly follow the instructions I recently posted for Fedora 15 + OpenFOAM 1.7.x: http://www.cfd-online.com/Forums/ope...tml#post308762

    Best regards,
    Bruno
    permalink
    Posted May 27, 2011 at 16:10 by wyldckat wyldckat is offline
 

All times are GMT -4. The time now is 01:05.