View Issue Details

IDProjectCategoryView StatusLast Update
0022743CommunityOCCT:Foundation Classespublic2017-10-14 10:14
ReporterszyAssigned Toabv 
PrioritynormalSeverityfeature 
Status closedResolutionno change required 
PlatformAOSL 
Product Version6.5.1 
Summary0022743: OSD_SharedLibrary :: DlOpen modification suggestion
DescriptionPost from the Forum - http://www.opencascade.org/org/forum/thread_21943/.
"Hi OCC Team,

Due to "Fatal error during graphic initialization" and TKOpenGL.dll Load Error in some weird cases

Would it be possible to change without big implication for all users :

Standard_Boolean OSD_SharedLibrary :: DlOpen ( const OSD_LoadMode Mode ) {

// ( myHandle = ( HINSTANCE )LoadLibraryEx ( myName, NULL, LOAD_WITH_ALTERED_SEARCH_PATH) ) == NULL
// replaced by
( myHandle = ( HINSTANCE ) ::LoadLibrary (myName) ) == NULL

because LOAD_WITH_ALTERED_SEARCH_PATH can be unpredictable and not under devleoper control. It look first in system dir and I dont wan too. Imagine you are workin with OCC 6.2.0 but you installed a nice OCC App 5.0 that put all dll inSystem32

LOAD_WITH_ALTERED_SEARCH_PATH seems useful for OCC, don't know really why.


Dll Hell ...
I personnaly use two ways for dll
Debug :
Path for OCC and other lib (TBB)
Release :
One big bin <dir> and that's all

Philippe
"
The proposed modification should be analyzed...
TagsNo tags attached.
Test case numberNot needed

Activities

szy

2011-10-03 16:11

manager   ~0018307

Note - http://msdn.microsoft.com/en-us/library/windows/desktop/ms682586%28v=vs.85%29.aspx#alternate_search_order_for_desktop_applications
...
The LoadLibraryEx function supports an alternate search order if the call specifies LOAD_WITH_ALTERED_SEARCH_PATH and the lpFileName parameter specifies an absolute path.

Note that the standard search strategy and the alternate search strategy specified by LoadLibraryEx with LOAD_WITH_ALTERED_SEARCH_PATH differ in just one way: The standard search begins in the calling application's directory, and the alternate search begins in the directory of the executable module that LoadLibraryEx is loading.

mkv

2017-07-13 19:37

tester   ~0068293

Dear ABV,
could you please put your opinion about it.

abv

2017-10-14 10:14

manager   ~0071436

The described probelm should not be relevant in current state of OCCT (7.1+) since TKOpenGl.dll is not loaded at run-time but linked with TKV3d.dll in a normal way. Other situations where dynamic loading can still take place are:

- Old-style loading of OCAF persistence plugins -- should be replaced by direct linking

- DRAW plugins -- should load OK since in the current OCCT build environment all libs are located in the same place (as opposed to ancient times of using WOK when the user workbench could contain only part of libs, while other libs taken from the reference workbench(es)).

Actually even in the older versions the problem described in the original issue description (when wrong DLLs are loaded from system32 dir) does not seem to be strictly bound to the usage of LOAD_WITH_ALTERED_SEARCH_PATH option.

According to MSDN docs, this option has effect only if the library (TKOpenGl.dll) is loaded with the full path specified, and in this case search for the dependent libs is started in the same folder pointed by that path, rather than in the application (i.e. executable) dir. Thus, the difference should have existed only when CSF_GraphicStr contained full path to TKOpenGl.dll but other OCCT libraries were located in different folder. This is clearly not correct setting.

Even in this condition use of LOAD_WITH_ALTERED_SEARCH_PATH seems to be reasonable since dependent libs seem to be more likely found in the same folder as the library being loaded rather than in the calling application library.

Thus I am closing this issue without making any changes.

Issue History

Date Modified Username Field Change
2011-10-03 16:11 szy New Issue
2011-10-03 16:11 szy Assigned To => abv
2011-10-03 16:11 szy Note Added: 0018307
2012-02-09 09:01 abv Target Version 6.5.3 => 6.5.4
2012-02-09 09:23 abv Target Version 6.5.4 => Unscheduled
2017-07-12 15:51 mkv Test case number => Not needed
2017-07-12 15:51 mkv Assigned To abv => msv
2017-07-12 15:51 mkv Status new => assigned
2017-07-12 16:02 msv Assigned To msv => abv
2017-07-13 19:37 mkv Note Added: 0068293
2017-10-14 10:14 abv Note Added: 0071436
2017-10-14 10:14 abv Status assigned => closed
2017-10-14 10:14 abv Resolution open => no change required
2017-10-14 10:14 abv Target Version Unscheduled =>