Dear all,

hunting around for a while with plain VMware images and rebuilding everything constantly I drilled down to the cause of the problem which I reported earlier which turns out to be twofold:

1) osgDB::fopen is opening a file (fopen) in the scope of osgDB dll and various plugins and also osgWidgets close files via the ANSI-C fclose (in the scope of the plugin) - this works fine for most OSes just not Windows and OS X. My fix is to inline the proxied version of fopen because otherwise osgDB needs to provide the whole set of C file operation functions.

2) Visual Studio 2008 is defaulting to link to the lowest common denominator of the runtime which is something like 9.0.22*** - however all known versions of VS 2008 (with or without SP or FeaturePack) ship with a redistributable with version 9.0.30*** - thus welcome to SxS hell. The introduced defines should work on both VS 2008 with and without SP1 (there was a bug ignoring the catch all version _VC_LIBS_) - it should have only an effect in VS 2005 and 2008 - maybe there should be an CMake option() around the defines as I could imagine some people want this exact behaviour.

Please test and comment (the patch is against the 2.8 branch but should be easy to port into the trunk)

Cheers,
Hartmut

--
Dr. Hartmut Seichter
PhD (HKU), Dipl.-Ing. (BUW)
Post-Doctoral Fellow, HIT Lab NZ
+64 3 364 3078
http://www.hitlabnz.org/people/hse25




Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt      (revision 10140)
+++ CMakeLists.txt      (working copy)
@@ -186,6 +186,8 @@
         # More MSVC specific compilation flags
         ADD_DEFINITIONS(-D_SCL_SECURE_NO_WARNINGS)
         ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE)
+               ADD_DEFINITIONS(-D_BIND_TO_CURRENT_CRT_VERSION=1)
+               ADD_DEFINITIONS(-D_BIND_TO_CURRENT_MFC_VERSION=1)               
     ENDIF(MSVC)
 
     #needed for net plugin
Index: include/osgDB/FileUtils
===================================================================
--- include/osgDB/FileUtils     (revision 10140)
+++ include/osgDB/FileUtils     (working copy)
@@ -14,6 +14,7 @@
 #ifndef OSGDB_FILEUTILS
 #define OSGDB_FILEUTILS 1
 
+#include <osg/Config>
 #include <osgDB/Registry>
 
 #include <vector>
@@ -38,8 +39,17 @@
 
 // Overload of the standard fopen function. If OSG_USE_UTF8_FILENAME is 
defined,
 // filename will be expanded from UTF8 to UTF16 and _wfopen will be called.
-extern OSGDB_EXPORT FILE* fopen(const char* filename, const char* mode);
+//extern OSGDB_EXPORT FILE* fopen(const char* filename, const char* mode);
 
+inline FILE* fopen(const char* filename, const char* mode)
+{
+#ifdef OSG_USE_UTF8_FILENAME
+       return ::_wfopen(convertUTF8toUTF16(filename).c_str(), 
convertUTF8toUTF16(mode).c_str());
+#else
+       return ::fopen(filename, mode);
+#endif
+}
+
 // Make a new directory.  Returns true if directory exists or was created.
 extern OSGDB_EXPORT bool makeDirectory( const std::string &directoryPath );
 
Index: src/osgDB/FileUtils.cpp
===================================================================
--- src/osgDB/FileUtils.cpp     (revision 10140)
+++ src/osgDB/FileUtils.cpp     (working copy)
@@ -98,15 +98,6 @@
 #endif
 }
 
-FILE* osgDB::fopen(const char* filename, const char* mode)
-{
-#ifdef OSG_USE_UTF8_FILENAME
-    return ::_wfopen(convertUTF8toUTF16(filename).c_str(), 
convertUTF8toUTF16(mode).c_str());
-#else
-    return ::fopen(filename, mode);
-#endif
-}
-
 bool osgDB::makeDirectory( const std::string &path )
 {
     if (path.empty())
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to