Topic: Error in Installing "engngm.C.o"

Hi,

I have problem with the installation of the latest version of the OOFRM at Git:

[ 30%] Building CXX object src/oofemlib/CMakeFiles/core.dir/emptycs.C.o
[ 31%] Building CXX object src/oofemlib/CMakeFiles/core.dir/intarray.C.o
[ 31%] Building CXX object src/oofemlib/CMakeFiles/core.dir/floatarray.C.o
[ 31%] Building CXX object src/oofemlib/CMakeFiles/core.dir/floatmatrix.C.o
[ 31%] Building CXX object src/oofemlib/CMakeFiles/core.dir/engngm.C.o
/home/mehdi/oofem.git/src/oofemlib/engngm.C: In member function ‘FILE* oofem::EngngModel::giveOutputStream()’:
/home/mehdi/oofem.git/src/oofemlib/engngm.C:1757:27: error: ‘unlink’ was not declared in this scope
                 unlink(sfn);
                           ^
/home/mehdi/oofem.git/src/oofemlib/engngm.C:1758:25: error: ‘close’ was not declared in this scope
                 close(fd);
                         ^
make[2]: *** [src/oofemlib/CMakeFiles/core.dir/engngm.C.o] Error 1
make[1]: *** [src/oofemlib/CMakeFiles/core.dir/all] Error 2
make: *** [all] Error 2

Re: Error in Installing "engngm.C.o"

Hi mehdi

What compiler are you using? There really haven't been any changes out there for quite some time, so the only thing I can think of is that the compiler you are using doesn't have access fo unistd.h, which it really should if it's on linux.


But perhaps we should question why this piece of code even exists.
As far as I can see in the code, that particular codepath in giveOutputStream() is never executed.
In  EngngModel :: Instanciate_init we always fopen a file description for the output stream, and the initialization also then relies on the fact that the stream is not NULL.
I can't see any situation where we would like to print to a temporary file that gets automatically deleted either.'

Borek, am I missing something here?

Re: Error in Installing "engngm.C.o"

I am using the Cmake 2.8.11.2 on UBUNTU 13.10

Re: Error in Installing "engngm.C.o"

Hi mehdi,

CMake is the configuration tool, the compiler will probably be GCC or Clang if you are using linux. If you haven't selected Clang manually, you are most likely using GCC
Please run

c++ --version

Re: Error in Installing "engngm.C.o"

Its C++ 4.8.1

Re: Error in Installing "engngm.C.o"

I can't find a reason to why it would complain over "unlink" and "close".
The code seems useless though, so you can probably safely remove that if-clause in EngngModel::giveOutputStream().
I'll wait for any comments from Borek before doing the same in the official git repo.

7

Re: Error in Installing "engngm.C.o"

I think we could make the implementation of giveOutputStream much simpler. In fact, when oofem is executed, the EngngModel::Instanciate_init is called first, which ensures that outputStream attribute is defined (and correspods to a file descriptor). In fact it reports an error, when the output file could not be opened. From this point of view, the giveOutputStream should only return the outputStream or report an error if not initialized.

Re: Error in Installing "engngm.C.o"

I removed that code now, leaving an error if someone ever managed to call it before initialization.

Hopefully that sorts out the compilation errors for mehdi  (though i still don't see why it wouldn't have worked).


We are still using _access/access from io.h/unistd.h as well, though I think we should avoid doing that too (race conditions). It is only used by oofeg, and i think it can be made better (just try to open the file, instead of checking access first, then trying to open). But that's a separate issue (unless there is something wrong with unistd.h, in which there should be an unlink function).