Archive: Calling to C++ function external library


Calling to C++ function external library
Is possible calling a C++ function external library from NSIS. This library is made for me.

Thanks for all.


Use the System plug-in.

Stu


For example, If I create a static library named stlib.lib with these source code:


// MathFuncsLib.h

namespace MathFuncs
{
class MyMathFuncs
{
public:
// Returns a + b
static double Add(double a, double b);
}
}



--------------------------------
MathFuncsLib.cpp
--------------------------------
#include "MathFuncsLib.h"

#include <stdexcept>

using namespace std;

namespace MathFuncs
{
double MyMathFuncs::Add(double a, double b)
{
return a + b;
}
}


How have to call to Add function from NSIS script?

Thanks for all.

In my opinion, since I've been away from nsis for some time, you can't call class methods from nsis... I can be wrong.... there are code that can call C# functions, you might want to check them...
I guess you can create a static function and create a instance of your class.
There are tutorials about how to use system plugin, search them :)


Do you advise me that developing a C library (.lib or .dll) is better, instead of a C++ library?

Thanks for all.


You might be able to get C++ to work, but C is way simpler. You could also write simple C wrapper for your C++ classes that only NSIS will use.