Link to home
Start Free TrialLog in
Avatar of mrpc_cambodia
mrpc_cambodia

asked on

How to import a DLL into my unmanaged C++ application?

Hello,

I am new to C++ programming. I started to develop application using Visual Studio C++ 2008. in my application, i need to use some function in a DLL file provided by a third party software vendor.

I dont know how to import that dll into my application? can you show me how? actually i only have one file with DLL as file extension. is it enough to import and use it? how about *.lib file? can you tell me the difference between this two type of file?

i received the below error when i build my applicaiton, hope it gives you further awareness of my problem:

Error      1      error LNK2019: unresolved external symbol "public: virtual __thiscall ImqStr::~ImqStr(void)" (??1ImqStr@@UAE@XZ) referenced in function _msgTrigger      MsgExits.obj


Thanks in advance,

mrpc_cambodia
ASKER CERTIFIED SOLUTION
Avatar of drichards
drichards

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mrpc_cambodia
mrpc_cambodia

ASKER

thanks for your response,

i only the dll file, not the lib file. can my program just work with the dll alone? or is it possible to generate lib file from the dll file?


Thank you,

mrpc_cambodia
You need the lib file or it won't work.
thanks drichards,

now i can compile my program. but to compile i need to specify 4 lib files instead of 1. and with me i only have one dll file with the same name as one of my lib file.

so can you clarify me do i need to have 4 dll files that correspond to the 4 lib files in order for my application to execute sucessfully? because now it can compile.


Thanks so much,

mrpc_cambodia
What 4 lib files do you need?  If they are ones from Microsoft, then the dlls will be available in the system.  Otherwies, you need dlls to go with the lib files or you will have loader errors when you try to run the program.
These are the libs file that i need to specify to the linker input, sorry it's not 4 files, but 5. only the first 2 files and the last one, i can find it's corresponding dll file:

imqb23vn.lib
imqs23vn.lib
libdiapi.lib
libwdisys.lib
WSock32.Lib

I have included my code file and header in the attachment as well. Actually this code is a template from an application. once i successfully compiled it, and deployed the dll to the target application, it can't be opened for execution. the original dll is 20kb, but my version is only 7kb.

In addition, when i compile dll project, it produces one dll file and one lib file. but for this project, the lib file is not produced at all.

I need your advice.


Thanks so much, you have given me alot of help.

mrpc_cambodia
WSock32 is a standard windows library and the Winsock dlls are on the machine (they are not named the same, and that's OK).  The first two apear to be IBM MQ Series libraries, and I don't konw what the dlls are for those.  Try runnign the code and it wil tell you if you are missing dlls.

If you have runtime issues, look in the system folders (<windows root> and <windows root>\System32) and in the folder where you program is installed (or the Visual Studio output folder).  If the dlls are not there, you need to move them to one of these locations.
I am thinking of one thing that could cause the problem. i compile my application with visual studio 2008. and the final dll is to be used by a third party application which was build with visual studio 6. So could there be compatibility problem?

i am going to try to recompile my application with Visual C++ 6 compiler.


Thanks so much.

mrpc_cambodia
There can be issues if you use different versions of compilers because they use different runtime libraries.  It is always best to use libraries compiled with the same tool chain.
I receive error message below in Event Viewer:

----------- error ---------
Faulting application WDITrigger.exe, version 0.0.0.0, faulting module imqs23vn.dll, version 6.0.0.5138, fault address 0x0000672f.
----------- error ---------


Thanks so much,

mrpc_cambodia
Is this with mismatched compiler versions between your main app and the dll?  This is typical of the type of error you get when it doesn't work.  Otherwise, it may just be that you have passed bad parameters to the dll routine.  You are now into runtime debugging, which is more involved than figuring out build problems.
with the application that i'm refering to so far. it has a sample dll and a sample C++ code which i can modify to compile into dll to work with the application.

the strange thing is: i have tried both dlls, and the same error message is produced in the event viewer.

Other than this error, the application works fine on my platform.


I do really appreciate your help,

mrpc_cambodia
It does sound like you are passing a bad parameter (or set of parameters) somewhere.
I don't think it does involve any bad paramater passing. i just copy and paste the dll in a designated folder and as in the product documentation, it said so.

it leads me to think it could be a platform problem. I'll investigate more and let you know any further clue i could found.


Thank you,

mrpc_cambodia
Thanks so much for your effort.

Your contribution is really amazing. With your clear instruction, my problem could have been solved since the beginning.

Now my problem is solved. it's not an error on my side, it's the documentation from the vendor that is the source of the error.


Thank you,

Have a nice day.