Old 1st November 2011, 16:58   #1
ginglese
Junior Member
 
Join Date: Jul 2006
Posts: 42
Plugin with dependancies

Hi,

i would like to create a nsis plugin to manage homemade stuff before installing my software.
So i have created a project for a nsis plugin and build it.
This plugin dll has some dependencies for Qt or homemade dll (for exemple).

could it work ?
ginglese is offline   Reply With Quote
Old 1st November 2011, 21:20   #2
LoRd_MuldeR
Major Dude
 
LoRd_MuldeR's Avatar
 
Join Date: Sep 2005
Location: Somewhere over the Slaughterhouse
Posts: 797
You would have to put all DLL's that the plug-in DLL depends on into the same folder as the installer EXE (aka $EXEDIR) - not into the folder from where the plug-in DLL is loaded (aka $PLUGINSDIR). For details look at the Dynamic-Link Library Search Order. Anyway, I would recommend to link everything statically into plug-in DLL to avoid dependencies. Qt can be built as static lib. Check your plug-in DLL with Dependency Walker to make sure it doesn't have any dependencies that could prevent it from loading correctly...

(BTW: The dependency on the Visual C++ Runtime libraries is another problem. Thus I would recommend to build plug-in DLL's with the static Runtime. Either that or link them against the VC 6.0 Runtime library, aka MSVCRT.DLL, which ships with Windows)

My Plugins: StdUtils | NSISList | CPUFeatures | ExecTimeout | KillProc
My source of inspiration: http://youtu.be/lCwY4_0W1YI
LoRd_MuldeR is offline   Reply With Quote
Old 2nd November 2011, 04:53   #3
T.Slappy
Major Dude
 
T.Slappy's Avatar
 
Join Date: Jan 2006
Location: Slovakia
Posts: 531
Send a message via ICQ to T.Slappy
Read this article: http://nsis.sourceforge.net/Building...%29_dependency

or this forum thread where my plug-in suffered with similar issues: http://forums.winamp.com/showthread.php?t=331275

Cool looking installer with custom design: www.graphical-installer.com
I offer NSIS scripting, C/C++/C#/Delphi programming: www.unsigned.sk
Develop NSIS projects in Visual Studio 2005-2019: www.visual-installer.com
or RAD Studio 2009, 2010, XE-10.3 Rio: www.rad-installer.com
T.Slappy is offline   Reply With Quote
Old 2nd November 2011, 05:37   #4
ginglese
Junior Member
 
Join Date: Jul 2006
Posts: 42
Hi,

Thanks a lot for the returns.
I will look at those links and post here how i handle things.

Guillaume
ginglese is offline   Reply With Quote
Old 5th November 2012, 11:05   #5
ginglese
Junior Member
 
Join Date: Jul 2006
Posts: 42
Hi,

Just for the record, here is how I handled it :
I use the SetOutPath before using my plugin functions.

ReserveFile "${NSISDIR}\Plugins\MyPlugin.dll"
...

SetOutPath $TEMP
File "MyPluginDependenciesDlls.dll"
File ...

MyPlugin::myPluginFunction
; get result
pop $R2

Guillaume
ginglese is offline   Reply With Quote
Old 5th November 2012, 18:24   #6
LoRd_MuldeR
Major Dude
 
LoRd_MuldeR's Avatar
 
Join Date: Sep 2005
Location: Somewhere over the Slaughterhouse
Posts: 797
I think SetOutPath will also change the "current directory", which is why the DLL will be loaded from there. That's because the "current directory" is one of the directories that will be searched when loading a DLL (remember the Dynamic-Link Library Search Order). However the directory where the installer executable is located will always be searched first. This could result in the wrong DLL being loaded! Furthermore loading DLL's from the "current directory" is discouraged, because it can result in security problems. That's why most applications will disable this behavior by calling SetDllDirectory("") nowadays. I think you would be best off by either avoiding DLL dependencies for plug-in DLL's or, if that isn't possible, let your plug-in DLL load the required DLL via LoadLibrary() and a full path. Your plug-in DLL could determine its own location (i.e. the installer's plug-ins directory) via GetModuleFileName() and then construct the path.

My Plugins: StdUtils | NSISList | CPUFeatures | ExecTimeout | KillProc
My source of inspiration: http://youtu.be/lCwY4_0W1YI
LoRd_MuldeR is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump