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. |