来自GSL的excel将不使用DLL函数 [英] excel won't use DLL functions when coming from GSL

查看:76
本文介绍了来自GSL的excel将不使用DLL函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是C ++的新手.我需要将其与excel链接.我设法用导出到Excel的基本功能(+,正方形,减法,导出数组1D)对基本DLL进行编程.

问题:我将DLL链接到GSL,并尝试使用Bessel函数(我确实链接了库,并从控制台应用程序中检查了从gsl导出的dll bessel函数是否起作用).

在excel中,一旦尝试在DLL中使用gsl导出函数,就找不到DLL.
这是我的DLL代码:(我修改了原来的实际减法函数后,将bessel函数置于soustraction中,并且正如我提到的那样,当从控制台应用程序调用此DLL函数时,这是可行的,因为我将gsl库正确地链接到了我的DLL项目)

#include"maDll.h";
#include;



double __stdcall carrre(double&arg)
{return arg * arg;}
双重__stdcall加法(double&arg1,double&arg2)
{return arg1 + arg2;}
double __stdcall soustraction(double&arg1,double&arg2)
{return gsl_sf_bessel_J0(5);}




void __stdcall DoubleElements(double * tableau,double * tableau2,long lngNbItems)
{
长我;
对于(i = 0; i< gnbitbits; i ++)> tableau [i] = 2.13 * tableau [i];
tableau2 [i] = gsl_sf_bessel_J0(i + 1);

}
}

VB :(如果我不使用gsl函数,则可以使用)

私人声明功能carrre _
库"C:\ Users \ ME \ Documents \ Visual Studio 2008 \ Projects \ MaDll \ Debug \ MaDll.dll"(arg作为Double)作为Double

私有声明函数添加_
库"C:\ Users \ ME \ Documents \ Visual Studio 2008 \ Projects \ MaDll \ Debug \ MaDll.dll" _
(arg1作为Double,arg2作为Double)作为Double

私人声明函数的用法_
库"C:\ Users \ ME \ Documents \ Visual Studio 2008 \ Projects \ MaDll \ Debug \ MaDll.dll"; _
(arg1作为Double,arg2作为Double)作为Double

谢谢,我已经搜索到了这一步,但是现在我很迷路了.

Hi, I am new to C++. I need to link it with excel,. I managed to program basic DLL''s with basic functions exported to Excel (+, square, substraction, export arrays 1D).

Problem: I linked my DLL to the GSL and tried to use the Bessel function (I did link the libraries and checked from a console application that my dll bessel function exported from gsl worked).

In excel, the DLL is not found anymore as soon as I try to use the gsl exported function in my DLL.
Here is my DLL code: (I put the bessel function in soustraction after modifying my original working real substraction function and as I mentioned this works when this DLL function is called from a console application, since I linked the gsl library properly to my DLL project)

#include "maDll.h";
#include ;



double __stdcall carrre (double& arg)
{return arg*arg;}
double __stdcall addition (double& arg1, double& arg2)
{return arg1+arg2;}
double __stdcall soustraction (double& arg1, double& arg2)
{return gsl_sf_bessel_J0 (5);}




void __stdcall DoubleElements(double * tableau,double * tableau2, long lngNbItems)
{
long i;
for (i=0;i<lngnbitems;i++)> tableau[i] = 2.13 * tableau[i];
tableau2[i] = gsl_sf_bessel_J0 (i+1);

}
}

VB: (it works if I don''t use the gsl function)

Private Declare Function carrre _
Lib "C:\Users\ME\Documents\Visual Studio 2008\Projects\MaDll\Debug\MaDll.dll" (arg As Double) As Double

Private Declare Function addition _
Lib "C:\Users\ME\Documents\Visual Studio 2008\Projects\MaDll\Debug\MaDll.dll" _
(arg1 As Double, arg2 As Double) As Double

Private Declare Function soustraction _
Lib "C:\Users\ME\Documents\Visual Studio 2008\Projects\MaDll\Debug\MaDll.dll"; _
(arg1 As Double, arg2 As Double) As Double

Thank you, I have searched to be up to this point but now I am quite lost...

推荐答案

Excel必须能够找到GSL库(DLL).

因此,您必须将GSL.DLL放在Excel可以找到它的位置,或者告诉Excel在哪里可以找到它,或者使用C ++ DLL来查找/加载它.

要确认这是问题所在,您可以将DLL复制到Excel Bin目录中,然后查看是否找到了DLL,但您不应在用户计算机上执行该操作.

最终的解决方案可能是将GSL和C ++ DLL合并在一起.

顺便说一下,您是否拥有GSL.DLL的源代码?
Excel must be able to find GSL library (DLL).

Thus you have to put GSL.DLL where Excel can find it or tell Excel where to find it or uses you C++ DLL to find/load it.

To comfirm this is the problem, you can copy the DLL inside Excel Bin directory and then see if the DLL is found but you should not do that on user computer.

A final solution might be to merge GSL and C++ DLL together.

By the way, do you have the source code of GSL.DLL?


另一种可能解决该问题的方法是从C ++ DLL动态加载DLL,而不是静态链接到它. ..

因此,您的C ++ DLL可能具有导出的函数LoadGSL(),可能还有UnLoadGSL(),您可能会从Excel调用以间接加载GSL.

实际上,使用解决方案在很大程度上取决于GSL的复杂性.如果它是仅包含一堆C样式函数的简单DLL,则在使用动态加载的C ++代码中进行包装很容易.
Another way that might resolve the problem is to dynamically load the DLL from your C++ DLL instead of statically linking to it...

Thus your C++ DLL migh have a exported function LoadGSL() and possibly UnLoadGSL() thay you would call from Excel to indirectly load GSL.

In fact, the solution to uses depends a lot on the complexity of GSL. If it was a simple DLL with only a bunch of C-style functions, it would be easy to do a wrapper in C++ code that would uses dynamic loading.


如果您正在创建库,从源代码开始,那么更简单的解决方案可能只是将代码放在相同的DLL中,并使用Excel中的单个DLL(包括间接使用).
If your are creating the librairies from the source code, then the easier solution might simply be to put your code in the same DLL and uses a single DLL from Excel (including indirect uses).


这篇关于来自GSL的excel将不使用DLL函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆