NREL / SOWFA

Other
138 stars 112 forks source link

Compilt error on ubuntu 15.04 with gcc-4.9 and gcc-6.1.0 #24

Open Bing008 opened 6 years ago

Bing008 commented 6 years ago

Hi ,I have compiled openfoam-2.4.x and openfast-dev on my ubuntu 15.04. But I got some error when I compiled SOWFA. setp1 ./Allwclean Successful setp2 .Allwmake error message as blow: Make/linux64GccDPOpt/ABLSolver.o:(.data.rel.ro._ZTVN4Foam8OPstreamE[_ZTVN4Foam8OPstreamE]+0x80): undefined reference toFoam::UOPstream::writeQuoted(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, bool)' collect2: error: ld returned 1 exit status /home/bing/OpenFOAM/OpenFOAM-2.4.x/wmake/Makefile:149: recipe for target '/home/bing/OpenFOAM/bing-2.4.x/platforms/linux64GccDPOpt/bin/ABLSolver' failed make: *** [/home/bing/OpenFOAM/bing-2.4.x/platforms/linux64GccDPOpt/bin/ABLSolver] Error 1`

The above error message show that the ABLSolver compilation appear error, but the ABLTerrainSolver was successfully compiled.

In addition to this,the windPlantSolver appear error too.the error mesaage are as blow: windPlantSolver.C:59:43: fatal error: horizontalAxisWindTurbinesALM.H: No such file or directory #include "horizontalAxisWindTurbinesALM.H" windPlantSolver.dep:718: recipe for target 'Make/linux64GccDPOpt/windPlantSolver.o' failed

So could you give me some advice? and I wanna konw which os version and gcc version when your researchers compiled SOWFA. Thanks

Bartdoekemeijer commented 6 years ago

Hello,

First of all, according to the OpenFOAM compatibility matrix, you should use GCC 4.X or 5.X for the installation of OpenFOAM 2.4.x. This webpage mentions that GCC 6.1.0 should not be compatible for the installation of OF 2.4.x, and that probably explains the first error you are getting. Namely, it seems like you are missing certain OpenFOAM functionality, hinting towards that your installation of OpenFOAM 2.4.x is not valid.

undefined reference toFoam::UOPstream::writeQuoted(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, bool)'collect2: error: ld returned 1 exit

Secondly, the "horizontalAxisWindTurbineALM.H" error is a common error. I am guessing your folder structure is something like:

$HOME/OpenFOAM/username-2.4.x/SOWFA/applications/... $HOME/OpenFOAM/username-2.4.x/SOWFA/src/...

If that is the case, your solution lies in taking out the extra "SOWFA" folder layer. You can do this by, mv $WM_PROJECT_USER_DIR/SOWFA/* $WM_PROJECT_USER_DIR/.

A different solution to the same problem is described in Pull Request #16.

Finally, I recommend you compile SOWFA without (Open)FAST first, before anything. Good luck.

pablo-benito commented 6 years ago

Hi smilke,

As Bart said, in order to properly build OpenFOAM 2.4 you need to use gcc < 5 otherwise you need to patch OpenFOAM itself (https://github.com/pablo-benito/OpenFOAM-2.4.x)

The issue that you see is telling you that the function writeQuoted is not found in the core of the OpenFOAM that you are using.. but the error appears during the linking phase, so that means that the function itself exists in the core code (actually inside ./OpenFOAM/db/IOstreams/Pstreams/UOPstream.C), doesn't have the expected 'binary signature' in the library (libOpenFOAM.so).

As you see, one of the parameters of that function is 'std::__cxx11::basic_strings' This means that ABLSolver.o was compiled using the 2011 C++ standard, but the core probably did not. In earlier versions of the standard c++, std::string inside the code were mapped inside the .o/.so files just as std::string, but now you end up with things like std::__cxx11. Then when you try to compile against that library using a different standard, the signature doesn't match exactly and you get the error that you see.

so.. could be possible that you compiled OpenFOAM with gcc 4 (where the default c++ standard was something pre-2011) and then you tried to build SOWFA with gcc 6 ? (on version 6, the default standard is c++2011 or c++2014) If that's the case, just recompile SOWFA with gcc 4..

If you are curious about the signature of that function inside the OpenFOAM core library you can actually read it with:

nm -AC ${FOAM_LIBBIN}/libOpenFOAM.so | grep 'UOPstream::writeQuoted'

If OpenFOAM is compiled with a 2011 standard you will see: Foam::UOPstream::writeQuoted(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)

but with a previous standard the signature will be: Foam::UOPstream::writeQuoted(std::string const&, bool)

GerFernandes commented 6 years ago

Just a note: According to the OpenFOAM (foundation)'s website, Ubuntu 15.04 is no longer "current" (see also here). Since you are in the installing & compiling stage, maybe this is something to think about. All the best!