Robert,

 

I have come across an issue with the current implementation of 
osgDB::appendPlatformSpecificLibraryFilePaths on Windows platforms.

 

It is common practice on windows to place copies of the supporting dlls that 
your program loads in the same directory as the executable. The standard Win32 
LoadLibrary function will look for dlls in the directory from which the program 
executable was loaded before searching in other standard places which will 
include the directories on the PATH environment variable. This behaviour allows 
an implementer to ensure that if dlls of the same name exist in places such as 
those on the PATH list that the version that is placed in the executable 
directory is used in preference, this is especially important if the dlls are 
unversioned as is the case with the standard build of osg plugins.

 

The current implementation of appendPlatformSpecificLibraryFilePaths for 
windows populates the osg library file path with the contents of the PATH 
environment variable. The current implementation of 
osgDB::DynamicLibrary::LoadLibrary searches for the dll on this path and if it 
finds it, it passes the full path name to the windows LoadLibrary functions. 
This defeats that functions searching behaviour and in our case causes someone 
else's version of a plugin dll to be loaded because they had put an entry in 
the PATH environment variable. We have hit this problem in real life on user 
installations. The results can be messy. Curse the popularity of OSG :-).

 

We have temporarily resolved this by explicitly setting the osg library path to 
empty in our applications.

 

I would suggest that this should be the default behaviour for 
appendPlatformSpecificLibraryFilePaths on windows as appending the PATH 
contents and some system directories is in some cases wrong, as described 
above, and in most cases superfluous as osgDB::DynamicLibrary::LoadLibrary will 
call windows LoadLibrary with the bare file name if it cannot be found on the 
osg paths, windows LoadLibrary will then run its own search algorithm which 
will include the PATH environment variable and system directories.

 

Comments anyone?

 

I no one disagrees I will submit a patch.

 

Roger

_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to