开发者

How to include a dll file that is been wrapped into a new dll?

In my application I have to explicitly link to a dll. The application is in QT with gcc compiler.

The dll the application have to link to is a wrapper around another old dll. The purpose is to fit the old dll to a new interface.

I use implicit linking when compiling the new dll. The new dll is compiled with msvc 2008. The reason is that the old dll has c++ class functions which can't be recognized by gcc. The new interface uses c functions.

So the big picture is that when I run my application I link the new dll and the new dll depends on the old dll. Everything works fine, except that I have to put the old dll开发者_如何学Python in the same folder as the exe or the same folder as the .pro file.

I have tried to add the old library into the application's qt .pro file but didn't work.

Is there any way I can move the directory of the old dll file?

To state more clearly, If the old dll and application are compiled with the same compiler, I could include the path to the old dll and lib in the .pro file and put it any where I want.

However, now, only the new dll recognizes the old dll functions so I could no longer do that. I wonder whether there is a way to modify the path that the exe file searches while running. Now it searches both the exe folder and its parent folder.


The windows operating system looks for dll's in a specified manner, the following link might help: Dynamic-Link Library Search

If you want to keep the dll in another folder, then adding the lib folder to your PATH variable will work, but you when you deploy the package you will have to make sure that the dll on the target machine can be found using the library search order as specified in the link.


I tried to modify the dll search order with SetDllDirectory which is mentioned from the link in Steven's answer. However it seems to be a msvc function only. (I'm not sure, but I included the mingw winbase.h file and it still doesn't recognizes it.)

So I tried to modify the PATH variable using putenv and it works.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜