blueCFD / Core

Coordination repository for the blueCFD-Core: Issue tracking, Wiki, project webpage and miscellaneous scripts
http://bluecfd.github.io/Core
53 stars 10 forks source link

Cannot compile a simple program using wmake #132

Closed ethren closed 2 years ago

ethren commented 5 years ago

Hello, I am aware that we have to follow the following instructions: https://github.com/blueCFD/Core/wiki/Quick-notes-on-how-to-update-build#work-environment-for-bluecfd-core-2016-2-and-2017 when trying to compile a source code program. I have also went through the FAQ. But unfortunately I couldn't compile a simple program in BlueCFD 2017.

Here is my program gradTest.C:

#include "fvCFD.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

int main(int argc, char *argv[])
{
    #include "setRootCase.H"
    #include "createTime.H"

    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

    Info<< nl << "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
        << "  ClockTime = " << runTime.elapsedClockTime() << " s"
        << nl << endl;

    Info<< "End\n" << endl;

    return 0;
}
// ************************************************************************* //

Here is my setup:

$ cat Make/files
gradTest.C

EXE = ./gradTest

$ cat Make/options
EXE_INC = \
    -I$(LIB_SRC)/finiteVolume/lnInclude \
    -I$(LIB_SRC)/meshTools/lnInclude

EXE_LIBS = \
    -lfiniteVolume \
    -lmeshTools

The path of current directory and its length:

$ pwd
/x/ofuser-of5/run/programming/gradTest
$ pwd | wc -c
39

But Unfortunately, the compilation fails when I run wmake. Here is the log file: log.log

Thank you

EDIT After reading carefully the log file I found the following error: C:/MICROS~1/OpenFOAM-5.x/src/OpenFOAM/containers/Lists/PackedList/PackedListI.T.H:550:13: error: return-statement with a value, in function returning 'void' [-fpermissive] I opened the file at that location:

notepad2 /home/ofuser/blueCFD/OpenFOAM-5.x/src/OpenFOAM/containers/Lists/PackedList/PackedListI.T.H

I found the following function:

template<unsigned nBits>
inline void Foam::PackedList<nBits>::const_iterator::operator=
(
    const iteratorBase& iter
)
{
    this->list_  = iter.list_;
    this->index_ = iter.index_;

    // Avoid going past end()
    // eg, iter = iterator(list, Inf)
    if (this->index_ > this->list_->size_)
    {
        this->index_ = this->list_->size_;
    }

    return *this; // <<<<<<<< Is it a bug?
}
s1291 commented 5 years ago

I tested that with BlueCFD 2017-2: I commented the line 550 in

/home/ofuser/blueCFD/OpenFOAM-5.x/src/OpenFOAM/containers/Lists/PackedList/PackedListI.T.H
template<unsigned nBits>
inline void Foam::PackedList<nBits>::const_iterator::operator=
(
    const iteratorBase& iter
)
{
    this->list_  = iter.list_;
    this->index_ = iter.index_;

    // Avoid going past end()
    // eg, iter = iterator(list, Inf)
    if (this->index_ > this->list_->size_)
    {
        this->index_ = this->list_->size_;
    }

    // return *this; // commented this line <<< This is the line 550
}

Now I could compile your program using wmake:

wmake

But wmake exe fails! PS: The function above in OpenFOAM7 doesn't contain the line return *this

wyldckat commented 5 years ago

@s1291 Many thanks for pointing that out, that is indeed a bug in the OpenFOAM 5.x we provide in blueCFD-Core 2017-2, which has already been fixed in the most recent 5.x repository, as reported here: https://github.com/OpenFOAM/OpenFOAM-5.x/commit/bfe333ff64a8838ddff768cd717f14fad69b7b49#diff-d3623e9d3148435270bc6f13c36a205d

As for the command: wmake exe - this will not work on Windows, since this was designed for creating a stand-alone executable, namely one that does not depend on other libraries. Please use wmake without the exe option.

@ethren Did you do any updates to the MSys2 installation that is provided with blueCFD-Core 2017-2? I ask this because the build error you are getting seems to be associated to using a more recent GCC version. If you run:

gcc --version
g++ --version

It should tell you this information:

gcc.exe (Rev1, Built by MSYS2 project) 7.2.0
...
G__~1.EXE (Rev1, Built by MSYS2 project) 7.2.0
wyldckat commented 5 years ago

@ethren I was intrigued about this and have tested building your application and it builds perfectly fine with blueCFD-Core 2017-2.

Please provide more details about your installation, because it is not using the standard installation which we provide.

ethren commented 5 years ago

@wyldckat Sorry, I forgot to mention that I am using a more recent version of GCC (version 9.2):

$ gcc --version
gcc.exe (Rev2, Built by MSYS2 project) 9.2.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ g++ --version
G__~1.EXE (Rev2, Built by MSYS2 project) 9.2.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

But Now it works perfectly after removing that line from the file.

s1291 commented 5 years ago

@wyldckat Thank you for the info!