PDA

View Full Version : Problem loading external dll



wangyingmm
27th June 2012, 16:46
I create a clr project using some external dlls which are .net based and don't have lib file with it.

my clr project build result is put in myproject\bin64, while the external dlls are put in myproject\extensions.

I use QCoreApplication::addLibraryPath("myproject\extensions") to set the external dll path, I checked with QCoreApplication::libraryPaths() that the correct absolute path is added.

but when running my application, exception is thrown saying the external dll file is not founded.

but if I copy the external dll to myproject\bin64, then it works fine. but to keep the project folders neat and well structured, I don't want to put everything in bin64 folder.

any hint about it?

thanks and regards,
WY

wysota
27th June 2012, 16:58
DLLs are loaded before the application is executed thus before any of your code is executed thus before addLibraryPath() is executed. This call is meant to do something different than you expect. Follow your platform guidelines for deploying dll files with your application.

wangyingmm
27th June 2012, 18:01
Can you simply suggest what the guideline for deploying external dll in window 7 is? Does that mean I have to put the external dll in my project output folder?

wysota
27th June 2012, 19:34
There are different approaches available. Putting the libraries in the same directory as the application binary is one of them, probably the most common one.

wangyingmm
28th June 2012, 09:14
There are different approaches available. Putting the libraries in the same directory as the application binary is one of them, probably the most common one.

my question is exactly "what those other approach are". As I said I don;t want to put all of them into bin folder.

wysota
28th June 2012, 10:15
my question is exactly "what those other approach are". As I said I don;t want to put all of them into bin folder.

As I said, google it or look in msdn. This is nothing related to Qt. What's the point of me repeating what has already been written numerous times all over the internet? What you find will probably explain the situation better and will be more suited to your particular usecase.

wangyingmm
28th June 2012, 10:54
As I said, google it or look in msdn. This is nothing related to Qt. What's the point of me repeating what has already been written numerous times all over the internet? What you find will probably explain the situation better and will be more suited to your particular usecase.

then why don't just say you don't know neither. putting useless answer here is also a wasting of time!

high_flyer
28th June 2012, 11:34
then why don't just say you don't know neither. putting useless answer here is also a wasting of time!
@angyingmm:
If you look at wysotas stats (right corner of any of his posts header) you will see he has about 26500 posts (at time of writing this post).
More importantly, he has ~3800 Thanked posts!
I wouldn't, with my 4th!! posts on this forum go and say he "doesn't know" or, that he posts "useless answers".
However, it is "useless" to post questions which are not Qt related in a Qt Programming forum.
Moreover, he DID gave you the answer, one you either don't quite understand or too lazy to follow - neither is a reason to slash out.

Above was meant as a friendly tip.

wysota
28th June 2012, 12:39
then why don't just say you don't know neither. putting useless answer here is also a wasting of time!

There are many approaches available, I'm not a trueseer, I can't see what sits inside your head and which approach is best for you. I told you what to look for, that should be enough. If not, then you can hire me or someone else to look it up for you and implement it for you while you're taking a sunbath at the Carribeans.

wangyingmm
28th June 2012, 13:39
................

Added after 4 minutes:


@angyingmm:
If you look at wysotas stats (right corner of any of his posts header) you will see he has about 26500 posts (at time of writing this post).
More importantly, he has ~3800 Thanked posts!
I wouldn't, with my 4th!! posts on this forum go and say he "doesn't know" or, that he posts "useless answers".
However, it is "useless" to post questions which are not Qt related in a Qt Programming forum.
Moreover, he DID gave you the answer, one you either don't quite understand or too lazy to follow - neither is a reason to slash out.

Above was meant as a friendly tip.

I guess a friendly tip is to give people answer on the thing they need help rather than let them search Google. I do appreciate and admire people here who have knowledge and are willing to share with others. That’s why I come here and ask, but unfortunately met people either can't quite understand the problem, or too lazy to answer. same, neither is a reason to putting the problem out off Qt.

It IS a QT related question! I DO know how to do it with a normal .net project, but not a Qt project. that's why I ask here.

amleto
28th June 2012, 13:40
There are many approaches available, I'm not a trueseer, I can't see what sits inside your head and which approach is best for you. I told you what to look for, that should be enough. If not, then you can hire me or someone else to look it up for you and implement it for you while you're taking a sunbath at the Carribeans.

*like*
10chars




I guess a friendly tip is to give people answer on the thing they need help rather than let them search Google. I do appreciate and admire people here who have knowledge and are willing to share with others. That’s why I come here and ask, but unfortunately met people either can't quite understand the problem, or too lazy to answer. same, neither is a reason to putting the problem out off Qt.

It IS a QT related question! I DO know how to do it with a normal .net project, but not a Qt project. that's why I ask here.


Your problem is that you used some Qt features wrongly, and thought that the result was a Qt problem. In fact you have a packaging/deployment problem which is not Qt related.

wysota
28th June 2012, 14:12
It IS a QT related question! I DO know how to do it with a normal .net project, but not a Qt project. that's why I ask here.
No, it's not related to Qt. Remove all Qt code from your app, take any 3rd party library unavailable by default on the target machine and you'll have the exact same problem. If you know how to solve it there, solve it the same way here. Your problem manifests itself BEFORE the application is executed thus how can it be related to what is INSIDE the application? If you don't believe then remove all code from main(), leave just a simple std::cout << "Hello" << std::endl; and see if it gets printed. If it's not then you should come to a conclusion that whatever you write as code of your program will not help your situation in any way (and thus since not a single line of Qt code was executed, this is not a problem related to Qt).