OpenSceneGraph icon indicating copy to clipboard operation
OpenSceneGraph copied to clipboard

Make under Windows fails

Open McLP2 opened this issue 5 years ago • 3 comments

Hey there! I just tried to compile the 3.6.5 release commit without success. After I ran cmake -G "MinGW Makefiles" ., mingw32-make fails at FileUtils.cpp with the following error:

...\OpenSceneGraph\src\osgDB\FileUtils.cpp: In function 'bool osgDB::makeDirectory(const string&)':
...\OpenSceneGraph\src\osgDB\FileUtils.cpp:161:19: error: aggregate 'osgDB::makeDirectory(const string&)::stat64 stbuf' has incomplete type and cannot be defined
  161 |     struct stat64 stbuf;
      |                   ^~~~~
...\OpenSceneGraph\src\osgDB\FileUtils.cpp:165:38: error: invalid use of incomplete type 'struct osgDB::makeDirectory(const string&)::stat64'
  165 |     if( stat64( path.c_str(), &stbuf ) == 0 )
      |                                      ^
...\OpenSceneGraph\src\osgDB\FileUtils.cpp:161:12: note: forward declaration of 'struct osgDB::makeDirectory(const string&)::stat64'
  161 |     struct stat64 stbuf;
      |            ^~~~~~
...\OpenSceneGraph\src\osgDB\FileUtils.cpp:186:41: error: invalid use of incomplete type 'struct osgDB::makeDirectory(const string&)::stat64'
  186 |         if( stat64( dir.c_str(), &stbuf ) < 0 )
      |                                         ^
...\OpenSceneGraph\src\osgDB\FileUtils.cpp:161:12: note: forward declaration of 'struct osgDB::makeDirectory(const string&)::stat64'
  161 |     struct stat64 stbuf;
      |            ^~~~~~
...\OpenSceneGraph\src\osgDB\FileUtils.cpp: In function 'osgDB::FileType osgDB::fileType(const string&)':
...\OpenSceneGraph\src\osgDB\FileUtils.cpp:311:19: error: aggregate 'osgDB::fileType(const string&)::stat64 fileStat' has incomplete type and cannot be defined
  311 |     struct stat64 fileStat;
      |                   ^~~~~~~~
...\OpenSceneGraph\src\osgDB\FileUtils.cpp:315:44: error: invalid use of incomplete type 'struct osgDB::fileType(const string&)::stat64'
  315 |     if ( stat64(filename.c_str(), &fileStat) != 0 )
      |                                            ^
...\OpenSceneGraph\src\osgDB\FileUtils.cpp:311:12: note: forward declaration of 'struct osgDB::fileType(const string&)::stat64'
  311 |     struct stat64 fileStat;
      |            ^~~~~~

This seems to be a relatively old issue, as I found the same error in a Mail thread from 2004 but as I am relatively new to C++, I am not sure how to apply their solution (as it does not seem appropreate having to change the source code, just to use make instead of visual studio) or if even a fix inside some configuration might be possible.

McLP2 avatar Nov 14 '20 13:11 McLP2

Could you try the OSG-3.6 branch to see if fixes applied to it since 3.6.5 fix the issue.

On Sat, 14 Nov 2020 at 13:58, McLP [email protected] wrote:

Hey there! I just tried to compile the 3.6.5 release commit without success. After I ran cmake -G "MinGW Makefiles" ., mingw32-make fails at FileUtils.cpp with the following error:

...\OpenSceneGraph\src\osgDB\FileUtils.cpp: In function 'bool osgDB::makeDirectory(const string&)': ...\OpenSceneGraph\src\osgDB\FileUtils.cpp:161:19: error: aggregate 'osgDB::makeDirectory(const string&)::stat64 stbuf' has incomplete type and cannot be defined 161 | struct stat64 stbuf; | ^~~~~ ...\OpenSceneGraph\src\osgDB\FileUtils.cpp:165:38: error: invalid use of incomplete type 'struct osgDB::makeDirectory(const string&)::stat64' 165 | if( stat64( path.c_str(), &stbuf ) == 0 ) | ^ ...\OpenSceneGraph\src\osgDB\FileUtils.cpp:161:12: note: forward declaration of 'struct osgDB::makeDirectory(const string&)::stat64' 161 | struct stat64 stbuf; | ^~~~~~ ...\OpenSceneGraph\src\osgDB\FileUtils.cpp:186:41: error: invalid use of incomplete type 'struct osgDB::makeDirectory(const string&)::stat64' 186 | if( stat64( dir.c_str(), &stbuf ) < 0 ) | ^ ...\OpenSceneGraph\src\osgDB\FileUtils.cpp:161:12: note: forward declaration of 'struct osgDB::makeDirectory(const string&)::stat64' 161 | struct stat64 stbuf; | ^~~~~~ ...\OpenSceneGraph\src\osgDB\FileUtils.cpp: In function 'osgDB::FileType osgDB::fileType(const string&)': ...\OpenSceneGraph\src\osgDB\FileUtils.cpp:311:19: error: aggregate 'osgDB::fileType(const string&)::stat64 fileStat' has incomplete type and cannot be defined 311 | struct stat64 fileStat; | ^~~~~~~~ ...\OpenSceneGraph\src\osgDB\FileUtils.cpp:315:44: error: invalid use of incomplete type 'struct osgDB::fileType(const string&)::stat64' 315 | if ( stat64(filename.c_str(), &fileStat) != 0 ) | ^ ...\OpenSceneGraph\src\osgDB\FileUtils.cpp:311:12: note: forward declaration of 'struct osgDB::fileType(const string&)::stat64' 311 | struct stat64 fileStat; | ^~~~~~

This seems to be a relatively old issue, as I found the same error in a Mail thread from 2004 https://marc.info/?l=mingw-users&m=109680871711163 but as I am relatively new to C++, I am not sure how to apply their solution (as it does not seem appropreate having to change the source code, just to use make instead of visual studio) or if even a fix inside some configuration might be possible.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/openscenegraph/OpenSceneGraph/issues/997, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKEGUD7F6PDYLXLGJT5NULSP2EJNANCNFSM4TVR3WIA .

robertosfield avatar Nov 14 '20 19:11 robertosfield

Tried OpenSceneGraph-3.6 and master branches, still getting the same error.

McLP2 avatar Nov 19 '20 00:11 McLP2

Mingw-w64 has _stat64 structure and function is called _stat64. Maybe OSG expects POSIX OS when compiling with GCC and is using stat64? On Mingw, best would probably be just using regular stat and defining _FILE_OFFSET_BITS=64, this makes "stat" being define for _stat64. See msys64\mingw64\x86_64-w64-mingw32\include\sys\stat.h.

jardik avatar Mar 05 '21 22:03 jardik