linking DLL's into c++ program QTCreator
I am somewhat new to this concept and am having some problems loading libraries at run time. On the development machine I am using, the libraries seem to get loaded properly and the program will run correctly at all times, but when i compile this program and move it to another computer with the required DLLs, they fail to load. I THINK the main reason this is happening is because the DLL that isn't loading is in a folder on the system somewhere (like C:\windows\system32) which doesn't exist on most other computers.
My question is, if i provide a custom DLL with the functionality required and ship it with the program, how can I get it to link properly in QTCreator? I have tried a combination of the -l and -L flags (ex: -llibname -LC:\path\to\where\dll\would\be) but this doesn't seem to do the trick either. The other surprising thing (to me anyway) is that even though the DLL would be required for the program to run, the program still succesfully launches an other computers.
If anyone has any adv开发者_如何学编程ice or tutorials I can read about this, i would be very grateful.
Firstly, you should read up on how Windows finds DLLs in order to load them.
Secondly, once you know how that process works, you could consider shipping your DLLs with your application so the problems go away when run on other machines. You should check that you have the rights to do that if they are third-party DLLs.
Thirdly, the Windows dependency walker tool is really great at diagnosing DLL load issues at runtime. Just load an .exe
into it and hit F7 to start profiling. It will show you all the DLLs your application loaded and from where.
Lastly, I don't know QTCreator but I would imagine that all you need to do is pass it the .lib
file with the right switch (and this link suggests that -L
is the correct switch, FWIW).
精彩评论