Old 28th February 2019, 13:49   #1
mjilani
Junior Member
 
Join Date: Feb 2019
Posts: 1
Static library call

Hi,

I have a static library written in C++ (test.lib). Can I call this library method from system plugin? I copied test.lib in plugin folder and trying to call method exposed by lib but getting error. Is there any difference between calling a custom dll's method and custom lib's method?

code snippet from library:
// header file
namespace TestLibrary
{
DWORD TestCall(LPCWSTR str); // Based on string content this method return 0 or 1
}

code snippet from nsi script

System::Call 'Test::TestLibrary::TestCall(t "custom string") i .R0'

MessageBox MB_OK "Test $R0" ; it print Test Error, I am expecting some int value



Any pointer highly appreciated..

Thanks,
mjilani
mjilani is offline   Reply With Quote
Old 28th February 2019, 14:08   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,356
A .LIB is not executable code, you must create a .DLL. The System plug-in does not understand C++ namespaces either, you should export the function as a undecorated C function.

Quote:
EXTERN_C DWORD WINAPI MyFunc(LPCWSTR p1)
{
return 42;
}
and add a .DEF file or whatever method your tool-chain uses to export functions.


Use http://www.dependencywalker.com/ to look at your exported function name.

Plug-ins in the plug-ins folder only work when they follow the NSIS plug-in function ABI and you don't use the System plug-in to call them.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 1st March 2019, 23:21   #3
BFeely
Junior Member
 
Join Date: Mar 2016
Posts: 15
Look through the source code at https://github.com/kichik/nsis/tree/.../Contrib/ExDLL to learn how to make NSIS plugin entry points.
BFeely 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