Answered by:
Difference between DLL and LIB.? error reasons by using DLL file instead of LIB file?

Question
-
Is there anybody who can explain me?
I am trying for using DLL file from MFC application by using the procedures of the following web link.
http://www.functionx.com/visualc/libraries/staticdll.htm
I can run successfully my tested program by adding LIB file into my project. (the author's direction)
When I added DLL file into my project and run again, I got the error associated with this declaration "extern "C" __declspec(dllimport)void BoxProperties(double L, double H, double W, double& A, double& V);"
If I want to add only DLL file into MFC application, how can I change the code.
My problem is I can download only DLL file not LIB for my real project.
If you have time, I also would like to know what the main difference between LIB and DLL files is.
Because, I wonder " the project can run for adding LIB but show error for using DLL."
Thank you very much for reading my question.Tuesday, October 14, 2008 3:59 AM
Answers
-
Hi, excuseme, maybe i'm just causing confussion to you, try to follow this links...
http://msdn.microsoft.com/en-us/library/9yd93633.aspx
Why dll's
Juan Carlos Ruiz- Marked as answer by jack 321 Friday, October 17, 2008 6:27 AM
Tuesday, October 14, 2008 5:10 AM
All replies
-
1- using static links the final code in library is integrated with your executable, so the file will be bigger
2- each time you run the program, all library content will be loaded to memory again
3- if you make changes to the library yo need to recompile all the code, not just the library
4- for the error be sure the dll file is in the same executable path or the dll location could be referenced from the path environment variable ( by exampl in Windows\System32)
Juan Carlos Ruiz- Proposed as answer by Juan Carlos Ruiz [perfil anterior] Tuesday, October 14, 2008 4:44 AM
- Edited by Juan Carlos Ruiz [perfil anterior] Tuesday, October 14, 2008 5:27 AM
Tuesday, October 14, 2008 4:20 AM -
Dear Expert,
Thank you for you explaination about lib file.How about the dll file?
I have copied two files dll and lib into my application folder.
I got error message after pressing Ctrl+F5 by adding my DLL file from "Project -> Add to Project -> Files".
But why the project works well after pressing Ctrl+F5 by adding my LIB file from "Project -> Add to Project -> Files".
I would like to know that the example project is compactible only for adding lib?? not for dll.??
if I want to add/use dll file into my MFC application, could i follow the same ways mentioned in the http://www.functionx.com/visualc/libraries/staticdll.htm web page.Tuesday, October 14, 2008 4:51 AM -
How could I correct my errors??
I compare my steps for trying with both LIB and DLL files. Kindly give me some solutions to overcome it.
Working well...
1: follwed the setps according to the infrormation from http://www.functionx.com/visualc/libraries/staticdll.htm. (For MFC )
2: but inside MFC, I add "LIB" file Project->Add to Project->Files.Got error...
1: follwed the setps according to the infrormation from http://www.functionx.com/visualc/libraries/staticdll.htm. (For MFC )
2: but inside MFC, I add "DLL" file Project->Add to Project->Files.
3: I also put the DLL into System32.
The eorror is like that...
Linking...
14_10_V5Dlg.obj : error LNK2001: unresolved external symbol __imp__BoxProperties
Debug/14_10_V5.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.14_10_V5.exe - 2 error(s), 0 warning(s)
Tuesday, October 14, 2008 4:58 AM -
- Edited by Juan Carlos Ruiz [perfil anterior] Tuesday, October 14, 2008 5:00 AM
Tuesday, October 14, 2008 4:58 AM -
Hi, excuseme, maybe i'm just causing confussion to you, try to follow this links...
http://msdn.microsoft.com/en-us/library/9yd93633.aspx
Why dll's
Juan Carlos Ruiz- Marked as answer by jack 321 Friday, October 17, 2008 6:27 AM
Tuesday, October 14, 2008 5:10 AM -
Hello Dear,
Thank you for giving suggestion for putting dll name as an input file..
But I still can't solve my error.
My error is like that:
Linking...
14_10_V6Dlg.obj : error LNK2001: unresolved external symbol __imp__BoxProperties
Debug/14_10_V6.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.14_10_V6.exe - 2 error(s), 0 warning(s)
I tried to give "additional library path" not only DLLname but also C:\Program Files\Microsoft Visual Studio\MyProjects\14_10_V6\DLLname.
Is there any other place for changing setting to solve my problem?
Thanky you so much for giving your time..
Regards.Tuesday, October 14, 2008 5:12 AM -
Thank you very much for the http://msdn.microsoft.com/en-us/library/9yd93633.aspx link.
Now, I know my problem for my real project,
1)I can not use Implicit Linking as I don't have LIB file.(I have only DLL file).
2)I can not use Explicit Linking as I even can't clear my errors for my tested project.. !_!
If you know the good and complete website link for using DLL files from MFC application, kindly share me please..
Thank you very much for your help.
Regards.Tuesday, October 14, 2008 5:22 AM -
are you sure this :
__declspec(dllimport)void BoxProperties(double L, double H, double W, double& A, double& V);
is not
__declspec(dllimport)void BoxProperties(double L, double H, double W, double* A, double* V);
?
see you, i need to sleep,
Juan Carlos Ruiz- Edited by Juan Carlos Ruiz [perfil anterior] Tuesday, October 14, 2008 5:26 AM
Tuesday, October 14, 2008 5:25 AM -
Hi Dear,
I think the code should be correct as I copied and tried all the things from http://www.functionx.com/visualc/libraries/staticdll.htm.
Anyway, thank you for helping me for solving my problem.Have a nice and sound sleep .. :D
See you later..
With Regards.Tuesday, October 14, 2008 5:44 AM