由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - 急问:VS2008里如何调用DLL
相关主题
问个小问题一个C语言的面试题,有点乱,麻烦看一下
怎样把gsl-1.15安装到vs2012ultimate平台上?请教一个C++ typedef的问题
如何使用这个template?为啥允许这样的const设计
Why the number is not exact in C++请教函数 INIT 怎么能free memory
请问const myClass &src 和myClass const &src有什么区别?问个GSL的问题
typedef const char *month Table[3]C库函数:strpbrk() 的实现一问
C++ STL map find does not work ???请问以下代码有什么错误?
有段c++代码看不懂C++ Q05: pointer to constant variable
相关话题的讨论汇总
话题: dll话题: hdll话题: pinv话题: cdf话题: gammainv
进入Programming版参与讨论
1 (共1页)
b**a
发帖数: 1375
1
要使用GSL的计算库
把libgsl.dll放在了对应的目录下.
如下程序
typedef double (*pgsl_cdf_gamma_Pinv)(const double P, const double a
, const double b);
HINSTANCE hDLL;
hDLL=LoadLibraryW((LPCWSTR)"libgsl.dll");
if(hDLL==NULL){
cout<<"dll not found";
return 0;
}
pgsl_cdf_gamma_Pinv GammaInv;
GammaInv=(pgsl_cdf_gamma_Pinv)GetProcAddress(hDLL,"gsl_cdf_gamma_
Pinv");
cout< 总是提示找不到dll,
请大牛指教, 拜谢了.
r*********r
发帖数: 3195
2
why not link the library with the program?
dynamic loading only looks in the default paths, most likely not in the
current directory.
k***r
发帖数: 4260
3
where exactly did you put the DLLs?

【在 b**a 的大作中提到】
: 要使用GSL的计算库
: 把libgsl.dll放在了对应的目录下.
: 如下程序
: typedef double (*pgsl_cdf_gamma_Pinv)(const double P, const double a
: , const double b);
: HINSTANCE hDLL;
: hDLL=LoadLibraryW((LPCWSTR)"libgsl.dll");
: if(hDLL==NULL){
: cout<<"dll not found";
: return 0;

y******e
发帖数: 359
4

If you don't specify the absolute path for the dll.
The sequence to find the dll:
1. The directory where the exe is located.
2. The current directory set by SetCurrentDirectory API. (Many other
programs could change the "current directory".
3. %windir%
4. %windir%\system32
5. the folders in the environment variale %PATH%
You could specify the absolute path to the dll then you can be sure the
right dll is loaded.

【在 k***r 的大作中提到】
: where exactly did you put the DLLs?
y******e
发帖数: 359
5
You check the hHandle to decide if the dll is there, that's wrong.
There are many reasons the hHandle could be NULL but the right dll is there.
For example:
If the dllmain has a bug or the global class object contructor causes crash,
then hHandle will be NULL.
To determine the right cause, you should call GetLastError API to find the
root cause of the loading failure.

【在 y******e 的大作中提到】
:
: If you don't specify the absolute path for the dll.
: The sequence to find the dll:
: 1. The directory where the exe is located.
: 2. The current directory set by SetCurrentDirectory API. (Many other
: programs could change the "current directory".
: 3. %windir%
: 4. %windir%\system32
: 5. the folders in the environment variale %PATH%
: You could specify the absolute path to the dll then you can be sure the

c****e
发帖数: 1453
6
It's possible this was caused by dll dependency, which means libgsl.dll
needs other dlls to be loaded, so the loading failed and returned NULL.
1 (共1页)
进入Programming版参与讨论
相关主题
C++ Q05: pointer to constant variable请问const myClass &src 和myClass const &src有什么区别?
如何让这个cur变量正确指向新地址typedef const char *month Table[3]
which str_cmp code is better?C++ STL map find does not work ???
how to resolve this problem?有段c++代码看不懂
问个小问题一个C语言的面试题,有点乱,麻烦看一下
怎样把gsl-1.15安装到vs2012ultimate平台上?请教一个C++ typedef的问题
如何使用这个template?为啥允许这样的const设计
Why the number is not exact in C++请教函数 INIT 怎么能free memory
相关话题的讨论汇总
话题: dll话题: hdll话题: pinv话题: cdf话题: gammainv