Compile Error of OpenFOAM-2.2.0 on RedHat EL5
Hi, foamers.
I downloaded OpenFOAM-2.2.0, and tried to compile on my RedHat EL5 system. But building process for libOpenFOAM was failed with following error message; primitives/triad/triad.C:36: error: expected initializer before '<' token primitives/triad/triad.C:39: error: expected initializer before '<' token What's the problem?:confused: Any comments welcome. |
When I removed the 'triad ::' from line 36 and line 39 of triad.C, the compilation was successful.
|
I experienced similar error in Xubuntu 12.10, i did the same fix and it compiled. However I'm a little concerned about removing triad:: from lines 36 and 39, could someone more C++ involved person inspect this and make a comment? :confused:
|
hello,
Same here. Compilation work with gcc 4.5 and 4.6, not with gcc 4.7.2 Regards, olivier |
Greetings to all!
I'm not exactly an expert on C++ (there is a lot about C++ that I don't know and don't even care to understand :rolleyes:), but I believe I understand what's happening in this case. The short answer is: it doesn't matter what hack you use. You can even comment out those lines and it will still build (well, at least "libOpenFOAM.so" did). Reason: The "triad" class is only used by the "triadField" field type definition and there is no clear indication that this particular "triadField" definition is used anywhere else. But it should appear some time in the future of OpenFOAM, so beware! ;) Keep in mind that Gcc 4.5 is now the minimum version required for OpenFOAM 2.2: http://www.openfoam.org/mantisbt/view.php?id=765 In case you want to be prepared right away, if using RHEL/CentOS/SL 6, you can get Gcc 4.5 and more recent versions from the EPEL repositories: http://fedoraproject.org/wiki/EPEL - edit: apparently it's not present for RHEL/CentOS/SL 6 either Unfortunately, the EPEL repositories don't have Gcc 4.5 and above for RHEL/CentOS/SL 5 :( Nonetheless, instructions on how to build your own Gcc 4.6 for OpenFOAM can be found on a nearby thread: http://www.cfd-online.com/Forums/ope...-10-04lts.html - keep in mind that those are for Ubuntu 10.04, so you'll need to adapt accordingly. _______________ Now for the long answer:
I think this explains most of the details on this topic ;) Best regards, Bruno |
Hello, Mr.Santos.
Thank you for your detail explanation of this problem. I will setup gcc4.6 and re-compile OF2.2 on my system. |
Hi,
I have the same problem even after updating gcc to version gcc (Debian 4.6.3-14). Maybe, OF still uses the old gcc version? How could I check it? Cheers, Ilya P.S. linux: Quote:
|
Hi Ilya,
Don't forget to check if both gcc and g++ are 4.6: Code:
gcc --version Bruno |
Hi Bruno,
you're right: g++ was still 4.4. Thanks, Ilya |
So far, I tried the following gcc/g++ versions: 4.5.4, 4.6.0, 4.7.1, 4.8.1, with OF 2.2.0 and 2.2.x (from github). They all produce the same error in triad.C. OS=RocksCluster 6.1, based on CentOS 6.3, and the said compilers were compiled from sources. The funny thing is, I have compiled OF 2.2.0 a few months ago on Debian 7.0, and I had the same error at first (I saved the compiler outputs), but then somehow I succeeded... and now I don't remember how...
Can somebody plz share their success stories? Some compiler switches, maybe? |
Ooops... I installed different versions of compilers in different folders, but the OF install script still used the "standard" compiler that comes with the OS. Apparently, the desired compiler can be selected by setting the environment variables WM_CC and WM_CXX (e.g., WM_CXX=/share/apps/GCC/gcc-4.8.1/bin/g++), however, it seems that those variables are not actually used (or are they)? There are files
OpenFOAM-(version)/wmake/rules/(platform)/c and c++, where the compiler calls are hardcoded, like 'cc = gcc -m64'. When using wmakeScheduler, this eventually turns into smth like 'ssh compile_host "g++ ..."' Naturally, the environment variables are not set on the appropriate host, and /usr/bin/g++ is used. I edited the respective lines in the wmake/rules files to be 'cc = $(WM_CC) -m64', 'CC = $(WM_CXX) -m64', and it compiled succesfully. The question is, should these compiler calls be hardcoded in wmake/rules? Why not use the WM_CC and WM_CXX variables? |
Quote:
The only reason I can find so far is that using "$(WM_*)" directly in the rule files might fail in some cases, such as Unix based machines or in very old Linux distributions. Nonetheless, these variables are used in the "Allwmake" script that is located in the ThirdParty folder, so it makes sense that they should also be used in the rules' files. But don't let me stop you! Feel free to report this in the official bug tracker: http://www.openfoam.org/bugs/ |
Quote:
|
All times are GMT -4. The time now is 03:57. |