Plugin DLL dependencies

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: Hacker, petermad, Stefan2, white

User avatar
tbeu
Power Member
Power Member
Posts: 1354
Joined: 2003-07-04, 07:52 UTC
Location: Germany
Contact:

Plugin DLL dependencies

Post by *tbeu »

I am still concerned about this old issue.
1) I developed a plugin which is dynamically linked to an external DLL, i.e. by LoadLibrary() and GetProcAdress().
2) This external DLL again is statically linked to an other external DLL.
The problem is that this second DLL can typically not be found by TC if it is not in TC directory, system directory, path etc. But there is simply no way to provide an plugin archive installer pluginst.inf which does a correct job. You well always see an error like "Error loading DLL".
My only workaround is to build an installer (using NSIS) to put this second DLL in system directory. I do not like it. But what else?
TC plugins: Autodesk 3ds Max / Inventor / Revit Preview, FileInDir, ImageMetaData (JPG Comment/EXIF/IPTC/XMP), MATLAB MAT-file Viewer, Mover, SetFolderDate, Solid Edge Preview, Zip2Zero and more
User avatar
m^2
Power Member
Power Member
Posts: 1413
Joined: 2006-07-12, 10:02 UTC
Location: Poland
Contact:

Post by *m^2 »

You can specify path to your dll while loading it.
User avatar
tbeu
Power Member
Power Member
Posts: 1354
Joined: 2003-07-04, 07:52 UTC
Location: Germany
Contact:

Post by *tbeu »

You did not get the point. Of course I specify the path to the first DLL. But I am not able to do so for the second DLL which statically depends on this first external DLL. That is waht all my trouble is about.
TC plugins: Autodesk 3ds Max / Inventor / Revit Preview, FileInDir, ImageMetaData (JPG Comment/EXIF/IPTC/XMP), MATLAB MAT-file Viewer, Mover, SetFolderDate, Solid Edge Preview, Zip2Zero and more
User avatar
Lefteous
Power Member
Power Member
Posts: 9536
Joined: 2003-02-09, 01:18 UTC
Location: Germany
Contact:

Post by *Lefteous »

2tbeu
I suggest not to load the first DLL during installation. What do you think?

Which plug-in type are you referring to? The functions called during installation differ from plug-in type to plug-in type.
User avatar
tbeu
Power Member
Power Member
Posts: 1354
Joined: 2003-07-04, 07:52 UTC
Location: Germany
Contact:

Post by *tbeu »

How to decide if plugin is loaded during installation or normal use? Anyway, it does not matter as second DLL is not found during neither loadings.
I am refering to lister plugins.

I already discussed this topic with ghisler some months ago. He always recommends dynamic DLL loading. But at this point I am no longer responsible for loading of dependent DLLs. Finally, our discussion stopped without results.
TC plugins: Autodesk 3ds Max / Inventor / Revit Preview, FileInDir, ImageMetaData (JPG Comment/EXIF/IPTC/XMP), MATLAB MAT-file Viewer, Mover, SetFolderDate, Solid Edge Preview, Zip2Zero and more
User avatar
Lefteous
Power Member
Power Member
Posts: 9536
Joined: 2003-02-09, 01:18 UTC
Location: Germany
Contact:

Post by *Lefteous »

2tbeu
In which function do you call LoadLibrary?
Last edited by Lefteous on 2007-01-18, 16:45 UTC, edited 2 times in total.
User avatar
tbeu
Power Member
Power Member
Posts: 1354
Joined: 2003-07-04, 07:52 UTC
Location: Germany
Contact:

Post by *tbeu »

Lefteous wrote:In which function do you call LoadLibrary?
Ha, good question. I know you are referring to http://ghisler.ch/board/viewtopic.php?t=13327. Like most of my plugins LoadLibrary() is called in DLLMain(). Only exception is MAT-file Viewer plugin where DLL loading was developed together with ghisler. It is done in very first call to ListLoad() there.
TC plugins: Autodesk 3ds Max / Inventor / Revit Preview, FileInDir, ImageMetaData (JPG Comment/EXIF/IPTC/XMP), MATLAB MAT-file Viewer, Mover, SetFolderDate, Solid Edge Preview, Zip2Zero and more
User avatar
Lefteous
Power Member
Power Member
Posts: 9536
Joined: 2003-02-09, 01:18 UTC
Location: Germany
Contact:

Post by *Lefteous »

So I guess your problem is solved by calling it in ListLoad also in this plugin right?
User avatar
tbeu
Power Member
Power Member
Posts: 1354
Joined: 2003-07-04, 07:52 UTC
Location: Germany
Contact:

Post by *tbeu »

Lefteous wrote:So I guess your problem is solved by calling it in ListLoad also in this plugin right?
I do not think so. Second dependent DLL can still not be found by TC no matter where I load first DLL. It probably will work for semi-automatic installation as Listload() will not be called then.
TC plugins: Autodesk 3ds Max / Inventor / Revit Preview, FileInDir, ImageMetaData (JPG Comment/EXIF/IPTC/XMP), MATLAB MAT-file Viewer, Mover, SetFolderDate, Solid Edge Preview, Zip2Zero and more
User avatar
Lefteous
Power Member
Power Member
Posts: 9536
Joined: 2003-02-09, 01:18 UTC
Location: Germany
Contact:

Post by *Lefteous »

2tbeu
Do you want to claim that ListLoad is called during installation? :? What is the value of the first parameter? :wink:
User avatar
tbeu
Power Member
Power Member
Posts: 1354
Joined: 2003-07-04, 07:52 UTC
Location: Germany
Contact:

Post by *tbeu »

Lefteous wrote:Do you want to claim that ListLoad is called during installation?
Surely not. OK, there will no be error message for plugin installation. However, the first time ListLoad() is called, the second DLL can not be loaded by TC. Hence, there is still no suitable workaround except proper installer which puts this second DLL on path.
TC plugins: Autodesk 3ds Max / Inventor / Revit Preview, FileInDir, ImageMetaData (JPG Comment/EXIF/IPTC/XMP), MATLAB MAT-file Viewer, Mover, SetFolderDate, Solid Edge Preview, Zip2Zero and more
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50475
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Try setting the current directory to the directory of your plugin in ListLoad BEFORE calling LoadLibrary, and set it back to what it was before when the dll is loaded.
Author of Total Commander
https://www.ghisler.com
User avatar
tbeu
Power Member
Power Member
Posts: 1354
Joined: 2003-07-04, 07:52 UTC
Location: Germany
Contact:

Post by *tbeu »

By means of GetCurrentDirectory()/SetCurrentDirectory()? OK, I will test it.
Last edited by tbeu on 2007-01-18, 21:57 UTC, edited 1 time in total.
TC plugins: Autodesk 3ds Max / Inventor / Revit Preview, FileInDir, ImageMetaData (JPG Comment/EXIF/IPTC/XMP), MATLAB MAT-file Viewer, Mover, SetFolderDate, Solid Edge Preview, Zip2Zero and more
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50475
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Yes, exactly! I hope that at least this will work. Another alternative would be to change the environment of your program - add the plugin directory to the PATH variable.
Author of Total Commander
https://www.ghisler.com
User avatar
tbeu
Power Member
Power Member
Posts: 1354
Joined: 2003-07-04, 07:52 UTC
Location: Germany
Contact:

Post by *tbeu »

In a quick test GetCurrentDirectory() returned the directory of the file to load. Using SetCurrentDirectory(PLUGIN_DIR) the dependent DLLs could be loaded. Seems that this solves the problem. Certainly one more hint for plugin developers! Thanks!
TC plugins: Autodesk 3ds Max / Inventor / Revit Preview, FileInDir, ImageMetaData (JPG Comment/EXIF/IPTC/XMP), MATLAB MAT-file Viewer, Mover, SetFolderDate, Solid Edge Preview, Zip2Zero and more
Post Reply